suyash2102
commited on
Commit
·
14ccd19
1
Parent(s):
ad7fefb
Upload gradio_LT.py
Browse files- gradio_LT.py +18 -0
gradio_LT.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_checkpoint = "suyash2102/model-en-to-fr"
|
5 |
+
translator = pipeline("translation", model=model_checkpoint)
|
6 |
+
def translation(text):
|
7 |
+
return translator(text)[0]['translation_text']
|
8 |
+
# Create a Gradio interface
|
9 |
+
iface = gr.Interface(
|
10 |
+
fn=translation,
|
11 |
+
inputs=gr.inputs.Textbox(label="Input English Text"),
|
12 |
+
outputs=gr.outputs.Textbox(label="Translated French Text"),
|
13 |
+
title="English to French Translation",
|
14 |
+
description="Translate English text to French using a fine-tuned model.",
|
15 |
+
)
|
16 |
+
|
17 |
+
# Launch the interface
|
18 |
+
iface.launch()
|