Spaces:
Sleeping
Sleeping
File size: 684 Bytes
9a3d357 b3db685 9a3d357 b3db685 9a3d357 b3db685 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from transformers import pipeline
import gradio as gr
# Load the translation pipeline
translator = pipeline("translation_en_to_fr", model="t5-small")
def translate_text(text):
translation = translator(text)[0]["translation_text"]
return translation
# Create a Gradio interface
demo = gr.Interface(
fn=translate_text,
inputs=gr.Textbox(label="Enter English Text", placeholder="Type something..."),
outputs=gr.Textbox(label="French Translation"),
title="English to French Translator",
description="Translate English text to French using T5-small.",
examples=[["Machine learning is amazing."], ["Hello, how are you?"]]
)
# Launch the app
demo.launch() |