Spaces:
Sleeping
Sleeping
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() |