Skip to content

Underweighting empty images? #133

Description

@asgersvenning

Here:

self.sample_weights = [image_weight * len(label_i["cls"]) for label_i, image_weight in zip(self.labels, calculate_image_weights(self.im_files))]
self.__indices = generate_indices(self.sample_weights, target_size=len(self.im_files) * self._oversample_factor)
len(label_i["cls"]) is the number of instances (objects/labels) in the image, so we literally set the resampling weight to zero if the image is empty. This still doesn't mean we completely ignore it, because generate_indices ensures that all images are included at least once per epoch, even if the weight is zero:
for i, w in enumerate(weights):
indices.extend([i] * int(max(round(w), 1)))

but still, perhaps we should change to:

self.sample_weights = [image_weight * (1 + len(label_i["cls"])) for label_i, image_weight in zip(self.labels, calculate_image_weights(self.im_files))]

Should try out when we train V2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

codeRelated to codeenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions