Spaces:
Paused
Paused
| import os | |
| from dotenv import load_dotenv | |
| from typing import Literal, List | |
| import openai | |
| import gradio as gr | |
| from backend import get_images | |
| load_dotenv() | |
| openai.api_key = os.getenv("OPENAI_API_KEY") | |
| with gr.Blocks() as demo: | |
| with gr.Column(variant="panel"): | |
| with gr.Row(variant="compact"): | |
| text = gr.Textbox( | |
| label="Enter your prompt", | |
| show_label=False, | |
| max_lines=1, | |
| placeholder="Enter your prompt", | |
| container=False, | |
| ) | |
| btn = gr.Button("Generate image") | |
| gallery = gr.Gallery( | |
| label="Generated images", | |
| show_label=False, | |
| elem_id="gallery", | |
| columns=2, | |
| rows=2, | |
| object_fit="contain", | |
| height="auto", | |
| ) | |
| btn.click(fn=get_images, inputs=text, outputs=gallery) | |
| if __name__ == "__main__": | |
| demo.launch() | |