Spaces:
Sleeping
Sleeping
Commit
·
3356a7c
1
Parent(s):
d38e058
fix gr.cache deprecation issue
Browse files
app.py
CHANGED
@@ -2,20 +2,23 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
import torch
|
4 |
|
5 |
-
#
|
6 |
-
|
|
|
7 |
def load_model():
|
8 |
"""Load the intent classification model"""
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
|
20 |
def classify_intent(comment):
|
21 |
"""
|
|
|
2 |
from transformers import pipeline
|
3 |
import torch
|
4 |
|
5 |
+
# Global variable to cache the model
|
6 |
+
_classifier = None
|
7 |
+
|
8 |
def load_model():
|
9 |
"""Load the intent classification model"""
|
10 |
+
global _classifier
|
11 |
+
if _classifier is None:
|
12 |
+
try:
|
13 |
+
_classifier = pipeline(
|
14 |
+
"text-classification",
|
15 |
+
model="YosefA/adfluence-intent-model",
|
16 |
+
return_all_scores=True
|
17 |
+
)
|
18 |
+
except Exception as e:
|
19 |
+
print(f"Error loading model: {e}")
|
20 |
+
return None
|
21 |
+
return _classifier
|
22 |
|
23 |
def classify_intent(comment):
|
24 |
"""
|