Spaces:
Running
Running
Commit
·
870f35d
1
Parent(s):
b561999
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
model_ids = {"models/runwayml/stable-diffusion-v1-5":"stable-diffusion-v1-5",
|
4 |
"models/stabilityai/stable-diffusion-2":"stable-diffusion-2",
|
5 |
"models/prompthero/openjourney":"openjourney",
|
@@ -17,6 +27,7 @@ for model_id in model_ids.keys():
|
|
17 |
|
18 |
def infer(prompt):
|
19 |
# gr.Interface.load("models/runwayml/stable-diffusion-v1-5",prompt=prompt).launch()
|
|
|
20 |
return prompt
|
21 |
|
22 |
start_work = """async() => {
|
@@ -150,7 +161,7 @@ with gr.Blocks(title='Text to Image') as demo:
|
|
150 |
with gr.Group(elem_id="page_2", visible=False) as page_2:
|
151 |
with gr.Row(elem_id="prompt_row"):
|
152 |
prompt_input0 = gr.Textbox(lines=4, label="prompt")
|
153 |
-
prompt_input1 = gr.Textbox(lines=4, label="prompt", visible=
|
154 |
with gr.Row():
|
155 |
submit_btn = gr.Button(value = "submit",elem_id="erase-btn").style(
|
156 |
margin=True,
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
import paddlehub as hub
|
4 |
+
|
5 |
+
language_translation_model = hub.Module(directory=f'./baidu_translate')
|
6 |
+
def getTextTrans(text, source='zh', target='en'):
|
7 |
+
try:
|
8 |
+
text_translation = language_translation_model.translate(text, source, target)
|
9 |
+
return text_translation
|
10 |
+
except Exception as e:
|
11 |
+
return text
|
12 |
+
|
13 |
model_ids = {"models/runwayml/stable-diffusion-v1-5":"stable-diffusion-v1-5",
|
14 |
"models/stabilityai/stable-diffusion-2":"stable-diffusion-2",
|
15 |
"models/prompthero/openjourney":"openjourney",
|
|
|
27 |
|
28 |
def infer(prompt):
|
29 |
# gr.Interface.load("models/runwayml/stable-diffusion-v1-5",prompt=prompt).launch()
|
30 |
+
prompt = getTextTrans(prompt, source='zh', target='en')
|
31 |
return prompt
|
32 |
|
33 |
start_work = """async() => {
|
|
|
161 |
with gr.Group(elem_id="page_2", visible=False) as page_2:
|
162 |
with gr.Row(elem_id="prompt_row"):
|
163 |
prompt_input0 = gr.Textbox(lines=4, label="prompt")
|
164 |
+
prompt_input1 = gr.Textbox(lines=4, label="prompt", visible=True)
|
165 |
with gr.Row():
|
166 |
submit_btn = gr.Button(value = "submit",elem_id="erase-btn").style(
|
167 |
margin=True,
|