German-Flan-T5 / app.py
AFischer1985's picture
Update app.py
d7c2c45
raw
history blame
634 Bytes
import gradio as gr
from transformers import pipeline
title= "German Flan-T5"
examples = [
["Erzähl mit eine Geschichte!"]
]
tDeEn = pipeline(model="Helsinki-NLP/opus-mt-de-en")
tEnDe = pipeline(model="Helsinki-NLP/opus-mt-en-de")
bot = pipeline(model="google/flan-t5-large")
def solve(text):
eng=tDeEn(text)[0]["translation_text"]
out=bot(eng,max_length=50)[0]["generated_text"]
out=tEnDe(out)[0]["translation_text"]
return out
task = gr.Interface(
fn=solve,
inputs=gr.Textbox(lines=5,max_lines=6,label="Auftrag:"),
outputs="text",
title=title,
examples=examples
)
if __name__ == "__main__":
task.launch()