Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
model = gr.Interface.load(f"models/prompthero/openjourney")
|
| 5 |
+
o = os.getenv("P")
|
| 6 |
+
|
| 7 |
+
def ac():
|
| 8 |
+
def im_fn(put,fac="",h=None):
|
| 9 |
+
if h == o:
|
| 10 |
+
put = f"{put}{fac}"
|
| 11 |
+
fac = f"{fac} "
|
| 12 |
+
return model(put),fac
|
| 13 |
+
elif h != o:
|
| 14 |
+
return(None,None)
|
| 15 |
+
def cl_fac():
|
| 16 |
+
return ""
|
| 17 |
+
with gr.Blocks() as b:
|
| 18 |
+
with gr.Row():
|
| 19 |
+
put = gr.Textbox()
|
| 20 |
+
btn1 = gr.Button()
|
| 21 |
+
with gr.Row():
|
| 22 |
+
out1 = gr.Image()
|
| 23 |
+
out2 = gr.Image()
|
| 24 |
+
with gr.Row():
|
| 25 |
+
out3 = gr.Image()
|
| 26 |
+
out4 = gr.Image()
|
| 27 |
+
with gr.Row(visible=False):
|
| 28 |
+
h=gr.Textbox(value="Q")
|
| 29 |
+
fac_b = gr.Textbox(value="",visible=False)
|
| 30 |
+
btn1.click(cl_fac,None,fac_b)
|
| 31 |
+
btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
|
| 32 |
+
out1.change(im_fn,[put,fac_b,h],[out2,fac_b])
|
| 33 |
+
out2.change(im_fn,[put,fac_b,h],[out3,fac_b])
|
| 34 |
+
out3.change(im_fn,[put,fac_b,h],[out4,fac_b])
|
| 35 |
+
b.queue(concurrency_count=100).launch(show_api=False)
|
| 36 |
+
ac()
|