simplify module3 venue workflow

This commit is contained in:
2026-09-16 06:33:11 +03:00
parent 25972390f1
commit 68dde2cfaf
6 changed files with 58 additions and 33 deletions
+10 -4
View File
@@ -5,18 +5,24 @@ from pathlib import Path
HERE = Path(__file__).resolve().parent
SOURCE = HERE / "dataset/raw"
SOURCE = HERE / "dataset/label-studio"
IMAGES = SOURCE / "images"
LABELS = SOURCE / "labels"
OUTPUT = HERE / "training_new"
IMAGE_EXTENSIONS = {".jpg", ".jpeg", ".png", ".bmp", ".webp"}
def main():
images = sorted(path for path in SOURCE.iterdir() if path.suffix.lower() in IMAGE_EXTENSIONS)
if not IMAGES.is_dir():
raise SystemExit(f"Нет каталога {IMAGES}")
images = sorted(path for path in IMAGES.iterdir() if path.suffix.lower() in IMAGE_EXTENSIONS)
if not images:
raise SystemExit(f"Нет кадров в {SOURCE}")
raise SystemExit(f"Нет кадров в {IMAGES}")
if not LABELS.is_dir():
raise SystemExit(f"Сначала экспортируйте YOLO-разметку в {LABELS}")
classes_file = SOURCE / "classes.txt"
if not classes_file.is_file():
raise SystemExit(f"Нет {classes_file}")
random.Random(42).shuffle(images)
test_count = max(1, round(len(images) * 0.1)) if len(images) >= 3 else 0
@@ -44,7 +50,7 @@ def main():
else:
destination.touch()
classes = (HERE / "dataset/classes.txt").read_text(encoding="utf-8").splitlines()
classes = classes_file.read_text(encoding="utf-8").splitlines()
names = "\n".join(f" {number}: {name}" for number, name in enumerate(classes))
(OUTPUT / "data.yaml").write_text(
f"path: {OUTPUT}\ntrain: train/images\nval: valid/images\ntest: test/images\n\nnames:\n{names}\n",