Spaces:
Sleeping
Sleeping
File size: 864 Bytes
d2dd70a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import gradio as gr
# Load your Hugging Face model (replace with your model name)
model_name = "Helsinki-NLP/opus-mt-en-es"
model = gr.load(model_name, src="models")
# Define the input component (text box)
text_input = gr.inputs.Textbox(lines=5, label="Enter text in English")
# Define the output component (text box)
text_output = gr.outputs.Textbox(label="Translated text in Spanish")
# Create the Gradio interface
iface = gr.Interface(
fn=model,
inputs=text_input,
outputs=text_output,
title="Hugging Face Model Translator",
description="Translate English text to Spanish using Hugging Face models.",
theme="default", # You can customize the theme (e.g., "huggingface")
examples=[
["Hello, how are you?"],
["I love Gradio!"],
["This is a test sentence."],
],
)
# Launch the interface
iface.launch()
|