TeresaSchaman commited on
Commit
4601f2f
路
verified 路
1 Parent(s): 34910e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -1,14 +1,21 @@
1
  import gradio as gr
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
 
3
 
4
- # Carga el modelo y el tokenizer
 
 
 
5
  model = AutoModelForSequenceClassification.from_pretrained("Schaman/DistilBERT_for_Logistic_Issues_Classification")
6
- tokenizer = AutoTokenizer.from_pretrained("Schaman/DistilBERT_for_Logistic_Issues_Classification")
 
7
 
8
  def predict(text):
9
  inputs = tokenizer(text, return_tensors="pt")
10
  outputs = model(**inputs)
11
- return outputs.logits.argmax().item()
 
 
12
 
13
  # Crea la interfaz de Gradio
14
  iface = gr.Interface(fn=predict, inputs="text", outputs="label")
 
1
  import gradio as gr
2
  from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
+ from transformers import DistilBertTokenizerFast, AutoModelForSequenceClassification
4
 
5
+ # Cargando el tokenizador est谩ndar
6
+ tokenizer = DistilBertTokenizerFast.from_pretrained('distilbert-base-uncased')
7
+
8
+ # Carga el modelo
9
  model = AutoModelForSequenceClassification.from_pretrained("Schaman/DistilBERT_for_Logistic_Issues_Classification")
10
+
11
+ label_dict = {0: 'Problemas con la facturaci贸n', 1: 'Da帽o en el paquete', 2: 'Entrega tard铆a', 3: 'Problemas con la entrega', 4: 'Problemas con el servicio al cliente', 5: 'Problemas con la recogida', 6: 'Problemas de seguimiento'}
12
 
13
  def predict(text):
14
  inputs = tokenizer(text, return_tensors="pt")
15
  outputs = model(**inputs)
16
+ prediction_index = outputs.logits.argmax().item()
17
+ return label_dict[prediction_index] # Devuelve la etiqueta correspondiente al 铆ndice
18
+
19
 
20
  # Crea la interfaz de Gradio
21
  iface = gr.Interface(fn=predict, inputs="text", outputs="label")