Spaces:
Sleeping
Sleeping
DmitriiSavin
dsavin
commited on
[113] - Handle batches with no gt, Add images with no gt to the dataset (#120)
Browse files
yolo/tools/data_loader.py
CHANGED
|
@@ -87,9 +87,6 @@ class YoloDataset(Dataset):
|
|
| 87 |
continue
|
| 88 |
annotations = annotations_index.get(image_info["id"], [])
|
| 89 |
image_seg_annotations = scale_segmentation(annotations, image_info)
|
| 90 |
-
if not image_seg_annotations:
|
| 91 |
-
continue
|
| 92 |
-
|
| 93 |
elif data_type == "txt":
|
| 94 |
label_path = labels_path / f"{image_id}.txt"
|
| 95 |
if not label_path.is_file():
|
|
|
|
| 87 |
continue
|
| 88 |
annotations = annotations_index.get(image_info["id"], [])
|
| 89 |
image_seg_annotations = scale_segmentation(annotations, image_info)
|
|
|
|
|
|
|
|
|
|
| 90 |
elif data_type == "txt":
|
| 91 |
label_path = labels_path / f"{image_id}.txt"
|
| 92 |
if not label_path.is_file():
|
yolo/tools/loss_functions.py
CHANGED
|
@@ -93,7 +93,7 @@ class YOLOLoss:
|
|
| 93 |
targets_cls, targets_bbox = self.separate_anchor(align_targets)
|
| 94 |
predicts_box = predicts_box / self.vec2box.scaler[None, :, None]
|
| 95 |
|
| 96 |
-
cls_norm = targets_cls.sum()
|
| 97 |
box_norm = targets_cls.sum(-1)[valid_masks]
|
| 98 |
|
| 99 |
## -- CLS -- ##
|
|
|
|
| 93 |
targets_cls, targets_bbox = self.separate_anchor(align_targets)
|
| 94 |
predicts_box = predicts_box / self.vec2box.scaler[None, :, None]
|
| 95 |
|
| 96 |
+
cls_norm = max(targets_cls.sum(), 1)
|
| 97 |
box_norm = targets_cls.sum(-1)[valid_masks]
|
| 98 |
|
| 99 |
## -- CLS -- ##
|