Spaces:
Sleeping
Sleeping
File size: 774 Bytes
54e8483 3b69718 54e8483 3b69718 54e8483 3b69718 2e4c29b 3b69718 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
from transformers import pipeline
# Initialize the translation pipeline with a pre-trained model
translator = pipeline("translation_en_to_fr", model="t5-small")
def translate(text):
# Translate the input text from English to French
result = translator(text, max_length=512)
return result[0]['translation_text']
# Define the Gradio interface
iface = gr.Interface(
fn=translate,
inputs=gr.Textbox(lines=2, placeholder="Enter English text here..."),
outputs=gr.Textbox(), # Updated for Gradio version 4.0
title="English to French Translation",
description="This app uses the T5 model to translate English text to French. Type some text and press submit."
)
# Launch the app
if __name__ == "__main__":
iface.launch()
|