File size: 937 Bytes
33bc31b
 
 
 
 
 
 
7baaae1
 
33bc31b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()