translation / app.py
Sunder34's picture
Create app.py
b337833 verified
raw
history blame contribute delete
576 Bytes
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()