danejsakshi13 commited on
Commit
5be89ee
·
1 Parent(s): 91f7357

Deploy translation backend

Browse files
Files changed (2) hide show
  1. app.py +15 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load English-to-Japanese translation pipeline
5
+ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ja")
6
+
7
+ # Define translation function
8
+ def translate(text):
9
+ if not text.strip():
10
+ return "Please enter some English text."
11
+ result = translator(text)[0]["translation_text"]
12
+ return result
13
+
14
+ # Create Gradio interface
15
+ gr.Interface(fn=translate, inputs="text", outputs="text").launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ gradio