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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import time
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# Initialize a counter to keep track of the number of times the function is called
|
| 7 |
+
call_counter = 0
|
| 8 |
+
|
| 9 |
+
# Function to display different images based on the call count
|
| 10 |
+
def generate_image(text):
|
| 11 |
+
global call_counter
|
| 12 |
+
|
| 13 |
+
# Define image paths for the first and second calls
|
| 14 |
+
image_paths = ["/content/yc01.jpg", "/content/yc02.png"]
|
| 15 |
+
|
| 16 |
+
# Check if the call_counter is within the range of available image paths
|
| 17 |
+
if call_counter < len(image_paths):
|
| 18 |
+
image_path = image_paths[call_counter]
|
| 19 |
+
call_counter += 1
|
| 20 |
+
else:
|
| 21 |
+
image_path = None
|
| 22 |
+
|
| 23 |
+
# If the image path exists, return it; otherwise, return None
|
| 24 |
+
if image_path:
|
| 25 |
+
image = Image.open(image_path)
|
| 26 |
+
return image
|
| 27 |
+
else:
|
| 28 |
+
return None
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# Function to show thumbnail
|
| 32 |
+
def get_ytmetas(youtube_link):
|
| 33 |
+
|
| 34 |
+
# Define image paths for the first and second calls
|
| 35 |
+
image_path = ["/content/playlist.png"]
|
| 36 |
+
|
| 37 |
+
# If the image path exists, return it; otherwise, return None
|
| 38 |
+
if image_path:
|
| 39 |
+
image = Image.open(image_path)
|
| 40 |
+
return f"Dalton & Michael", f"Dalton Caldwell and Michael Seibel talk startups, Silicon Valley and advice for founders."
|
| 41 |
+
#return image, "Dalton & Michael", "Dalton Caldwell and Michael Seibel talk startups, Silicon Valley and advice for founders."
|
| 42 |
+
else:
|
| 43 |
+
return None
|
| 44 |
+
|
| 45 |
+
# Function to fine-tune a model
|
| 46 |
+
def train_model(youtube_link):
|
| 47 |
+
time.sleep(1)
|
| 48 |
+
return "Model successfully trained for Datlon & Michael."
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
with gr.Blocks(title = "Old Fat Boy") as demo:
|
| 52 |
+
with gr.Tab("Train"):
|
| 53 |
+
with gr.Row():
|
| 54 |
+
tb_youtubelink = gr.Textbox(label="Youtube Link" )
|
| 55 |
+
with gr.Row():
|
| 56 |
+
btn_run = gr.Button("Train",variant="primary")
|
| 57 |
+
with gr.Row():
|
| 58 |
+
tb_indicator = gr.Textbox(label="Output")
|
| 59 |
+
|
| 60 |
+
btn_run.click(fn=train_model,inputs=[tb_youtubelink],outputs=[tb_indicator])
|
| 61 |
+
|
| 62 |
+
with gr.Tab("Generate"):
|
| 63 |
+
with gr.Row():
|
| 64 |
+
prompt = gr.Textbox(label="Prompt" )
|
| 65 |
+
image_output = gr.Image(label="Image")
|
| 66 |
+
image_button = gr.Button("Generate Image")
|
| 67 |
+
|
| 68 |
+
image_button.click(generate_image, inputs=prompt, outputs=image_output)
|
| 69 |
+
|
| 70 |
+
with gr.Tab("Edit"):
|
| 71 |
+
with gr.Column():
|
| 72 |
+
edit_image = gr.Image(label="Generated Image")
|
| 73 |
+
# Left --> tools
|
| 74 |
+
with gr.Row():
|
| 75 |
+
# Element 1
|
| 76 |
+
with gr.Column():
|
| 77 |
+
element1 = gr.Image(label="Element1")
|
| 78 |
+
# Drag
|
| 79 |
+
with gr.Row():
|
| 80 |
+
with gr.Column(scale=1, min_width=10):
|
| 81 |
+
gr.Markdown(value="Drag", show_label=False)
|
| 82 |
+
with gr.Column(scale=4, min_width=10):
|
| 83 |
+
with gr.Row():
|
| 84 |
+
with gr.Column(scale=1, min_width=10):
|
| 85 |
+
enable_add_points = gr.Button("Add Points")
|
| 86 |
+
with gr.Column(scale=1, min_width=10):
|
| 87 |
+
undo_points = gr.Button("Reset Points")
|
| 88 |
+
with gr.Row():
|
| 89 |
+
with gr.Column(scale=1, min_width=10):
|
| 90 |
+
form_start_btn = gr.Button("Start")
|
| 91 |
+
with gr.Column(scale=1, min_width=10):
|
| 92 |
+
form_stop_btn = gr.Button("Apply")
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
form_draw_interval_number = gr.Number(
|
| 96 |
+
#value=global_state.value["draw_interval"],
|
| 97 |
+
label="Draw Interval (steps)",
|
| 98 |
+
interactive=True,
|
| 99 |
+
visible=False,
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
# Element 2
|
| 103 |
+
with gr.Column():
|
| 104 |
+
element1 = gr.Image(label="Element2")
|
| 105 |
+
# Drag
|
| 106 |
+
with gr.Row():
|
| 107 |
+
with gr.Column(scale=1, min_width=10):
|
| 108 |
+
gr.Markdown(value="Drag", show_label=False)
|
| 109 |
+
with gr.Column(scale=4, min_width=10):
|
| 110 |
+
with gr.Row():
|
| 111 |
+
with gr.Column(scale=1, min_width=10):
|
| 112 |
+
enable_add_points = gr.Button("Add Points")
|
| 113 |
+
with gr.Column(scale=1, min_width=10):
|
| 114 |
+
undo_points = gr.Button("Reset Points")
|
| 115 |
+
with gr.Row():
|
| 116 |
+
with gr.Column(scale=1, min_width=10):
|
| 117 |
+
form_start_btn = gr.Button("Start")
|
| 118 |
+
with gr.Column(scale=1, min_width=10):
|
| 119 |
+
form_stop_btn = gr.Button("Apply")
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
form_draw_interval_number = gr.Number(
|
| 123 |
+
#value=global_state.value["draw_interval"],
|
| 124 |
+
label="Draw Interval (steps)",
|
| 125 |
+
interactive=True,
|
| 126 |
+
visible=False,
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
# Element 3
|
| 130 |
+
with gr.Column():
|
| 131 |
+
element1 = gr.Image(label="Element3")
|
| 132 |
+
# Drag
|
| 133 |
+
with gr.Row():
|
| 134 |
+
with gr.Column(scale=1, min_width=10):
|
| 135 |
+
gr.Markdown(value="Drag", show_label=False)
|
| 136 |
+
with gr.Column(scale=4, min_width=10):
|
| 137 |
+
with gr.Row():
|
| 138 |
+
with gr.Column(scale=1, min_width=10):
|
| 139 |
+
enable_add_points = gr.Button("Add Points")
|
| 140 |
+
with gr.Column(scale=1, min_width=10):
|
| 141 |
+
undo_points = gr.Button("Reset Points")
|
| 142 |
+
with gr.Row():
|
| 143 |
+
with gr.Column(scale=1, min_width=10):
|
| 144 |
+
form_start_btn = gr.Button("Start")
|
| 145 |
+
with gr.Column(scale=1, min_width=10):
|
| 146 |
+
form_stop_btn = gr.Button("Apply")
|
| 147 |
+
|
| 148 |
+
form_draw_interval_number = gr.Number(
|
| 149 |
+
#value=global_state.value["draw_interval"],
|
| 150 |
+
label="Draw Interval (steps)",
|
| 151 |
+
interactive=True,
|
| 152 |
+
visible=False,
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
if __name__ == "__main__":
|
| 157 |
+
demo.launch(share=False, debug=True, favicon_path='oldfatboy.png')
|
| 158 |
+
|
oldfatboy.png
ADDED
|
|
yc01.jpg
ADDED
|
|