aigorithm commited on
Commit
c1facc5
Β·
1 Parent(s): 9d2239c
Files changed (3) hide show
  1. README.md +3 -3
  2. app.py +77 -0
  3. requirements.txt +62 -0
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Aiclown
3
- emoji: 🐠
4
  colorFrom: indigo
5
  colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 3.50.2
8
  app_file: app.py
9
  pinned: false
10
  ---
 
1
  ---
2
+ title: Demo Illusion Diffusion Hq
3
+ emoji: πŸ“‰
4
  colorFrom: indigo
5
  colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 3.44.4
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import boto3
3
+ import banana_dev as client
4
+ import os
5
+ from typing import Iterable
6
+ import gradio as gr
7
+ from gradio.themes.base import Base
8
+ from gradio.themes.utils import colors, fonts, sizes
9
+ from PIL import Image
10
+ import io
11
+ import base64
12
+ from io import BytesIO
13
+ import traceback
14
+ import uuid
15
+ from dotenv import load_dotenv
16
+ import gzip
17
+
18
+ load_dotenv()
19
+
20
+ BANANA_API_KEY = os.getenv("BANANA_API_KEY")
21
+ BANANA_MODEL_KEY = os.getenv("BANANA_MODEL_KEY")
22
+ BANANA_URL = os.getenv("BANANA_URL")
23
+
24
+ def predict(image, prompt,qr_code, negative_prompt, seed):
25
+ try:
26
+ my_model = client.Client(
27
+ api_key=BANANA_API_KEY,
28
+ model_key=BANANA_MODEL_KEY,
29
+ url=BANANA_URL,
30
+ )
31
+ #target image
32
+ with open(image.name, "rb") as f:
33
+ image_bytes = f.read()
34
+ image_encoded = base64.b64encode(image_bytes)
35
+ image = image_encoded.decode("utf-8")
36
+
37
+ print(image)
38
+ print(negative_prompt)
39
+ print(seed)
40
+ print(qr_code)
41
+ print(prompt)
42
+
43
+ inputs = {
44
+ "prompt" : prompt,
45
+ "qr_code_content" : qr_code,
46
+ "negative_prompt": negative_prompt,
47
+ "image": image,
48
+ "seed": seed
49
+ }
50
+ result, meta = my_model.call("/", inputs)
51
+ output_bytes = result["outputs"]
52
+
53
+ image_encoded = output_bytes.encode('utf-8')
54
+ image_data = base64.b64decode(image_encoded)
55
+ image_data = gzip.decompress(image_data)
56
+ image_io = BytesIO(image_data)
57
+ output_image = Image.open(image_io)
58
+ return output_image, None
59
+ except Exception as e:
60
+ tb_str = traceback.format_exception(type(e), e, e.__traceback__)
61
+ tb_str = "".join(tb_str)
62
+ return None, tb_str
63
+
64
+ with gr.Blocks() as demo:
65
+ title_with_logo = gr.Markdown("# Powered by Banana <img src='https://files.umso.co/lib_udQIfMXlGlflDxFd/rnqmq7j8oqug1kae.png' align='left' width='50' height='50'>")
66
+ with gr.Column():
67
+ image = gr.File(label="Image", file_count="single", scale=1)
68
+ prompt=gr.Textbox(label="Prompt")
69
+ qr_code=gr.Textbox(label="QR code link")
70
+ negative_prompt= gr.Textbox(label="Negative Prompt")
71
+ seed= gr.Textbox(label="Seed")
72
+ btn = gr.Button("Run illusion-diffusion-hq")
73
+ output_image = gr.Image(label="Output Image")
74
+ output_error = gr.Textbox(label="Error Message")
75
+ btn.click(predict, [image, prompt,qr_code, negative_prompt, seed], [output_image, output_error])
76
+
77
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.1.1
3
+ annotated-types==0.5.0
4
+ anyio==3.7.1
5
+ attrs==23.1.0
6
+ banana-dev==5.1.0
7
+ boto3==1.28.50
8
+ botocore==1.31.50
9
+ certifi==2023.7.22
10
+ charset-normalizer==3.2.0
11
+ click==8.1.7
12
+ contourpy==1.1.1
13
+ cycler==0.11.0
14
+ fastapi==0.103.1
15
+ ffmpy==0.3.1
16
+ filelock==3.12.4
17
+ fonttools==4.42.1
18
+ fsspec==2023.9.1
19
+ gradio==3.44.4
20
+ gradio_client==0.5.1
21
+ h11==0.14.0
22
+ httpcore==0.18.0
23
+ httpx==0.25.0
24
+ huggingface-hub==0.17.2
25
+ idna==3.4
26
+ importlib-resources==6.0.1
27
+ Jinja2==3.1.2
28
+ jmespath==1.0.1
29
+ jsonschema==4.19.0
30
+ jsonschema-specifications==2023.7.1
31
+ kiwisolver==1.4.5
32
+ MarkupSafe==2.1.3
33
+ matplotlib==3.8.0
34
+ numpy==1.26.0
35
+ orjson==3.9.7
36
+ packaging==23.1
37
+ pandas==2.1.0
38
+ Pillow==10.0.1
39
+ pydantic==2.3.0
40
+ pydantic_core==2.6.3
41
+ pydub==0.25.1
42
+ pyparsing==3.1.1
43
+ python-dateutil==2.8.2
44
+ python-multipart==0.0.6
45
+ pytz==2023.3.post1
46
+ PyYAML==6.0.1
47
+ referencing==0.30.2
48
+ requests==2.31.0
49
+ rpds-py==0.10.3
50
+ s3transfer==0.6.2
51
+ semantic-version==2.10.0
52
+ six==1.16.0
53
+ sniffio==1.3.0
54
+ starlette==0.27.0
55
+ toolz==0.12.0
56
+ tqdm==4.66.1
57
+ typing_extensions==4.8.0
58
+ tzdata==2023.3
59
+ urllib3==1.26.16
60
+ uvicorn==0.23.2
61
+ websockets==11.0.3
62
+ python-dotenv