Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,50 +1,62 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
model1 = gr.load("models/pimpilikipilapi1/NSFW_master")
|
6 |
-
model2 = gr.load("models/prashanth970/flux-lora-uncensored")
|
7 |
-
model3 = gr.load("models/DiegoJR1973/NSFW-TrioHMH-Flux")
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
return
|
22 |
-
|
23 |
-
def
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
gr.
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import time
|
3 |
+
|
4 |
+
|
5 |
+
model1 = gr.Interface.load("models/pimpilikipilapi1/NSFW_master", live=False, preprocess=True, postprocess=False)
|
6 |
+
model2 = gr.Interface.load("models/prashanth970/flux-lora-uncensored", live=False, preprocess=True, postprocess=False)
|
7 |
+
model3 = gr.Interface.load("models/DiegoJR1973/NSFW-TrioHMH-Flux", live=False, preprocess=True, postprocess=False)
|
8 |
+
|
9 |
+
models = {
|
10 |
+
1: model1,
|
11 |
+
2: model2,
|
12 |
+
3: model3
|
13 |
+
}
|
14 |
+
|
15 |
+
def send_it_idx(idx):
|
16 |
+
def send_it_fn(prompt):
|
17 |
+
model = models.get(idx)
|
18 |
+
if model:
|
19 |
+
return model(prompt)
|
20 |
+
return None
|
21 |
+
return send_it_fn
|
22 |
+
|
23 |
+
def clear_fn():
|
24 |
+
return None, None, None
|
25 |
+
|
26 |
+
with gr.Blocks(title="SD Models") as my_interface:
|
27 |
+
with gr.Column(scale=12):
|
28 |
+
with gr.Row():
|
29 |
+
primary_prompt = gr.Textbox(label="Prompt", value="")
|
30 |
+
with gr.Row(scale=6):
|
31 |
+
run = gr.Button("Run", variant="primary")
|
32 |
+
clear_btn = gr.Button("Clear")
|
33 |
+
|
34 |
+
sd_outputs = {}
|
35 |
+
for idx, model in models.items():
|
36 |
+
with gr.Column(scale=3, min_width=200):
|
37 |
+
with gr.Box():
|
38 |
+
sd_outputs[idx] = gr.Image(label=f"Model {idx}")
|
39 |
+
|
40 |
+
with gr.Row(visible=False):
|
41 |
+
start_box = gr.Number(interactive=False)
|
42 |
+
end_box = gr.Number(interactive=False)
|
43 |
+
tog_box = gr.Textbox(value=0, interactive=False)
|
44 |
+
|
45 |
+
def all_task_start():
|
46 |
+
t_stamp = time.time()
|
47 |
+
return gr.update(value=t_stamp), gr.update(value=t_stamp), gr.update(value=0)
|
48 |
+
|
49 |
+
primary_prompt.submit(all_task_start, None, [start_box, end_box, tog_box])
|
50 |
+
run.click(all_task_start, None, [start_box, end_box, tog_box])
|
51 |
+
|
52 |
+
for idx, model in models.items():
|
53 |
+
run.click(model, inputs=[primary_prompt], outputs=[sd_outputs[idx]])
|
54 |
+
|
55 |
+
clear_btn.click(
|
56 |
+
clear_fn,
|
57 |
+
None,
|
58 |
+
[primary_prompt, *list(sd_outputs.values())]
|
59 |
+
)
|
60 |
+
|
61 |
+
my_interface.queue(concurrency_count=100, status_update_rate=1)
|
62 |
+
my_interface.launch(inline=True, show_api=False)
|