Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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)
|