Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,12 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Cargar el modelo
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Funci贸n de chatbot que traduce autom谩ticamente
|
| 8 |
def chatbot_response(message, chat_history):
|
|
@@ -18,7 +22,7 @@ with gr.Blocks() as demo:
|
|
| 18 |
msg = gr.Textbox(label="Escribe tu mensaje en Espa帽ol...")
|
| 19 |
send_btn = gr.Button("Enviar")
|
| 20 |
|
| 21 |
-
#
|
| 22 |
send_btn.click(fn=chatbot_response, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 23 |
|
| 24 |
# Lanzar la aplicaci贸n
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
| 3 |
|
| 4 |
+
# Cargar el tokenizador y el modelo correctamente
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("projecte-aina/aina-translator-es-ast")
|
| 6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("projecte-aina/aina-translator-es-ast")
|
| 7 |
+
|
| 8 |
+
# Crear el pipeline de traducci贸n
|
| 9 |
+
translator = pipeline("translation", model=model, tokenizer=tokenizer)
|
| 10 |
|
| 11 |
# Funci贸n de chatbot que traduce autom谩ticamente
|
| 12 |
def chatbot_response(message, chat_history):
|
|
|
|
| 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
|