Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import random
|
3 |
+
import gradio as gr
|
4 |
+
import requests
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
from utils import read_css_from_file
|
8 |
+
from inference import generate_image_from_text, generate_image_from_text_with_persistent_storage
|
9 |
+
# Read CSS from file
|
10 |
+
css = read_css_from_file("style.css")
|
11 |
+
|
12 |
+
DESCRIPTION = '''
|
13 |
+
<div id="content_align">
|
14 |
+
<span style="color:darkred;font-size:32px:font-weight:bold">
|
15 |
+
EfficientCLIP-GAN Models Image Generation Demo
|
16 |
+
</span>
|
17 |
+
</div>
|
18 |
+
<div id="content_align">
|
19 |
+
<span style="color:blue;font-size:16px:font-weight:bold">
|
20 |
+
Generate images directly from text prompts
|
21 |
+
</span>
|
22 |
+
</div>
|
23 |
+
<div id="content_align" style="margin-top: 10px;">
|
24 |
+
</div>
|
25 |
+
'''
|
26 |
+
|
27 |
+
# Creating Gradio interface
|
28 |
+
with gr.Blocks(css=css) as app:
|
29 |
+
gr.Warning("This 💻 demo uses the EfficientCLIP-GAN model which is trained on CUB dataset 🐦🐥.\nKeep your prompt coherent to the birds domain.\nIf you like the demo, don't forget to click on the like 💖 button.")
|
30 |
+
gr.Markdown(DESCRIPTION)
|
31 |
+
with gr.Row():
|
32 |
+
with gr.Column():
|
33 |
+
text_prompt = gr.Textbox(label="Input Prompt", placeholder="", lines=3)
|
34 |
+
generate_button = gr.Button("Generate Image", variant='primary')
|
35 |
+
|
36 |
+
with gr.Row():
|
37 |
+
with gr.Column():
|
38 |
+
image_output1 = gr.Image(type="pil", label="Image Output 1")
|
39 |
+
image_output2 = gr.Image(type="pil", label="Image Output 2")
|
40 |
+
|
41 |
+
with gr.Column():
|
42 |
+
image_output3 = gr.Image(type="pil", label="Image Output 3")
|
43 |
+
image_output4 = gr.Image(type="pil", label="Image Output 4")
|
44 |
+
|
45 |
+
generate_button.click(generate_image_from_text, inputs=[text_prompt], outputs=[image_output1, image_output2, image_output3, image_output4])
|
46 |
+
|
47 |
+
# Launch the app
|
48 |
+
app.launch()
|