Skip to content

Commit

Permalink
Merge pull request #2 from soilb33/main
Browse files Browse the repository at this point in the history
added score output to the coco annotations.
  • Loading branch information
TankredO authored Jul 19, 2022
2 parents b3137de + a5d4d51 commit 2a0e1e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ginjinn/predictor/predictors.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ def predict(

if "COCO" in output_options:
self._update_coco(
"annotations", image, img_name, i_img + 1, boxes, classes, masks
"annotations", image, img_name, i_img + 1, boxes, scores, classes, masks
)

if "cropped" in output_options:
self._save_cropped(
image, img_name, i_img + 1, boxes, classes, masks, padding
image, img_name, i_img + 1, boxes, scores, classes, masks, padding
)

if "visualization" in output_options:
Expand Down Expand Up @@ -312,6 +312,7 @@ def _save_cropped(
img_name: str,
img_id: int,
boxes: np.ndarray,
scores: np.ndarray,
classes: List[str],
masks: Optional[np.ndarray] = None,
padding: int = 5,
Expand Down Expand Up @@ -360,6 +361,7 @@ def _save_cropped(
"img_{}_{}.jpg".format(img_id, i_inst + 1),
len(self._coco_images["annotations_cropped"]) + 1,
np.expand_dims(box, axis=0),
np.expand_dims(scores[i_inst], axis=0),
np.expand_dims(classes[i_inst], axis=0),
np.expand_dims(mask_cropped, axis=0),
)
Expand All @@ -371,6 +373,7 @@ def _update_coco(
img_name: str,
img_id: int,
boxes: np.ndarray,
scores: np.ndarray,
classes: List[str],
masks: Optional[np.ndarray] = None,
):
Expand All @@ -397,6 +400,7 @@ def _update_coco(
anno = {
"area": (bbox[2] - bbox[0]) * (bbox[3] - bbox[1]),
"bbox": bbox_coco,
"score": scores[i_inst],
"iscrowd": 0,
"image_id": img_id,
"id": len(self._coco_annotations[name]) + 1,
Expand Down

0 comments on commit 2a0e1e6

Please sign in to comment.