Codewithsalty commited on
Commit
68f05cc
·
verified ·
1 Parent(s): ac416f7

Update newapi.py

Browse files
Files changed (1) hide show
  1. newapi.py +4 -5
newapi.py CHANGED
@@ -11,10 +11,9 @@ from huggingface_hub import hf_hub_download
11
  from models.TumorModel import TumorClassification, GliomaStageModel
12
  from utils import get_precautions_from_gemini
13
 
14
- # ✅ Use Hugging Face's built-in writable cache directory
15
- cache_dir = "/home/user/.cache/huggingface"
16
-
17
- # No need to call os.makedirs — directory already exists
18
 
19
  # Initialize FastAPI app
20
  app = FastAPI(title="Brain Tumor Detection API")
@@ -107,7 +106,7 @@ async def predict_glioma_stage(data: MutationInput):
107
  stages = ['Stage 1', 'Stage 2', 'Stage 3', 'Stage 4']
108
  return {"glioma_stage": stages[idx]}
109
 
110
- # For local development only
111
  if __name__ == "__main__":
112
  import uvicorn
113
  uvicorn.run("newapi:app", host="0.0.0.0", port=10000)
 
11
  from models.TumorModel import TumorClassification, GliomaStageModel
12
  from utils import get_precautions_from_gemini
13
 
14
+ # ✅ Use a safe local cache dir
15
+ cache_dir = "./hf_cache"
16
+ os.makedirs(cache_dir, exist_ok=True) # create if it doesn't exist
 
17
 
18
  # Initialize FastAPI app
19
  app = FastAPI(title="Brain Tumor Detection API")
 
106
  stages = ['Stage 1', 'Stage 2', 'Stage 3', 'Stage 4']
107
  return {"glioma_stage": stages[idx]}
108
 
109
+ # Only needed for local development, not in Hugging Face Spaces
110
  if __name__ == "__main__":
111
  import uvicorn
112
  uvicorn.run("newapi:app", host="0.0.0.0", port=10000)