rajbhirud commited on
Commit
f2e64c6
1 Parent(s): d21eeb9

Create gradio_eng_to_fra.py

Browse files
Files changed (1) hide show
  1. gradio_eng_to_fra.py +21 -0
gradio_eng_to_fra.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # install gradio, transformers and sentencepiece before using this code
2
+ from transformers import pipeline
3
+ import gradio as gr
4
+
5
+ model_checkpoint = "rajbhirud/eng-to-fra-model"
6
+ translator = pipeline("translation", model=model_checkpoint)
7
+
8
+ def translation(text):
9
+ return translator(text)[0]['translation_text']
10
+
11
+ # Create a Gradio interface
12
+ iface = gr.Interface(
13
+ fn=translation,
14
+ inputs=gr.inputs.Textbox(label="Input English Text"),
15
+ outputs=gr.outputs.Textbox(label="Translated French Text"),
16
+ title="English to French Translation",
17
+ description="Translate English text to French using a fine-tuned model.",
18
+ )
19
+
20
+ # Launch the interface
21
+ iface.launch()