Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import paddlehub as hub
|
|
|
4 |
|
5 |
model = hub.Module(name="ernie_vilg")
|
|
|
6 |
|
7 |
myInput = gr.Textbox(label="Beschreiwung", value='ζ΄ηηΌιηη«')
|
|
|
8 |
myOutputs = [
|
9 |
gr.Gallery(label="Konschtwierk"),
|
10 |
gr.Textbox(label="Resultat")
|
11 |
]
|
12 |
|
13 |
def create(prompt):
|
|
|
14 |
try:
|
15 |
artwork = model.generate_image(
|
16 |
text_prompts=prompt,
|
@@ -20,7 +24,7 @@ def create(prompt):
|
|
20 |
except Exception as e:
|
21 |
error_text=str(e)
|
22 |
return None, error_text
|
23 |
-
return artwork,
|
24 |
|
25 |
demo = gr.Interface(
|
26 |
fn=create,
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import paddlehub as hub
|
4 |
+
from googletrans import Translator
|
5 |
|
6 |
model = hub.Module(name="ernie_vilg")
|
7 |
+
translator = Translator()
|
8 |
|
9 |
myInput = gr.Textbox(label="Beschreiwung", value='ζ΄ηηΌιηη«')
|
10 |
+
|
11 |
myOutputs = [
|
12 |
gr.Gallery(label="Konschtwierk"),
|
13 |
gr.Textbox(label="Resultat")
|
14 |
]
|
15 |
|
16 |
def create(prompt):
|
17 |
+
chinese_translation = translator.translate(prompt, src="lb", dest="cn")
|
18 |
try:
|
19 |
artwork = model.generate_image(
|
20 |
text_prompts=prompt,
|
|
|
24 |
except Exception as e:
|
25 |
error_text=str(e)
|
26 |
return None, error_text
|
27 |
+
return artwork, chinese_translation
|
28 |
|
29 |
demo = gr.Interface(
|
30 |
fn=create,
|