Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
index.py
CHANGED
@@ -78,35 +78,17 @@ def image_classifier(prompt, starter_image, image_strength):
|
|
78 |
|
79 |
print(output)
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
print(image_url)
|
91 |
-
response = requests.get(image_url)
|
92 |
-
print(response)
|
93 |
-
img2 = Image.open(io.BytesIO(response.content))
|
94 |
-
|
95 |
-
# Download the image from the URL
|
96 |
-
image_url = output[2]
|
97 |
-
print(image_url)
|
98 |
-
response = requests.get(image_url)
|
99 |
-
print(response)
|
100 |
-
img3 = Image.open(io.BytesIO(response.content))
|
101 |
-
|
102 |
-
return [img1, img2, img3]
|
103 |
-
|
104 |
-
|
105 |
-
# app = Flask(__name__)
|
106 |
-
# os.environ.get("REPLICATE_API_TOKEN")
|
107 |
|
108 |
-
|
109 |
-
# def index():
|
110 |
|
111 |
demo = gr.Interface(fn=image_classifier, inputs=["text", "image", gr.Slider(0, 1, step=0.025, value=0.2, label="Image Strength")], outputs=["image", "image", "image"])
|
112 |
demo.launch(share=False)
|
|
|
78 |
|
79 |
print(output)
|
80 |
|
81 |
+
images = []
|
82 |
+
for i in range(min(len(output), 3)):
|
83 |
+
image_url = output[i]
|
84 |
+
response = requests.get(image_url)
|
85 |
+
images.append(Image.open(io.BytesIO(response.content)))
|
86 |
+
|
87 |
+
# Add empty images if fewer than 3 were returned
|
88 |
+
while len(images) < 3:
|
89 |
+
images.append(Image.new('RGB', (512, 512), 'gray'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
+
return images
|
|
|
92 |
|
93 |
demo = gr.Interface(fn=image_classifier, inputs=["text", "image", gr.Slider(0, 1, step=0.025, value=0.2, label="Image Strength")], outputs=["image", "image", "image"])
|
94 |
demo.launch(share=False)
|