Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,6 @@ from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassifica
|
|
3 |
|
4 |
# Model details
|
5 |
MODEL_NAME = "Pisethan/sangapac-math"
|
6 |
-
reverse_label_mapping = {
|
7 |
-
0: "arithmetic",
|
8 |
-
1: "multiplication",
|
9 |
-
2: "division",
|
10 |
-
3: "algebra",
|
11 |
-
4: "geometry",
|
12 |
-
}
|
13 |
|
14 |
# Load model and tokenizer
|
15 |
try:
|
@@ -27,12 +20,12 @@ def predict(input_text):
|
|
27 |
try:
|
28 |
# Predict the category
|
29 |
result = classifier(input_text)
|
30 |
-
|
31 |
-
|
32 |
|
33 |
return {
|
34 |
-
"Category":
|
35 |
-
"Confidence":
|
36 |
}
|
37 |
except Exception as e:
|
38 |
return {"Error": str(e)}
|
|
|
3 |
|
4 |
# Model details
|
5 |
MODEL_NAME = "Pisethan/sangapac-math"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Load model and tokenizer
|
8 |
try:
|
|
|
20 |
try:
|
21 |
# Predict the category
|
22 |
result = classifier(input_text)
|
23 |
+
label = result[0]["label"] # Directly use the label provided by the model
|
24 |
+
score = result[0]["score"]
|
25 |
|
26 |
return {
|
27 |
+
"Category": label, # No need to remap since the label is already readable
|
28 |
+
"Confidence": score,
|
29 |
}
|
30 |
except Exception as e:
|
31 |
return {"Error": str(e)}
|