-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvalidation_tools.py
More file actions
23 lines (21 loc) · 856 Bytes
/
Copy pathvalidation_tools.py
File metadata and controls
23 lines (21 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Validator:
def __init__(self):
pass
def validate(self, annotations):
issues = []
for i, anno in enumerate(annotations):
if "coords" not in anno or not anno["coords"]:
issues.append(f"Annotation {i} has no coordinates.")
if "class" not in anno:
issues.append(f"Annotation {i} has no class assigned.")
if anno.get("type") == "bbox":
x, y, w, h = anno["coords"]
if w <= 0 or h <= 0:
issues.append(f"Annotation {i} has invalid bbox dimensions.")
return issues
def calculate_annotation_metrics(self, annotations):
metrics = {}
for anno in annotations:
cls = anno.get("class", "Unknown")
metrics[cls] = metrics.get(cls, 0) + 1
return metrics