shubham5524 commited on
Commit
3b0b0be
·
verified ·
1 Parent(s): 14bf0ca

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +1 -4
main.py CHANGED
@@ -22,16 +22,13 @@ logging.getLogger("uvicorn").setLevel(logging.WARNING)
22
 
23
  import tempfile
24
 
25
- # Instead of hardcoding paths to /app/.cache
26
  temp_dir = tempfile.gettempdir()
27
  matplotlib_cache = os.path.join(temp_dir, "matplotlib")
28
  torchxrayvision_cache = os.path.join(temp_dir, "torchxrayvision")
29
 
30
- # Set environment variables to use these paths
31
  os.environ["MPLCONFIGDIR"] = matplotlib_cache
32
  os.environ["TORCHXrayVISION_CACHE"] = torchxrayvision_cache
33
 
34
- # Create directories
35
  os.makedirs(matplotlib_cache, exist_ok=True)
36
  os.makedirs(torchxrayvision_cache, exist_ok=True)
37
 
@@ -132,4 +129,4 @@ async def predict_cxr(image_url: str = Query(..., description="URL to a chest X-
132
  })
133
 
134
  except Exception as e:
135
- return JSONResponse(content={"error": str(e)}, status_code=500)
 
22
 
23
  import tempfile
24
 
 
25
  temp_dir = tempfile.gettempdir()
26
  matplotlib_cache = os.path.join(temp_dir, "matplotlib")
27
  torchxrayvision_cache = os.path.join(temp_dir, "torchxrayvision")
28
 
 
29
  os.environ["MPLCONFIGDIR"] = matplotlib_cache
30
  os.environ["TORCHXrayVISION_CACHE"] = torchxrayvision_cache
31
 
 
32
  os.makedirs(matplotlib_cache, exist_ok=True)
33
  os.makedirs(torchxrayvision_cache, exist_ok=True)
34
 
 
129
  })
130
 
131
  except Exception as e:
132
+ return JSONResponse(content={"error": str(e)}, status_code=500)