Closed Jonas-Meier closed 3 years ago
Hi @Jonas-Meier ,
Good catch! I think that makes sense to reinitialize the mask each time an object is to add, a new commit has been made. Thanks a lot !
It probably needs to be adjusted in other metadata creation files as well. But I'm closing the issue since it's essentially fixed as of b703ae7.
Probably, there is a bug with the
mask
variable in metadata creation. The variable is created in the loop over all images, but is modified in the loop over the annotations of an image. When sampling more than one annotation per image, themask
is not reset back to 0s but instead still holds the 1s from the bbox of the previous annotation. The next annotation then sets 1s for its bbox which could result in a wrong mask for that annotation, since old 1s are still present.Originally, there was a limit to sample at most one annotation per image https://github.com/YoungXIAO13/FewShotDetection/blob/6eac710dae379ff025fac697c9d5ed80ef5bf06a/lib/datasets/metadata_coco.py#L234 which would prevent that inconsistency of
mask
variable, since it would be reset back to 0s before processing annotations of a new image.But since commit 838f471, we allow for sampling multiple annotations per image which could lead to the inconsistency described above. Curently, we have a phase-dependent strategy, https://github.com/YoungXIAO13/FewShotDetection/blob/fc0b453029cffb8719b9d65421f9a91019c1a392/lib/datasets/metadata_coco.py#L240-L241 which could still lead to problems for phase 2.
I'm not sure if we should reset the masks values back to zero
mask[y1:y2, x1:x2] = 0
or to completely redefine the variablemask = np.zeros((self.img_size, self.img_size), dtype=np.float32)
, directly after https://github.com/YoungXIAO13/FewShotDetection/blob/fc0b453029cffb8719b9d65421f9a91019c1a392/lib/datasets/metadata_coco.py#L238