tonicanada
commited on
Commit
•
655c1f0
1
Parent(s):
8c66ef7
Uploading our food not food classifier demo from a notebook!
Browse files
app.py
CHANGED
@@ -12,6 +12,13 @@ spanish_sentence_classification_by_school_subject_pipeline = pipeline(task="text
|
|
12 |
device="cuda" if torch.cuda.is_available() else "cpu",
|
13 |
batch_size=32)
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# 3. Create a Gradio interface
|
16 |
description = """
|
17 |
Un clasificador de texto que indica a qué asignatura se refiere la frase.
|
@@ -20,7 +27,7 @@ Fine-tuned from [DistilBERT](https://huggingface.co/distilbert/distilbert/distil
|
|
20 |
"""
|
21 |
|
22 |
demo = gr.Interface(
|
23 |
-
fn =
|
24 |
inputs = "text",
|
25 |
outputs=gr.Label(num_top_classes=10),
|
26 |
title="📚🔍 Clasificador de asignaturas",
|
|
|
12 |
device="cuda" if torch.cuda.is_available() else "cpu",
|
13 |
batch_size=32)
|
14 |
|
15 |
+
def classify_text(text):
|
16 |
+
# Usa el clasificador
|
17 |
+
result = spanish_sentence_classification_by_school_subject_pipeline(text)
|
18 |
+
# Ahora accedemos al primer diccionario en la primera lista
|
19 |
+
return result[0][0]['label'], result[0][0]['score']
|
20 |
+
|
21 |
+
|
22 |
# 3. Create a Gradio interface
|
23 |
description = """
|
24 |
Un clasificador de texto que indica a qué asignatura se refiere la frase.
|
|
|
27 |
"""
|
28 |
|
29 |
demo = gr.Interface(
|
30 |
+
fn = classify_text,
|
31 |
inputs = "text",
|
32 |
outputs=gr.Label(num_top_classes=10),
|
33 |
title="📚🔍 Clasificador de asignaturas",
|