ch-tseng commited on
Commit
5da8fea
·
1 Parent(s): 6a3a328
Files changed (3) hide show
  1. app.py +5 -0
  2. config.py +10 -10
  3. download_gd.py +32 -0
app.py CHANGED
@@ -14,6 +14,11 @@ import streamlit as st
14
 
15
  import config
16
  from utils import load_model, infer_uploaded_image, infer_uploaded_video, infer_uploaded_webcam
 
 
 
 
 
17
 
18
  # setting page layout
19
  st.set_page_config(
 
14
 
15
  import config
16
  from utils import load_model, infer_uploaded_image, infer_uploaded_video, infer_uploaded_webcam
17
+ from download_gd import *
18
+ import os
19
+
20
+ if not os.path.exists('crowded_human_yolov8s.pt'):
21
+ download_file_from_google_drive('1qCXBDy3YuxS9bqfRIc--cRLo1L3DAYq2', 'crowded_human_yolov8s.pt')
22
 
23
  # setting page layout
24
  st.set_page_config(
config.py CHANGED
@@ -31,15 +31,15 @@ SOURCES_LIST = ["Image", "Video", "Webcam"]
31
 
32
  # DL model config
33
  DETECTION_MODEL_DIR = ROOT / 'models' / 'detection'
34
- YOLOv8n = DETECTION_MODEL_DIR / "yolov8n.pt"
35
- YOLOv8s = DETECTION_MODEL_DIR / "yolov8s.pt"
36
- YOLOv8m = DETECTION_MODEL_DIR / "yolov8m.pt"
37
- YOLOv8l = DETECTION_MODEL_DIR / "yolov8l.pt"
38
- YOLOv8x = DETECTION_MODEL_DIR / "yolov8x.pt"
39
 
40
  DETECTION_MODEL_LIST = [
41
- "yolov8n.pt",
42
- "yolov8s.pt",
43
- "yolov8m.pt",
44
- "yolov8l.pt",
45
- "yolov8x.pt"]
 
31
 
32
  # DL model config
33
  DETECTION_MODEL_DIR = ROOT / 'models' / 'detection'
34
+ #YOLOv8n = DETECTION_MODEL_DIR / "yolov8n.pt"
35
+ YOLOv8s = 'crowded_human_yolov8s.pt'
36
+ #YOLOv8m = DETECTION_MODEL_DIR / "yolov8m.pt"
37
+ #YOLOv8l = DETECTION_MODEL_DIR / "yolov8l.pt"
38
+ #YOLOv8x = DETECTION_MODEL_DIR / "yolov8x.pt"
39
 
40
  DETECTION_MODEL_LIST = [
41
+ # "yolov8n.pt",
42
+ "yolov8s.pt"]
43
+ # "yolov8m.pt",
44
+ # "yolov8l.pt",
45
+ # "yolov8x.pt"]
download_gd.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Reference: https://stackoverflow.com/questions/38511444/python-download-files-from-google-drive-using-url
2
+
3
+ import requests
4
+
5
+ def download_file_from_google_drive(id, destination):
6
+ URL = "https://docs.google.com/uc?export=download"
7
+
8
+ session = requests.Session()
9
+
10
+ response = session.get(URL, params = { 'id' : id }, stream = True)
11
+ token = get_confirm_token(response)
12
+
13
+ if token:
14
+ params = { 'id' : id, 'confirm' : token }
15
+ response = session.get(URL, params = params, stream = True)
16
+
17
+ save_response_content(response, destination)
18
+
19
+ def get_confirm_token(response):
20
+ for key, value in response.cookies.items():
21
+ if key.startswith('download_warning'):
22
+ return value
23
+
24
+ return None
25
+
26
+ def save_response_content(response, destination):
27
+ CHUNK_SIZE = 32768
28
+
29
+ with open(destination, "wb") as f:
30
+ for chunk in response.iter_content(CHUNK_SIZE):
31
+ if chunk: # filter out keep-alive new chunks
32
+ f.write(chunk)