Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,12 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Load the translation model
|
| 5 |
translator = pipeline("translation_en_to_fr", model="Helsinki-NLP/opus-mt-en-fr")
|
| 6 |
|
| 7 |
-
# Translation function
|
| 8 |
def translate_text(text):
|
| 9 |
translated_text = translator(text)[0]["translation_text"]
|
| 10 |
return translated_text
|
| 11 |
|
| 12 |
-
# Gradio Interface
|
| 13 |
iface = gr.Interface(
|
| 14 |
fn=translate_text,
|
| 15 |
inputs=gr.Textbox(label="Enter English Text"),
|
|
@@ -17,6 +14,4 @@ iface = gr.Interface(
|
|
| 17 |
title="English to French Translator",
|
| 18 |
description="Enter text in English and get the French translation using an Open-Source Hugging Face model.",
|
| 19 |
)
|
| 20 |
-
|
| 21 |
-
# Launch the app
|
| 22 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
translator = pipeline("translation_en_to_fr", model="Helsinki-NLP/opus-mt-en-fr")
|
| 5 |
|
|
|
|
| 6 |
def translate_text(text):
|
| 7 |
translated_text = translator(text)[0]["translation_text"]
|
| 8 |
return translated_text
|
| 9 |
|
|
|
|
| 10 |
iface = gr.Interface(
|
| 11 |
fn=translate_text,
|
| 12 |
inputs=gr.Textbox(label="Enter English Text"),
|
|
|
|
| 14 |
title="English to French Translator",
|
| 15 |
description="Enter text in English and get the French translation using an Open-Source Hugging Face model.",
|
| 16 |
)
|
|
|
|
|
|
|
| 17 |
iface.launch()
|