islasher commited on
Commit
dcc31e0
1 Parent(s): d5d34a8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import from_pretrained_fastai
2
+ import gradio as gr
3
+ # from fastai.vision.all import *
4
+ # from transformers import AutoModelForSequenceClassification, AutoTokenizer
5
+ import torch
6
+ from transformers import pipeline
7
+ from transformers import Seq2SeqTrainer, AutoModelForSeq2SeqLM, Seq2SeqTrainingArguments, DataCollatorForSeq2Seq
8
+ from transformers import AutoTokenizer
9
+
10
+
11
+ # repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME"
12
+ repo_id = "islasher/mbart-spanishToQuechua"
13
+
14
+
15
+ # Definimos una función que se encarga de llevar a cabo las predicciones
16
+
17
+
18
+ # Cargar el modelo y el tokenizador
19
+ nombre_modelo = 'islasher/mbart-spanishToQuechua'
20
+ model = AutoModelForSeq2SeqLM.from_pretrained(nombre_modelo)
21
+ tokenizer = AutoTokenizer.from_pretrained(nombre_modelo)
22
+
23
+
24
+ def predict(frase):
25
+ #img = PILImage.create(img)
26
+ inputs = tokenizer(frase, return_tensors="pt")
27
+ outputs = model(**inputs)
28
+ trad = tokenizer.decode(outputs[0], skip_special_tokens=True)
29
+ return trad
30
+ # Creamos la interfaz y la lanzamos.
31
+ gr.Interface(fn=predict, inputs="text", outputs="text").launch(share=False)