Spaces:
Runtime error
Runtime error
Create models.py
Browse files
models.py
CHANGED
@@ -116,8 +116,8 @@ class ModelManager:
|
|
116 |
try:
|
117 |
logger.info("Loading custom intent model with MultiLabelIntentClassifier")
|
118 |
|
119 |
-
# Create the custom model architecture
|
120 |
-
|
121 |
|
122 |
# Download the model file from HuggingFace
|
123 |
try:
|
@@ -128,8 +128,8 @@ class ModelManager:
|
|
128 |
|
129 |
# Load the state dict
|
130 |
state_dict = torch.load(model_path, map_location='cpu')
|
131 |
-
|
132 |
-
self.models[name] =
|
133 |
|
134 |
logger.info("Custom intent model loaded successfully from HuggingFace")
|
135 |
|
|
|
116 |
try:
|
117 |
logger.info("Loading custom intent model with MultiLabelIntentClassifier")
|
118 |
|
119 |
+
# Create the custom model architecture (referencing the global class)
|
120 |
+
intent_model = MultiLabelIntentClassifier("distilbert-base-uncased", 6)
|
121 |
|
122 |
# Download the model file from HuggingFace
|
123 |
try:
|
|
|
128 |
|
129 |
# Load the state dict
|
130 |
state_dict = torch.load(model_path, map_location='cpu')
|
131 |
+
intent_model.load_state_dict(state_dict)
|
132 |
+
self.models[name] = intent_model.to(self.device)
|
133 |
|
134 |
logger.info("Custom intent model loaded successfully from HuggingFace")
|
135 |
|