Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files31 unmodified lines3233343536373839404142434445464748495051525331 unmodified linestoken=hf_token # Use token for private repo access)# Load with custom unpickler to handle missing modulesclass CustomUnpickler(pickle.Unpickler):def find_class(self, module, name):# Redirect src.* imports to current directoryif module.startswith('src.'):module = module.replace('src.', '')try:return super().find_class(module, name)except (ModuleNotFoundError, AttributeError):# If module not found, try without the prefixreturn super().find_class(name, name)with open(model_path, 'rb') as f:model = CustomUnpickler(f).load()print("✅ Model loaded successfully")except Exception as e:print(f"❌ Error loading model: {e}")import traceback31 unmodified lines323334353637383940414243444546474831 unmodified linestoken=hf_token # Use token for private repo access)with open(model_path, 'rb') as f:model_data = pickle.load(f)# Handle both dict format and raw modelif isinstance(model_data, dict):model = model_data['model']print(f"✅ Model loaded successfully (threshold: {model_data.get('optimal_threshold', 0.5)})")else:model = model_dataprint("✅ Model loaded successfully")except Exception as e:print(f"❌ Error loading model: {e}")import traceback
app.py+9-14