Spaces:
Runtime error
Runtime error
Kvikontent
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -47,8 +47,9 @@ def query(payload):
|
|
47 |
|
48 |
def generate_image_from_prompt(prompt_text):
|
49 |
image_bytes = query({"inputs": prompt_text})
|
50 |
-
|
51 |
-
|
|
|
52 |
|
53 |
title = "KVIImager 2.0 Demo 🎨"
|
54 |
description = "This app uses Hugging Face AI model to generate an image based on the provided text prompt 🖼️."
|
@@ -56,13 +57,13 @@ description = "This app uses Hugging Face AI model to generate an image based on
|
|
56 |
input_prompt = gr.Textbox(label="Enter Prompt 📝", placeholder="E.g. 'A peaceful garden with a small cottage'")
|
57 |
output_generated_image = gr.Image(label="Generated Image")
|
58 |
|
59 |
-
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
47 |
|
48 |
def generate_image_from_prompt(prompt_text):
|
49 |
image_bytes = query({"inputs": prompt_text})
|
50 |
+
img = BytesIO(image_bytes) # Convert to BytesIO stream
|
51 |
+
pil_img = Image.open(img) # Open the image using PIL library
|
52 |
+
return pil_img # Return the converted PIL image
|
53 |
|
54 |
title = "KVIImager 2.0 Demo 🎨"
|
55 |
description = "This app uses Hugging Face AI model to generate an image based on the provided text prompt 🖼️."
|
|
|
57 |
input_prompt = gr.Textbox(label="Enter Prompt 📝", placeholder="E.g. 'A peaceful garden with a small cottage'")
|
58 |
output_generated_image = gr.Image(label="Generated Image")
|
59 |
|
60 |
+
#with gr.Blocks(theme=gr.themes.Soft()) as app:
|
61 |
+
# caption = "Generate Image"
|
62 |
+
iface = gr.Interface(
|
63 |
+
generate_image_from_prompt,
|
64 |
+
inputs=input_prompt,
|
65 |
+
outputs=output_generated_image,
|
66 |
+
title=title,
|
67 |
+
description=description
|
68 |
+
)
|
69 |
+
iface.launch()
|