Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
main.py
CHANGED
|
@@ -96,12 +96,14 @@ pipeline = None
|
|
| 96 |
# Mount static files
|
| 97 |
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
| 98 |
|
|
|
|
|
|
|
| 99 |
# Startup event - Initialize the model
|
| 100 |
@app.on_event("startup")
|
| 101 |
async def startup_event():
|
| 102 |
-
"""Initialize the WBC classification pipeline on server startup"""
|
| 103 |
global pipeline
|
| 104 |
-
|
|
|
|
| 105 |
logger.info("π Starting WBC Classification API...")
|
| 106 |
logger.info(f"π Current working directory: {os.getcwd()}")
|
| 107 |
logger.info(f"π― Model path: {MODEL_PATH}")
|
|
@@ -131,8 +133,7 @@ async def startup_event():
|
|
| 131 |
repo_type="space"
|
| 132 |
)
|
| 133 |
logger.info(f"β
Downloaded model to: {downloaded_path}")
|
| 134 |
-
global
|
| 135 |
-
MODEL_PATH = downloaded_path
|
| 136 |
except Exception as download_error:
|
| 137 |
logger.error(f"β Failed to download model: {download_error}")
|
| 138 |
# Continue without model for now
|
|
@@ -157,6 +158,7 @@ async def startup_event():
|
|
| 157 |
pipeline = None
|
| 158 |
# Don't exit - let the API start even without model
|
| 159 |
|
|
|
|
| 160 |
# Add a simple startup check endpoint
|
| 161 |
@app.get("/api/startup_check")
|
| 162 |
async def startup_check():
|
|
|
|
| 96 |
# Mount static files
|
| 97 |
app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
| 98 |
|
| 99 |
+
|
| 100 |
+
|
| 101 |
# Startup event - Initialize the model
|
| 102 |
@app.on_event("startup")
|
| 103 |
async def startup_event():
|
|
|
|
| 104 |
global pipeline
|
| 105 |
+
global MODEL_PATH # <-- Move this to the top before any use of MODEL_PATH
|
| 106 |
+
|
| 107 |
logger.info("π Starting WBC Classification API...")
|
| 108 |
logger.info(f"π Current working directory: {os.getcwd()}")
|
| 109 |
logger.info(f"π― Model path: {MODEL_PATH}")
|
|
|
|
| 133 |
repo_type="space"
|
| 134 |
)
|
| 135 |
logger.info(f"β
Downloaded model to: {downloaded_path}")
|
| 136 |
+
MODEL_PATH = downloaded_path # Now this works, since global is at the top
|
|
|
|
| 137 |
except Exception as download_error:
|
| 138 |
logger.error(f"β Failed to download model: {download_error}")
|
| 139 |
# Continue without model for now
|
|
|
|
| 158 |
pipeline = None
|
| 159 |
# Don't exit - let the API start even without model
|
| 160 |
|
| 161 |
+
|
| 162 |
# Add a simple startup check endpoint
|
| 163 |
@app.get("/api/startup_check")
|
| 164 |
async def startup_check():
|