SamanthaStorm commited on
Commit
ba85ad6
·
verified ·
1 Parent(s): d83fafe

Create models.py

Browse files
Files changed (1) hide show
  1. models.py +4 -4
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
- self.models[name] = MultiLabelIntentClassifier("distilbert-base-uncased", 6)
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
- self.models[name].load_state_dict(state_dict)
132
- self.models[name] = self.models[name].to(self.device)
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