File size: 666 Bytes
9851a31
d1d5bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#please install gradio, transformers and sentencepiece before using this code
from transformers import pipeline
import gradio as gr

model_checkpoint = "suyash2102/model-en-to-fr"
translator = pipeline("translation", model=model_checkpoint)
def translation(text):
  return translator(text)[0]['translation_text']
# Create a Gradio interface
iface = gr.Interface(
    fn=translation,
    inputs=gr.inputs.Textbox(label="Input English Text"),
    outputs=gr.outputs.Textbox(label="Translated French Text"),
    title="English to French Translation",
    description="Translate English text to French using a fine-tuned model.",
)

# Launch the interface
iface.launch()