Sanjayraju30 commited on
Commit
0d71e7b
·
verified ·
1 Parent(s): 8a6f8bf

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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