This commit is contained in:
2025-12-21 12:06:28 +01:00
parent c0374b3890
commit 94b83fb018
32 changed files with 281 additions and 212 deletions

View File

@@ -0,0 +1,26 @@
from pathlib import Path
label_dir = Path("./datasets/your_dataset/val/labels")
def valid_line(line):
parts = line.split()
if len(parts) != 5:
return False
cls, x, y, w, h = map(float, parts)
return 0 <= cls and 0 < w <= 1 and 0 < h <= 1
empty = []
for p in label_dir.glob("*.txt"):
if p.stat().st_size == 0:
empty.append(p.name)
print(f"Empty label files: {len(empty)}")
invalid = []
for p in label_dir.glob("*.txt"):
lines = p.read_text().strip().splitlines()
if not any(valid_line(l) for l in lines):
invalid.append(p.name)
print(f"Effectively empty labels: {len(invalid)}")