sanmt_v2 / app.py
balaramas's picture
Create app.py
5c21fac verified
raw
history blame
627 Bytes
import gradio as gr
import subprocess
subprocess.check_call(["pip", "install", "transformers"])
subprocess.check_call(["pip", "install", "torch"])
from transformers import pipeline
pipe = pipeline("text2text-generation", model="balaramas/mbart-sahitrans_new_data")
def sanmt(txt):
output=pipe(txt, max_length=20, min_length=5, do_sample=False)[0]['generated_text']
return output
iface = gr.Interface(
fn=sanmt,
inputs=gr.Textbox(label="Enter text in Sanskrit", placeholder="Type here..."),
outputs=gr.Textbox(label="Translated Hindi Text"),
title="Sanskrit to Hindi Translator"
)
iface.launch()