Bingsu commited on
Commit
189300e
·
1 Parent(s): ef10017

feat: add ultralytics models, download concurrent

Browse files
Files changed (1) hide show
  1. models.py +39 -23
models.py CHANGED
@@ -1,33 +1,40 @@
1
  from __future__ import annotations
2
 
 
3
  from pathlib import Path
4
 
5
  from huggingface_hub import hf_hub_download
6
- from ultralytics import YOLO
7
  from tqdm.auto import tqdm
 
8
 
9
- REPOBINGSU = "Bingsu/adetailer"
10
- REPOGUON = "guon/hand-eyes"
 
11
 
12
  model_info = [
13
- (REPOBINGSU, "deepfashion2_yolov8s-seg.pt"),
14
- (REPOBINGSU, "face_yolov8m.pt"),
15
- (REPOBINGSU, "face_yolov8n.pt"),
16
- (REPOBINGSU, "face_yolov8n_v2.pt"),
17
- (REPOBINGSU, "face_yolov8s.pt"),
18
- (REPOBINGSU, "face_yolov9c.pt"),
19
- (REPOBINGSU, "hand_yolov8n.pt"),
20
- (REPOBINGSU, "hand_yolov8s.pt"),
21
- (REPOBINGSU, "hand_yolov9c.pt"),
22
- (REPOBINGSU, "person_yolov8m-seg.pt"),
23
- (REPOBINGSU, "person_yolov8n-seg.pt"),
24
- (REPOBINGSU, "person_yolov8s-seg.pt"),
25
- (REPOGUON, "Eyes.pt"),
26
- (REPOGUON, "PitEyeDetailer-v1-seg.pt"),
27
- (REPOGUON, "PitHandDetailer-v1-seg.pt"),
28
- (REPOGUON, "female_breast-v4.2.pt"),
29
- (REPOGUON, "full_eyes_detect_v1.pt"),
30
- (REPOGUON, "lips_v1.pt"),
 
 
 
 
 
31
  ]
32
 
33
 
@@ -45,8 +52,17 @@ def export(path: str) -> str:
45
  def main():
46
  save = Path("models")
47
  save.mkdir(exist_ok=True)
48
- for repo, model in tqdm(model_info):
49
- path = download(model, repo)
 
 
 
 
 
 
 
 
 
50
  onnx = export(path)
51
  target_dir = save / Path(model).stem
52
  (target_dir / "1").mkdir(exist_ok=True, parents=True)
 
1
  from __future__ import annotations
2
 
3
+ from concurrent.futures import ThreadPoolExecutor
4
  from pathlib import Path
5
 
6
  from huggingface_hub import hf_hub_download
 
7
  from tqdm.auto import tqdm
8
+ from ultralytics import YOLO
9
 
10
+ BINGSU = "Bingsu/adetailer"
11
+ GUON = "guon/hand-eyes"
12
+ ULTRALYTICS = "Ultralytics/YOLOv8"
13
 
14
  model_info = [
15
+ (BINGSU, "deepfashion2_yolov8s-seg.pt"),
16
+ (BINGSU, "face_yolov8m.pt"),
17
+ (BINGSU, "face_yolov8n.pt"),
18
+ (BINGSU, "face_yolov8n_v2.pt"),
19
+ (BINGSU, "face_yolov8s.pt"),
20
+ (BINGSU, "face_yolov9c.pt"),
21
+ (BINGSU, "hand_yolov8n.pt"),
22
+ (BINGSU, "hand_yolov8s.pt"),
23
+ (BINGSU, "hand_yolov9c.pt"),
24
+ (BINGSU, "person_yolov8m-seg.pt"),
25
+ (BINGSU, "person_yolov8n-seg.pt"),
26
+ (BINGSU, "person_yolov8s-seg.pt"),
27
+ (GUON, "Eyes.pt"),
28
+ (GUON, "PitEyeDetailer-v1-seg.pt"),
29
+ (GUON, "PitHandDetailer-v1-seg.pt"),
30
+ (GUON, "female_breast-v4.2.pt"),
31
+ (GUON, "full_eyes_detect_v1.pt"),
32
+ (GUON, "lips_v1.pt"),
33
+ (ULTRALYTICS, "yolov8l.pt"),
34
+ (ULTRALYTICS, "yolov8m.pt"),
35
+ (ULTRALYTICS, "yolov8n.pt"),
36
+ (ULTRALYTICS, "yolov8s.pt"),
37
+ (ULTRALYTICS, "yolov8x.pt"),
38
  ]
39
 
40
 
 
52
  def main():
53
  save = Path("models")
54
  save.mkdir(exist_ok=True)
55
+
56
+ pbar = tqdm(model_info)
57
+ with ThreadPoolExecutor() as executor:
58
+ fs = []
59
+ for repo, model in tqdm(model_info):
60
+ fu = executor.submit(download, model, repo)
61
+ fu.add_done_callback(lambda _: pbar.update())
62
+ fs.append(fu)
63
+
64
+ for future in fs:
65
+ path = future.result()
66
  onnx = export(path)
67
  target_dir = save / Path(model).stem
68
  (target_dir / "1").mkdir(exist_ok=True, parents=True)