Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,17 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
import time
|
| 3 |
|
| 4 |
-
models =
|
|
|
|
|
|
|
| 5 |
"pimpilikipilapi1/NSFW_master",
|
| 6 |
"DiegoJR1973/NSFW-TrioHMH-Flux",
|
|
|
|
| 7 |
"prashanth970/flux-lora-uncensored",
|
|
|
|
| 8 |
]
|
| 9 |
|
| 10 |
model_functions = {}
|
|
@@ -16,7 +23,7 @@ for model_path in models:
|
|
| 16 |
def the_fn(txt):
|
| 17 |
return None
|
| 18 |
model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
|
| 19 |
-
model_idx
|
| 20 |
|
| 21 |
|
| 22 |
def send_it_idx(idx):
|
|
@@ -42,12 +49,14 @@ def all_task_end(cnt,t_stamp):
|
|
| 42 |
if et > to and t_stamp != 0:
|
| 43 |
d = gr.update(value=0)
|
| 44 |
tog = gr.update(value=1)
|
|
|
|
| 45 |
else:
|
| 46 |
if cnt != 0:
|
| 47 |
d = gr.update(value=et)
|
| 48 |
else:
|
| 49 |
d = gr.update(value=0)
|
| 50 |
tog = gr.update(value=0)
|
|
|
|
| 51 |
pass
|
| 52 |
return d, tog
|
| 53 |
|
|
@@ -62,36 +71,44 @@ def clear_fn():
|
|
| 62 |
nn = len(models)
|
| 63 |
return tuple([None, *[None for _ in range(nn)]])
|
| 64 |
|
|
|
|
|
|
|
| 65 |
with gr.Blocks(title="SD Models") as my_interface:
|
| 66 |
-
with gr.Column():
|
|
|
|
|
|
|
| 67 |
with gr.Row():
|
| 68 |
-
with gr.
|
| 69 |
-
primary_prompt
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
with gr.Row():
|
| 72 |
-
run
|
| 73 |
-
clear_btn
|
| 74 |
with gr.Row():
|
| 75 |
sd_outputs = {}
|
| 76 |
model_idx = 1
|
| 77 |
for model_path in models:
|
| 78 |
with gr.Column(scale=3, min_width=200):
|
| 79 |
-
with gr.
|
| 80 |
sd_outputs[model_idx] = gr.Image(label=model_path)
|
| 81 |
pass
|
| 82 |
model_idx += 1
|
| 83 |
pass
|
|
|
|
| 84 |
|
| 85 |
with gr.Row(visible=False):
|
| 86 |
-
start_box
|
| 87 |
-
end_box
|
| 88 |
-
tog_box
|
| 89 |
|
| 90 |
start_box.change(
|
| 91 |
all_task_end,
|
| 92 |
[start_box, end_box],
|
| 93 |
[start_box, tog_box],
|
| 94 |
-
|
|
|
|
| 95 |
|
| 96 |
primary_prompt.submit(all_task_start, None, [start_box, end_box, tog_box])
|
| 97 |
run.click(all_task_start, None, [start_box, end_box, tog_box])
|
|
@@ -100,7 +117,14 @@ with gr.Blocks(title="SD Models") as my_interface:
|
|
| 100 |
for model_path in models:
|
| 101 |
runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
|
| 102 |
model_idx += 1
|
|
|
|
|
|
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
clear_btn.click(
|
| 105 |
clear_fn,
|
| 106 |
None,
|
|
@@ -112,4 +136,5 @@ with gr.Blocks(title="SD Models") as my_interface:
|
|
| 112 |
tog_box,
|
| 113 |
cancels=[*list(runs_dict.values())])
|
| 114 |
|
| 115 |
-
my_interface.
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
# import os
|
| 3 |
+
# import sys
|
| 4 |
+
# from pathlib import Path
|
| 5 |
import time
|
| 6 |
|
| 7 |
+
models =[
|
| 8 |
+
"enhanceaiteam/Flux-uncensored",
|
| 9 |
+
"CultriX/flux-nsfw-highress",
|
| 10 |
"pimpilikipilapi1/NSFW_master",
|
| 11 |
"DiegoJR1973/NSFW-TrioHMH-Flux",
|
| 12 |
+
"lustlyai/Flux_Lustly.ai_Uncensored_nsfw_v1",
|
| 13 |
"prashanth970/flux-lora-uncensored",
|
| 14 |
+
"black-forest-labs/FLUX.1-dev",
|
| 15 |
]
|
| 16 |
|
| 17 |
model_functions = {}
|
|
|
|
| 23 |
def the_fn(txt):
|
| 24 |
return None
|
| 25 |
model_functions[model_idx] = gr.Interface(fn=the_fn, inputs=["text"], outputs=["image"])
|
| 26 |
+
model_idx+=1
|
| 27 |
|
| 28 |
|
| 29 |
def send_it_idx(idx):
|
|
|
|
| 49 |
if et > to and t_stamp != 0:
|
| 50 |
d = gr.update(value=0)
|
| 51 |
tog = gr.update(value=1)
|
| 52 |
+
#print(f'to: {to} et: {et}')
|
| 53 |
else:
|
| 54 |
if cnt != 0:
|
| 55 |
d = gr.update(value=et)
|
| 56 |
else:
|
| 57 |
d = gr.update(value=0)
|
| 58 |
tog = gr.update(value=0)
|
| 59 |
+
#print (f'passing: to: {to} et: {et}')
|
| 60 |
pass
|
| 61 |
return d, tog
|
| 62 |
|
|
|
|
| 71 |
nn = len(models)
|
| 72 |
return tuple([None, *[None for _ in range(nn)]])
|
| 73 |
|
| 74 |
+
|
| 75 |
+
|
| 76 |
with gr.Blocks(title="SD Models") as my_interface:
|
| 77 |
+
with gr.Column(scale=12):
|
| 78 |
+
# with gr.Row():
|
| 79 |
+
# gr.Markdown("""- Primary prompt: 你想画的内容(英文单词,如 a cat, 加英文逗号效果更好;点 Improve 按钮进行完善)\n- Real prompt: 完善后的提示词,出现后再点右边的 Run 按钮开始运行""")
|
| 80 |
with gr.Row():
|
| 81 |
+
with gr.Row(scale=6):
|
| 82 |
+
primary_prompt=gr.Textbox(label="Prompt", value="")
|
| 83 |
+
# real_prompt=gr.Textbox(label="Real prompt")
|
| 84 |
+
with gr.Row(scale=6):
|
| 85 |
+
# improve_prompts_btn=gr.Button("Improve")
|
| 86 |
with gr.Row():
|
| 87 |
+
run=gr.Button("Run",variant="primary")
|
| 88 |
+
clear_btn=gr.Button("Clear")
|
| 89 |
with gr.Row():
|
| 90 |
sd_outputs = {}
|
| 91 |
model_idx = 1
|
| 92 |
for model_path in models:
|
| 93 |
with gr.Column(scale=3, min_width=200):
|
| 94 |
+
with gr.Box():
|
| 95 |
sd_outputs[model_idx] = gr.Image(label=model_path)
|
| 96 |
pass
|
| 97 |
model_idx += 1
|
| 98 |
pass
|
| 99 |
+
pass
|
| 100 |
|
| 101 |
with gr.Row(visible=False):
|
| 102 |
+
start_box=gr.Number(interactive=False)
|
| 103 |
+
end_box=gr.Number(interactive=False)
|
| 104 |
+
tog_box=gr.Textbox(value=0,interactive=False)
|
| 105 |
|
| 106 |
start_box.change(
|
| 107 |
all_task_end,
|
| 108 |
[start_box, end_box],
|
| 109 |
[start_box, tog_box],
|
| 110 |
+
every=1,
|
| 111 |
+
show_progress=True)
|
| 112 |
|
| 113 |
primary_prompt.submit(all_task_start, None, [start_box, end_box, tog_box])
|
| 114 |
run.click(all_task_start, None, [start_box, end_box, tog_box])
|
|
|
|
| 117 |
for model_path in models:
|
| 118 |
runs_dict[model_idx] = run.click(model_functions[model_idx], inputs=[primary_prompt], outputs=[sd_outputs[model_idx]])
|
| 119 |
model_idx += 1
|
| 120 |
+
pass
|
| 121 |
+
pass
|
| 122 |
|
| 123 |
+
# improve_prompts_btn_clicked=improve_prompts_btn.click(
|
| 124 |
+
# get_prompts,
|
| 125 |
+
# inputs=[primary_prompt],
|
| 126 |
+
# outputs=[primary_prompt],
|
| 127 |
+
# cancels=list(runs_dict.values()))
|
| 128 |
clear_btn.click(
|
| 129 |
clear_fn,
|
| 130 |
None,
|
|
|
|
| 136 |
tog_box,
|
| 137 |
cancels=[*list(runs_dict.values())])
|
| 138 |
|
| 139 |
+
my_interface.queue(concurrency_count=100, status_update_rate=1)
|
| 140 |
+
my_interface.launch(inline=True, show_api=False)
|