eng-to-fra-model / gradio_eng_to_fra.py
rajbhirud's picture
Create gradio_eng_to_fra.py
f2e64c6 verified
raw
history blame contribute delete
665 Bytes
# install gradio, transformers and sentencepiece before using this code
from transformers import pipeline
import gradio as gr
model_checkpoint = "rajbhirud/eng-to-fra-model"
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()