Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
import numpy as np
|
2 |
import gradio as gr
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def flip_text(x):
|
6 |
return x[::-1]
|
@@ -10,17 +15,29 @@ def flip_image(x):
|
|
10 |
return np.fliplr(x)
|
11 |
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
with gr.Blocks() as pan:
|
14 |
gr.Markdown("Flip text or image files using this demo.")
|
15 |
|
16 |
run = gr.Button("Generate Images")
|
17 |
|
18 |
with gr.Tab("Flip Text"):
|
19 |
-
|
20 |
##model = ("stabilityai/stable-diffusion-2-1")
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
with gr.Tab("Flip Image"):
|
26 |
with gr.Row():
|
@@ -39,5 +56,5 @@ with gr.Blocks() as pan:
|
|
39 |
|
40 |
# text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
41 |
# image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
42 |
-
|
43 |
-
pan.launch()
|
|
|
1 |
import numpy as np
|
2 |
import gradio as gr
|
3 |
|
4 |
+
models = [
|
5 |
+
{"name": "Stable Diffusion 2", "url": "stabilityai/stable-diffusion-2-1"},
|
6 |
+
]
|
7 |
+
|
8 |
+
current_model = models[0]
|
9 |
|
10 |
def flip_text(x):
|
11 |
return x[::-1]
|
|
|
15 |
return np.fliplr(x)
|
16 |
|
17 |
|
18 |
+
def set_model(current_model_index):
|
19 |
+
global current_model
|
20 |
+
current_model = models[current_model_index]
|
21 |
+
return gr.update(value=f"{current_model['name']}")
|
22 |
+
|
23 |
+
|
24 |
with gr.Blocks() as pan:
|
25 |
gr.Markdown("Flip text or image files using this demo.")
|
26 |
|
27 |
run = gr.Button("Generate Images")
|
28 |
|
29 |
with gr.Tab("Flip Text"):
|
30 |
+
|
31 |
##model = ("stabilityai/stable-diffusion-2-1")
|
32 |
+
model_name1 = gr.Dropdown(
|
33 |
+
label="Choose Model",
|
34 |
+
choices=[m["name"] for m in models],
|
35 |
+
type="index",
|
36 |
+
value=current_model["name"],
|
37 |
+
interactive=True,
|
38 |
+
)
|
39 |
+
input_text = gr.Textbox(label="Prompt idea",)
|
40 |
+
output1 = gr.Image(label="")
|
41 |
|
42 |
with gr.Tab("Flip Image"):
|
43 |
with gr.Row():
|
|
|
56 |
|
57 |
# text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
58 |
# image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
59 |
+
pan.queue(concurrency_count=200)
|
60 |
+
pan.launch(inline=True, show_api=True, max_threads=400)
|