Spaces:
Runtime error
Runtime error
vijaydhanda
commited on
Commit
·
3a4b804
1
Parent(s):
7267105
Updated
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
model = pipeline("translation", model="AbhirupGhosh/opus-mt-finetuned-en-hi")
|
5 |
+
|
6 |
+
def translate(text):
|
7 |
+
translations = model(text)
|
8 |
+
output = translations[0]['translation_text']
|
9 |
+
return output
|
10 |
+
|
11 |
+
gr.Interface(
|
12 |
+
fn=translate,
|
13 |
+
inputs = gr.Textbox(label="EN"),
|
14 |
+
outputs = gr.Textbox(label="HI"),
|
15 |
+
title="Translate English to Hindi",
|
16 |
+
description="Translation using Helsinki-NLP Opus MT model.",
|
17 |
+
examples= [
|
18 |
+
"Traduire une langue est un problème très complexe et pourtant ce modèle de Helsinki-NLP y arrive à la fois plutôt bien et rapidement, tu en conviens?",
|
19 |
+
"J'aurais préféré qu'ils soient tous présent lors de la démonstration plutôt que d'avoir à me répéter pour chacun d'entre-eux.",
|
20 |
+
],
|
21 |
+
allow_flagging="never"
|
22 |
+
).launch(debug=True, enable_queue=True)
|