Upload 2 files
Browse files- app.py +14 -24
- requirements.txt +4 -2
app.py
CHANGED
|
@@ -1,29 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
| 3 |
|
| 4 |
-
# Cargar el
|
| 5 |
-
|
| 6 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("projecte-aina/aina-translator-es-ast")
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
gr.Markdown("# 🤖 Chatbot Traductor Español → Asturiano")
|
| 20 |
-
|
| 21 |
-
chatbot = gr.Chatbot()
|
| 22 |
-
msg = gr.Textbox(label="Escribe tu mensaje en Español...")
|
| 23 |
-
send_btn = gr.Button("Enviar")
|
| 24 |
-
|
| 25 |
-
# Configuración del botón de envío
|
| 26 |
-
send_btn.click(fn=chatbot_response, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 27 |
-
|
| 28 |
-
# Lanzar la aplicación
|
| 29 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Cargar el modelo
|
| 5 |
+
model = pipeline("translation", model="projecte-aina/aina-translator-es-ast")
|
|
|
|
| 6 |
|
| 7 |
+
# Función para traducir
|
| 8 |
+
def translate(text):
|
| 9 |
+
return model(text)[0]['translation_text']
|
| 10 |
|
| 11 |
+
# Crear la interfaz de Gradio
|
| 12 |
+
interface = gr.Interface(
|
| 13 |
+
fn=translate,
|
| 14 |
+
inputs=gr.Textbox(label="Texto en español"),
|
| 15 |
+
outputs=gr.Textbox(label="Traducción al asturiano")
|
| 16 |
+
)
|
| 17 |
|
| 18 |
+
# Lanzar la interfaz
|
| 19 |
+
interface.launch(debug=True, share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
-
huggingface_hub==0.25.2
|
| 2 |
transformers
|
| 3 |
-
torch
|
| 4 |
gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
transformers
|
|
|
|
| 2 |
gradio
|
| 3 |
+
torch
|
| 4 |
+
torchvision
|
| 5 |
+
torchaudio
|
| 6 |
+
sentencepiece
|