app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
|
4 |
-
models =[
|
5 |
"enhanceaiteam/Flux-uncensored",
|
6 |
"adirik/flux-cinestill",
|
7 |
"kudzueye/boreal-flux-dev-v2",
|
@@ -16,13 +16,12 @@ model_functions = {}
|
|
16 |
model_idx = 1
|
17 |
for model_path in models:
|
18 |
try:
|
19 |
-
model_functions[model_idx] = gr.
|
20 |
except Exception as error:
|
21 |
def the_fn(txt):
|
22 |
return None
|
23 |
model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
|
24 |
-
model_idx+=1
|
25 |
-
|
26 |
|
27 |
def send_it_idx(idx):
|
28 |
def send_it_fn(prompt):
|
@@ -38,10 +37,9 @@ def clear_it(val):
|
|
38 |
val = 0
|
39 |
else:
|
40 |
val = 0
|
41 |
-
pass
|
42 |
return val
|
43 |
|
44 |
-
def all_task_end(cnt,t_stamp):
|
45 |
to = t_stamp + 360
|
46 |
et = time.time()
|
47 |
if et > to and t_stamp != 0:
|
@@ -53,11 +51,9 @@ def all_task_end(cnt,t_stamp):
|
|
53 |
else:
|
54 |
d = gr.update(value=0)
|
55 |
tog = gr.update(value=0)
|
56 |
-
pass
|
57 |
return d, tog
|
58 |
|
59 |
def all_task_start():
|
60 |
-
print("\n\n\n\n\n\n\n")
|
61 |
t = time.gmtime()
|
62 |
t_stamp = time.time()
|
63 |
current_time = time.strftime("%H:%M:%S", t)
|
@@ -67,17 +63,14 @@ def clear_fn():
|
|
67 |
nn = len(models)
|
68 |
return tuple([None, *[None for _ in range(nn)]])
|
69 |
|
70 |
-
|
71 |
-
|
72 |
with gr.Blocks(title="SD Models") as my_interface:
|
73 |
with gr.Column(scale=12):
|
74 |
with gr.Row():
|
75 |
-
with gr.Row(
|
76 |
-
primary_prompt=gr.Textbox(label="Prompt", value="")
|
77 |
-
with gr.Row(
|
78 |
-
|
79 |
-
|
80 |
-
clear_btn=gr.Button("Clear")
|
81 |
with gr.Row():
|
82 |
sd_outputs = {}
|
83 |
model_idx = 1
|
@@ -85,22 +78,19 @@ with gr.Blocks(title="SD Models") as my_interface:
|
|
85 |
with gr.Column(scale=3, min_width=200):
|
86 |
with gr.Box():
|
87 |
sd_outputs[model_idx] = gr.Image(label=model_path)
|
88 |
-
pass
|
89 |
model_idx += 1
|
90 |
-
pass
|
91 |
-
pass
|
92 |
-
|
93 |
with gr.Row(visible=False):
|
94 |
-
start_box=gr.Number(interactive=False)
|
95 |
-
end_box=gr.Number(interactive=False)
|
96 |
-
tog_box=gr.Textbox(value=0,interactive=False)
|
97 |
|
98 |
start_box.change(
|
99 |
all_task_end,
|
100 |
[start_box, end_box],
|
101 |
[start_box, tog_box],
|
102 |
every=1,
|
103 |
-
show_progress=True
|
|
|
104 |
|
105 |
primary_prompt.submit(all_task_start, None, [start_box, end_box, tog_box])
|
106 |
run.click(all_task_start, None, [start_box, end_box, tog_box])
|
@@ -109,20 +99,19 @@ with gr.Blocks(title="SD Models") as my_interface:
|
|
109 |
for model_path in models:
|
110 |
runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
|
111 |
model_idx += 1
|
112 |
-
pass
|
113 |
-
pass
|
114 |
|
115 |
clear_btn.click(
|
116 |
clear_fn,
|
117 |
None,
|
118 |
[primary_prompt, *list(sd_outputs.values())],
|
119 |
-
cancels=[*list(runs_dict.values())]
|
|
|
120 |
tog_box.change(
|
121 |
clear_it,
|
122 |
tog_box,
|
123 |
tog_box,
|
124 |
-
cancels=[*list(runs_dict.values())]
|
|
|
125 |
|
126 |
my_interface.queue(concurrency_count=100, status_update_rate=1)
|
127 |
-
my_interface.launch(inline=True, show_api=False)
|
128 |
-
|
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
|
4 |
+
models = [
|
5 |
"enhanceaiteam/Flux-uncensored",
|
6 |
"adirik/flux-cinestill",
|
7 |
"kudzueye/boreal-flux-dev-v2",
|
|
|
16 |
model_idx = 1
|
17 |
for model_path in models:
|
18 |
try:
|
19 |
+
model_functions[model_idx] = gr.load(f"models/{model_path}", live=False)
|
20 |
except Exception as error:
|
21 |
def the_fn(txt):
|
22 |
return None
|
23 |
model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
|
24 |
+
model_idx += 1
|
|
|
25 |
|
26 |
def send_it_idx(idx):
|
27 |
def send_it_fn(prompt):
|
|
|
37 |
val = 0
|
38 |
else:
|
39 |
val = 0
|
|
|
40 |
return val
|
41 |
|
42 |
+
def all_task_end(cnt, t_stamp):
|
43 |
to = t_stamp + 360
|
44 |
et = time.time()
|
45 |
if et > to and t_stamp != 0:
|
|
|
51 |
else:
|
52 |
d = gr.update(value=0)
|
53 |
tog = gr.update(value=0)
|
|
|
54 |
return d, tog
|
55 |
|
56 |
def all_task_start():
|
|
|
57 |
t = time.gmtime()
|
58 |
t_stamp = time.time()
|
59 |
current_time = time.strftime("%H:%M:%S", t)
|
|
|
63 |
nn = len(models)
|
64 |
return tuple([None, *[None for _ in range(nn)]])
|
65 |
|
|
|
|
|
66 |
with gr.Blocks(title="SD Models") as my_interface:
|
67 |
with gr.Column(scale=12):
|
68 |
with gr.Row():
|
69 |
+
with gr.Row():
|
70 |
+
primary_prompt = gr.Textbox(label="Prompt", value="")
|
71 |
+
with gr.Row():
|
72 |
+
run = gr.Button("Run", variant="primary")
|
73 |
+
clear_btn = gr.Button("Clear")
|
|
|
74 |
with gr.Row():
|
75 |
sd_outputs = {}
|
76 |
model_idx = 1
|
|
|
78 |
with gr.Column(scale=3, min_width=200):
|
79 |
with gr.Box():
|
80 |
sd_outputs[model_idx] = gr.Image(label=model_path)
|
|
|
81 |
model_idx += 1
|
|
|
|
|
|
|
82 |
with gr.Row(visible=False):
|
83 |
+
start_box = gr.Number(interactive=False)
|
84 |
+
end_box = gr.Number(interactive=False)
|
85 |
+
tog_box = gr.Textbox(value=0, interactive=False)
|
86 |
|
87 |
start_box.change(
|
88 |
all_task_end,
|
89 |
[start_box, end_box],
|
90 |
[start_box, tog_box],
|
91 |
every=1,
|
92 |
+
show_progress=True
|
93 |
+
)
|
94 |
|
95 |
primary_prompt.submit(all_task_start, None, [start_box, end_box, tog_box])
|
96 |
run.click(all_task_start, None, [start_box, end_box, tog_box])
|
|
|
99 |
for model_path in models:
|
100 |
runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
|
101 |
model_idx += 1
|
|
|
|
|
102 |
|
103 |
clear_btn.click(
|
104 |
clear_fn,
|
105 |
None,
|
106 |
[primary_prompt, *list(sd_outputs.values())],
|
107 |
+
cancels=[*list(runs_dict.values())]
|
108 |
+
)
|
109 |
tog_box.change(
|
110 |
clear_it,
|
111 |
tog_box,
|
112 |
tog_box,
|
113 |
+
cancels=[*list(runs_dict.values())]
|
114 |
+
)
|
115 |
|
116 |
my_interface.queue(concurrency_count=100, status_update_rate=1)
|
117 |
+
my_interface.launch(inline=True, show_api=False)
|
|