Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
from space import Space
|
4 |
|
5 |
-
# Load the
|
6 |
-
|
7 |
|
8 |
# Create a Gradio interface for the translation app
|
9 |
def translate(text):
|
10 |
-
# Use the
|
11 |
-
result =
|
12 |
-
return result
|
13 |
|
14 |
input_text = gr.inputs.Textbox(label="Input English Text")
|
15 |
output_text = gr.outputs.Textbox(label="Output Urdu Text")
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
+
# Load the English to Urdu translation model from the transformers library
|
5 |
+
translator = pipeline("translation_en_to_ur")
|
6 |
|
7 |
# Create a Gradio interface for the translation app
|
8 |
def translate(text):
|
9 |
+
# Use the translator pipeline to translate the input text
|
10 |
+
result = translator(text, max_length=500)
|
11 |
+
return result[0]['translation_text']
|
12 |
|
13 |
input_text = gr.inputs.Textbox(label="Input English Text")
|
14 |
output_text = gr.outputs.Textbox(label="Output Urdu Text")
|