File size: 1,854 Bytes
3fef7c3
 
 
 
 
 
 
 
e14bd4d
3fef7c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f557d3
 
3fef7c3
 
4c55a36
 
3fef7c3
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import random
import gradio as gr
import requests
from PIL import Image

from utils import read_css_from_file
from inference import generate_image_from_text, generate_image_from_text_with_persistent_storage

# Read CSS from file
css = read_css_from_file("style.css")

DESCRIPTION = '''
    <div id="content_align">
        <span style="color:darkred;font-size:32px:font-weight:bold">
        EfficientCLIP-GAN Models Image Generation Demo
        </span>
    </div>
    <div id="content_align">
        <span style="color:blue;font-size:16px:font-weight:bold">
        Generate images directly from text prompts
        </span>
    </div>
    <div id="content_align" style="margin-top: 10px;">
    </div>
'''

# Creating Gradio interface
with gr.Blocks(css=css) as app:
    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.")
    gr.Markdown(DESCRIPTION)
    with gr.Row():
        with gr.Column():
            text_prompt = gr.Textbox(label="Input Prompt", placeholder="", lines=3)
    generate_button = gr.Button("Generate Image", variant='primary')

    with gr.Row():
        with gr.Column():
            image_output1 = gr.Image(type="pil", format = "jpeg", label="Generated Image 1")
            image_output2 = gr.Image(type="pil", format = "jpeg", label="Generated Image 2")

        with gr.Column():
            image_output3 = gr.Image(type="pil", format = "jpeg", label="Generated Image 3")
            image_output4 = gr.Image(type="pil", format = "jpeg", label="Generated Image 4")

    generate_button.click(generate_image_from_text, inputs=[text_prompt], outputs=[image_output1, image_output2, image_output3, image_output4])

# Launch the app
app.launch()