kostya-cholak commited on
Commit
dedf935
·
1 Parent(s): 55439af

fix: load model from HF

Browse files
Files changed (2) hide show
  1. app.py +12 -1
  2. requirements.txt +5 -4
app.py CHANGED
@@ -5,11 +5,22 @@ import cv2
5
  import streamlit as st
6
 
7
  from ultralytics import YOLO
 
8
 
9
 
10
  @st.cache_resource
11
  def load_model():
12
- return YOLO("models/soccer_ball.pt")
 
 
 
 
 
 
 
 
 
 
13
 
14
 
15
  def process_video(video_path):
 
5
  import streamlit as st
6
 
7
  from ultralytics import YOLO
8
+ from huggingface_hub import hf_hub_url, cached_download
9
 
10
 
11
  @st.cache_resource
12
  def load_model():
13
+ repo_id = "BreakIntoData/cv_workshop"
14
+ filename = "soccer_ball.pt"
15
+
16
+ # Create a URL for the model file on the Hugging Face Hub
17
+ model_url = hf_hub_url(repo_id, filename)
18
+
19
+ # Download the model file from the Hub and cache it locally
20
+ cached_model_path = cached_download(model_url)
21
+
22
+ # Load the model using YOLO from the cached model file
23
+ return YOLO(cached_model_path)
24
 
25
 
26
  def process_video(video_path):
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
- ultralytics
2
- opencv-python
3
- numpy
4
- streamlit
 
 
1
+ ultralytics==8.2.63
2
+ opencv-python==4.10.0.84
3
+ numpy==1.26.4
4
+ streamlit==1.37.1
5
+ huggingface_hub==0.24.5