Spaces:
Running
Running
broadfield-dev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
models = [
|
6 |
"CompVis/stable-diffusion-v1-4",
|
7 |
"runwayml/stable-diffusion-v1-5",
|
8 |
-
"
|
9 |
-
"
|
10 |
-
"
|
11 |
-
"
|
12 |
-
"
|
13 |
-
"
|
14 |
-
"
|
15 |
-
"
|
16 |
]
|
17 |
|
18 |
def generate_image(prompt, model_name):
|
19 |
client = InferenceClient(model_name)
|
20 |
response = client.text_to_image(prompt)
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
# Create Gradio Interface
|
24 |
with gr.Blocks() as demo:
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
import base64
|
4 |
+
from io import BytesIO
|
5 |
+
from PIL import Image
|
6 |
|
7 |
+
# Define the list of models
|
8 |
models = [
|
9 |
"CompVis/stable-diffusion-v1-4",
|
10 |
"runwayml/stable-diffusion-v1-5",
|
11 |
+
"stabilityai/stable-diffusion-2-1-base",
|
12 |
+
"stabilityai/stable-diffusion-2-1",
|
13 |
+
"CompVis/ldm-text2im-large-256",
|
14 |
+
"lambdalabs/sd-text2img-base-2-0",
|
15 |
+
"ZB-Tech/Text-to-Image",
|
16 |
+
"cloudqi/cqi_text_to_image_pt_v0",
|
17 |
+
"kothariyashhh/GenAi-Texttoimage",
|
18 |
+
"sairajg/Text_To_Image"
|
19 |
]
|
20 |
|
21 |
def generate_image(prompt, model_name):
|
22 |
client = InferenceClient(model_name)
|
23 |
response = client.text_to_image(prompt)
|
24 |
+
|
25 |
+
if isinstance(response, list):
|
26 |
+
image_data = response[0]['image']
|
27 |
+
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
28 |
+
return image
|
29 |
+
else:
|
30 |
+
return "Failed to generate image."
|
31 |
|
32 |
# Create Gradio Interface
|
33 |
with gr.Blocks() as demo:
|