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