Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Initialize the translation pipeline | |
| pipe = pipeline("translation", model="google-t5/t5-base") | |
| # Define the translation function | |
| def translate(text): | |
| translation = pipe(text) | |
| return translation[0]['translation_text'] | |
| # Create the Gradio interface | |
| iface = gr.Interface( | |
| fn=translate, | |
| inputs="text", | |
| outputs="text", | |
| title="Text Translation with T5", | |
| description="Enter text to translate it using the Google T5 model.", | |
| ) | |
| # Launch the Gradio app | |
| if __name__ == "__main__": | |
| iface.launch() | |