File size: 2,805 Bytes
e123da8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import gradio as gr
from src.create import create_with_generate, create_with_upload

with gr.Blocks() as demo:
    gr.Markdown("Generate background imgage for zoom using this demo.")
    with gr.Row():
        with gr.Column(scale=1):
            with gr.Row():
                organization = gr.Textbox(label="Your organization")
                name = gr.Textbox(label="Your name")
            with gr.Row():
                organization_size = gr.Number(
                    precision=0, value=35, label="Font size of organization"
                )
                name_size = gr.Number(precision=0, value=50, label="Font size of name")
            with gr.Row():
                hspace = gr.Number(precision=0, value=50, label="Horizontal space")
                vspace = gr.Number(precision=0, value=50, label="Vertical space")
                interval_space = gr.Number(
                    precision=0, value=30, label="Interval space"
                )
            red = gr.Slider(maximum=255, minimum=0, step=1, value=0, label="Red")
            green = gr.Slider(maximum=255, minimum=0, step=1, value=0, label="Blue")
            blue = gr.Slider(maximum=255, minimum=0, step=1, value=100, label="Green")

            with gr.TabItem(label="Upload image"):
                image_input = gr.Image(label="Input imgae")
                upload_button = gr.Button("Generate")
            with gr.TabItem(label="Generate image"):
                with gr.Row():
                    api_key = gr.Textbox(label="You own OpenAI API key")
                    use_before = gr.Radio(
                        ["Generate new one", "Use before one"], value="Generate new one"
                    )
                prompt = gr.Textbox(
                    value="background image for zoom meeting",
                    label="Prompt message to generate image",
                )
                generate_button = gr.Button("Generate")
        with gr.Column(scale=1):
            image_output = gr.Image(label="Output image")

    upload_button.click(
        create_with_upload,
        inputs=[
            image_input,
            name,
            organization,
            name_size,
            organization_size,
            vspace,
            hspace,
            interval_space,
            red,
            green,
            blue,
        ],
        outputs=image_output,
    )

    generate_button.click(
        create_with_generate,
        inputs=[
            prompt,
            use_before,
            api_key,
            name,
            organization,
            name_size,
            organization_size,
            vspace,
            hspace,
            interval_space,
            red,
            green,
            blue,
        ],
        outputs=image_output,
    )

demo.launch()