Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -20,18 +20,20 @@ from io import BytesIO
|
|
20 |
import logging
|
21 |
logging.getLogger("uvicorn").setLevel(logging.WARNING)
|
22 |
|
23 |
-
import
|
24 |
-
|
25 |
-
# Set a custom path for Matplotlib to use
|
26 |
-
os.environ["MPLCONFIGDIR"] = "/app/.cache/matplotlib"
|
27 |
|
28 |
-
#
|
29 |
-
|
|
|
|
|
30 |
|
31 |
-
#
|
32 |
-
os.
|
33 |
-
os.
|
34 |
|
|
|
|
|
|
|
35 |
|
36 |
|
37 |
app = FastAPI()
|
|
|
20 |
import logging
|
21 |
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 |
|
38 |
|
39 |
app = FastAPI()
|