2 / app.py
paranitik's picture
Update app.py
81c616f
raw
history blame contribute delete
786 Bytes
import gradio as gr
from transformers import GPT2LMHeadModel, GPT2Tokenizer
from transformers import pipeline
pipe = pipeline("text-generation", model="ai-forever/mGPT-1.3B-turkmen")
def translate(text):
return pipe(text)[0]["translation_text"]
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
english = gr.Textbox(label="English text")
translate_btn = gr.Button(value="Translate")
with gr.Column():
russian = gr.Textbox(label="Russian Text")
translate_btn.click(translate, inputs=english, outputs=russian, api_name="translate-to-russian")
examples = gr.Examples(examples=["I went to the supermarket yesterday.", "Helen is a good swimmer."],
inputs=[english])
demo.launch()