Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files5 unmodified lines6789101118 unmodified lines30313233343536375 unmodified linesimport picklefrom huggingface_hub import hf_hub_downloadimport osfrom typing import List, Unionapp = FastAPI(title="Headache Predictor API")18 unmodified linescache_dir=cache_dir,token=hf_token # Use token for private repo access)with open(model_path, 'rb') as f:model = pickle.load(f)print("✅ Model loaded successfully")except Exception as e:print(f"❌ Error loading model: {e}")5 unmodified lines678910111218 unmodified lines313233343536373839404142434445464748495051525 unmodified linesimport picklefrom huggingface_hub import hf_hub_downloadimport osimport sysfrom typing import List, Unionapp = FastAPI(title="Headache Predictor API")18 unmodified linescache_dir=cache_dir,token=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}")
app.py+16-1