feat: add ultralytics models, download concurrent
Browse files
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 |
-
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
model_info = [
|
| 13 |
-
(
|
| 14 |
-
(
|
| 15 |
-
(
|
| 16 |
-
(
|
| 17 |
-
(
|
| 18 |
-
(
|
| 19 |
-
(
|
| 20 |
-
(
|
| 21 |
-
(
|
| 22 |
-
(
|
| 23 |
-
(
|
| 24 |
-
(
|
| 25 |
-
(
|
| 26 |
-
(
|
| 27 |
-
(
|
| 28 |
-
(
|
| 29 |
-
(
|
| 30 |
-
(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|