Sunder34 commited on
Commit
b337833
·
verified ·
1 Parent(s): 480990b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the translation pipeline
5
+ pipe = pipeline("translation", model="google-t5/t5-base")
6
+
7
+ # Define the translation function
8
+ def translate(text):
9
+ translation = pipe(text)
10
+ return translation[0]['translation_text']
11
+
12
+ # Create the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=translate,
15
+ inputs="text",
16
+ outputs="text",
17
+ title="Text Translation with T5",
18
+ description="Enter text to translate it using the Google T5 model.",
19
+ )
20
+
21
+ # Launch the Gradio app
22
+ if __name__ == "__main__":
23
+ iface.launch()