Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files5 unmodified lines678910111218 unmodified lines31323334353637383940414243444546473448495051525 unmodified linesimport picklefrom huggingface_hub import hf_hub_downloadimport osimport sysfrom typing import List, Union
app = FastAPI(title="Headache Predictor API")18 unmodified lines cache_dir=cache_dir, token=hf_token # Use token for private repo access )
# Load with custom unpickler to handle missing modules class CustomUnpickler(pickle.Unpickler): def find_class(self, module, name): # Redirect src.* imports to current directory if module.startswith('src.'): module = module.replace('src.', '') try: return super().find_class(module, name) except (ModuleNotFoundError, AttributeError): # If module not found, try without the prefix return super().find_class(name, name)
with open(model_path, 'rb') as f: model = pickle.load(f) model = CustomUnpickler(f).load()
print("✅ Model loaded successfully") except Exception as e: print(f"❌ Error loading model: {e}")app.py+16-1