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 = '''
WordCraft : Visuals from Verbs
A small, lightining fast efficient AI image generator
This 💻 demo uses the EfficientCLIP-GAN model which is trained on CUB dataset🐦🐥.
Keep your prompt coherent to the birds domain.
If you like the demo, don't forget to click on the like 💖 button.
'''
# Creating Gradio interface
with gr.Blocks(css=css) as app:
gr.Markdown(DESCRIPTION)
with gr.Row():
with gr.Column():
text_prompt = gr.Textbox(label="Input Prompt", value="this tiny bird has a very small bill, a belly covered with white delicate feathers and has a set of black rounded eyes.", lines=3)
generate_button = gr.Button("Generate Images", variant='primary')
with gr.Row():
with gr.Column():
image_output1 = gr.Image(label="Generated Image 1")
image_output2 = gr.Image(label="Generated Image 2")
with gr.Column():
image_output3 = gr.Image(label="Generated Image 3")
image_output4 = gr.Image(label="Generated Image 4")
generate_button.click(generate_image_from_text_with_persistent_storage, inputs=[text_prompt], outputs=[image_output1, image_output2, image_output3, image_output4])
# Launch the app
app.launch()