Updates
This commit is contained in:
26
rpi/training/utils/debug.py
Normal file
26
rpi/training/utils/debug.py
Normal 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)}")
|
||||
Reference in New Issue
Block a user