Spaces:
Sleeping
Sleeping
Commit ·
a8b6747
1
Parent(s): fed7c10
Fix: Support new model key names (tfidf vs tfidf_vectorizer)
Browse files380 unmodified lines381382383384385386387388389390391392393394395380 unmodified lineslogger.error("Failed to load model with all methods")return False# Extract componentsself.model = model_data['model']self.tfidf_vectorizer = model_data['tfidf_vectorizer']self.label_encoder = model_data.get('label_encoder')# Always use module-level clean_text to avoid pickle issuesself.text_cleaner = clean_textself.model_accuracy = model_data.get('accuracy', 0.0)self.model_f1_score = model_data.get('f1_score', 0.0)self.classes = model_data.get('classes', [])self.is_initialized = Truelogger.info("Sentiment analysis model initialized successfully")380 unmodified lines381382383384385386387388389390391392393394395396397398399380 unmodified lineslogger.error("Failed to load model with all methods")return False# Extract components (support both old and new model key names)self.model = model_data['model']# New model uses 'tfidf', old model uses 'tfidf_vectorizer'self.tfidf_vectorizer = model_data.get('tfidf') or model_data.get('tfidf_vectorizer')self.label_encoder = model_data.get('label_encoder')# Always use module-level clean_text to avoid pickle issuesself.text_cleaner = clean_textself.model_accuracy = model_data.get('accuracy', 0.0)self.model_f1_score = model_data.get('f1_score', 0.0)# Get classes from model or label_encoderself.classes = model_data.get('classes', [])if not self.classes and hasattr(self.model, 'classes_'):self.classes = list(self.model.classes_)self.is_initialized = Truelogger.info("Sentiment analysis model initialized successfully")
app.py+6-2