MohitRajput45 commited on
Commit
c2588cd
·
verified ·
1 Parent(s): cb223c6

Update src/core_model/predict.py

Browse files
Files changed (1) hide show
  1. src/core_model/predict.py +10 -7
src/core_model/predict.py CHANGED
@@ -9,22 +9,25 @@ class MindGuardPredictor:
9
  # 1. Identify the Model Hub ID
10
  self.model_id = "MohitRajput45/mindguard-xlmr"
11
 
12
- # 2. Load the components
 
 
 
 
13
  try:
 
14
  self.tokenizer = XLMRobertaTokenizer.from_pretrained(
15
  self.model_id,
16
- subfolder="final_mindguard_model"
17
  )
18
  self.model = XLMRobertaForSequenceClassification.from_pretrained(
19
  self.model_id,
20
- subfolder="final_mindguard_model"
21
  )
22
- print("✅ Model and Tokenizer loaded successfully from Hub.")
23
  except Exception as e:
24
  print(f"❌ Error loading model: {e}")
25
- # Fallback attempt if subfolder isn't present
26
- self.tokenizer = XLMRobertaTokenizer.from_pretrained(self.model_id)
27
- self.model = XLMRobertaForSequenceClassification.from_pretrained(self.model_id)
28
 
29
  # 3. Emotion Mapping (Mathematical ID to English Word)
30
  self.emotion_map = {
 
9
  # 1. Identify the Model Hub ID
10
  self.model_id = "MohitRajput45/mindguard-xlmr"
11
 
12
+ # 2. Identify the EXACT path inside that Repo
13
+ # Based on your HF screenshot, this is the full path to the files
14
+ hf_subfolder = "artifacts/xlmr_weights/final_mindguard_model"
15
+
16
+ # 3. Load the components from the Hub
17
  try:
18
+ print(f"DEBUG: Attempting to load model from {self.model_id} in {hf_subfolder}...")
19
  self.tokenizer = XLMRobertaTokenizer.from_pretrained(
20
  self.model_id,
21
+ subfolder=hf_subfolder
22
  )
23
  self.model = XLMRobertaForSequenceClassification.from_pretrained(
24
  self.model_id,
25
+ subfolder=hf_subfolder
26
  )
27
+ print("✅ Model and Tokenizer loaded successfully from Hub!")
28
  except Exception as e:
29
  print(f"❌ Error loading model: {e}")
30
+ raise e # Stop the app if the model fails to load
 
 
31
 
32
  # 3. Emotion Mapping (Mathematical ID to English Word)
33
  self.emotion_map = {