Spaces:
Build error
Build error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +6 -0
src/streamlit_app.py
CHANGED
@@ -1,8 +1,14 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import torch
|
3 |
import numpy as np
|
4 |
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
# Load the YOLOv5 model
|
7 |
model = torch.hub.load('ultralytics/yolov5', 'custom', path='model/best.pt', force_reload=True)
|
8 |
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
3 |
import torch
|
4 |
import numpy as np
|
5 |
from streamlit_webrtc import webrtc_streamer, VideoTransformerBase
|
6 |
|
7 |
+
# Set a writable cache directory for PyTorch
|
8 |
+
torch_cache_dir = os.path.join(os.getcwd(), 'torch_cache')
|
9 |
+
os.makedirs(torch_cache_dir, exist_ok=True)
|
10 |
+
os.environ['TORCH_HOME'] = torch_cache_dir
|
11 |
+
|
12 |
# Load the YOLOv5 model
|
13 |
model = torch.hub.load('ultralytics/yolov5', 'custom', path='model/best.pt', force_reload=True)
|
14 |
|