mbarnig's picture
Update app.py
d061559
raw
history blame
821 Bytes
import gradio as gr
import numpy as np
import paddlehub as hub
from googletrans import Translator
model = hub.Module(name="ernie_vilg")
translator = Translator()
myInput = gr.Textbox(label="Beschreiwung")
myOutputs = [
gr.Gallery(label="Konschtwierk"),
gr.Textbox(label="Resultat")
]
def create(prompt):
chinese_translation = translator.translate(prompt, src="lb", dest="fr")
print(chinese_translation)
try:
artwork = model.generate_image(
text_prompts=chinese_translation,
style = '油画',
visualization=False
)
except Exception as e:
error_text=str(e)
return None, error_text
return artwork, chinese_translation
demo = gr.Interface(
fn=create,
inputs=myInput,
outputs=myOutputs
)
demo.launch()