fkalpana commited on
Commit
3b69718
1 Parent(s): 54e8483

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -1,7 +1,23 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Initialize the translation pipeline with a pre-trained model
5
+ translator = pipeline("translation_en_to_fr", model="t5-small")
6
 
7
+ def translate(text):
8
+ # Translate the input text from English to French
9
+ result = translator(text, max_length=512)
10
+ return result[0]['translation_text']
11
+
12
+ # Define the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=translate,
15
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter English text here..."),
16
+ outputs="text",
17
+ title="English to French Translation",
18
+ description="This app uses the T5 model to translate English text to French. Type some text and press submit."
19
+ )
20
+
21
+ # Launch the app
22
+ if __name__ == "__main__":
23
+ iface.launch()