in src/sagemaker_defect_detection/dataset/neu.py [0:0]
def _make_dataset(self) -> List[DetectionSample]:
instances = []
base_dir = self.root.expanduser()
for target_cls in sorted(self.class_to_idx.keys()):
cls_idx = self.class_to_idx[target_cls]
target_dir = base_dir / target_cls
if not target_dir.is_dir():
continue
images = sorted(list((target_dir / "images").glob("*.jpg")))
annotations = sorted(list((target_dir / "annotations").glob("*.xml")))
assert len(images) == len(annotations), f"something is wrong. Mismatched number of images and annotations"
for path, ann in zip(images, annotations):
instances.append(DetectionSample(str(path), int(cls_idx), str(ann)))
return instances