File size: 6,356 Bytes
9ffd712
 
 
 
 
 
2699d64
9ffd712
 
 
2699d64
 
 
9ffd712
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cfd385f
a938b98
9ffd712
 
fd23ac5
 
 
 
ee3d59d
fd23ac5
9ffd712
29b726a
9ffd712
 
 
 
 
 
 
 
fd23ac5
 
 
9ffd712
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a053e6b
9ffd712
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a053e6b
9ffd712
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a053e6b
9ffd712
 
 
 
 
 
 
4803405
a053e6b
29b726a
413b360
9ffd712
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import gradio as gr
import time
from PIL import Image


# Initialize a counter to keep track of the number of times the function is called
#call_counter = 0

# Function to display different images based on the call count
def generate_image(text):
    
    # Define image paths for the first call
    image_path = "yc01.jpg"

    # If the image path exists, return it; otherwise, return None
    if image_path:
        image = Image.open(image_path)
        return image
    else:
        return None


# Function to show thumbnail
def get_ytmetas(youtube_link):

    # Define image paths for the first and second calls
    image_path = ["/content/playlist.png"]

    # If the image path exists, return it; otherwise, return None
    if image_path:
        image = Image.open(image_path)
        return f"Dalton & Michael", f"Dalton Caldwell and Michael Seibel talk startups, Silicon Valley and advice for founders."
        #return image, "Dalton & Michael", "Dalton Caldwell and Michael Seibel talk startups, Silicon Valley and advice for founders."
    else:
        return None

# Function to fine-tune a model
def train_model(youtube_link, progress=gr.Progress()):
    time.sleep(4)
    return "Model successfully trained for Datlon & Michael."

def my_function(x, progress=gr.Progress()):
    progress(0, desc="Training...")
    time.sleep(1)
    for i in progress.tqdm(range(100)):
        time.sleep(0.2)
    return "Model successfully trained for Datlon & Michael."

with gr.Blocks(title = "Old Fat Boy").queue() as demo:
    with gr.Tab("Train"):
            with gr.Row():
                tb_youtubelink = gr.Textbox(label="Youtube Link" )
            with gr.Row():
                btn_run = gr.Button("Train",variant="primary")
            with gr.Row():
                tb_indicator = gr.Textbox(label="Output")

            #btn_run.click(fn=train_model,inputs=[tb_youtubelink],outputs=[tb_indicator])
            btn_run.click(fn=my_function,inputs=[tb_youtubelink],outputs=[tb_indicator])
        
    with gr.Tab("Generate"):
        with gr.Row():
            prompt = gr.Textbox(label="Prompt" )
            image_output = gr.Image(label="Image")
        image_button = gr.Button("Generate Image")

    image_button.click(generate_image, inputs=prompt, outputs=image_output)

    with gr.Tab("Edit"):
            with gr.Column():
              edit_image = gr.Image(label="Generated Image")
                # Left --> tools
            with gr.Row():
              # Element 1
              with gr.Column():
                element1 = gr.Image(label="Element1")
                # Drag
                with gr.Row():
                    with gr.Column(scale=1, min_width=10):
                        gr.Markdown(value="Drag", show_label=False)
                    with gr.Column(scale=4, min_width=10):
                        with gr.Row():
                            with gr.Column(scale=1, min_width=10):
                                enable_add_points = gr.Button("Add Points")
                            with gr.Column(scale=1, min_width=10):
                                undo_points = gr.Button("Reset Points")
                        with gr.Row():
                            with gr.Column(scale=1, min_width=10):
                                form_start_btn = gr.Button("Start")
                            with gr.Column(scale=1, min_width=10):
                                form_stop_btn = gr.Button("Stop")


                form_draw_interval_number = gr.Number(
                    #value=global_state.value["draw_interval"],
                    label="Draw Interval (steps)",
                    interactive=True,
                    visible=False,
                )

              # Element 2
              with gr.Column():
                element1 = gr.Image(label="Element2")
                # Drag
                with gr.Row():
                    with gr.Column(scale=1, min_width=10):
                        gr.Markdown(value="Drag", show_label=False)
                    with gr.Column(scale=4, min_width=10):
                        with gr.Row():
                            with gr.Column(scale=1, min_width=10):
                                enable_add_points = gr.Button("Add Points")
                            with gr.Column(scale=1, min_width=10):
                                undo_points = gr.Button("Reset Points")
                        with gr.Row():
                            with gr.Column(scale=1, min_width=10):
                                form_start_btn = gr.Button("Start")
                            with gr.Column(scale=1, min_width=10):
                                form_stop_btn = gr.Button("Stop")


                form_draw_interval_number = gr.Number(
                    #value=global_state.value["draw_interval"],
                    label="Draw Interval (steps)",
                    interactive=True,
                    visible=False,
                )

              # Element 3
              with gr.Column():
                element1 = gr.Image(label="Element3")
                # Drag
                with gr.Row():
                    with gr.Column(scale=1, min_width=10):
                        gr.Markdown(value="Drag", show_label=False)
                    with gr.Column(scale=4, min_width=10):
                        with gr.Row():
                            with gr.Column(scale=1, min_width=10):
                                enable_add_points = gr.Button("Add Points")
                            with gr.Column(scale=1, min_width=10):
                                undo_points = gr.Button("Reset Points")
                        with gr.Row():
                            with gr.Column(scale=1, min_width=10):
                                form_start_btn = gr.Button("Start")
                            with gr.Column(scale=1, min_width=10):
                                form_stop_btn = gr.Button("Stop")

                form_draw_interval_number = gr.Number(
                    #value=global_state.value["draw_interval"],
                    label="Draw Interval (steps)",
                    interactive=True,
                    visible=False,
                )
            apply_btn = gr.Button("Apply")
        
if __name__ == "__main__":    
    demo.launch(share=False, debug=True, favicon_path='oldfatboy.png')