Skip to content

Make the RandCropByLabelClassesd warning only show when ratio for a missing class is set to nonzero #7594

Closed
@lorinczszabolcs

Description

@lorinczszabolcs

Is your feature request related to a problem? Please describe.
Warnings such as no available indices of class 1 to crop, set the crop ratio of this class to zero. appear even when ratios is already set to 0 for the missing class 1.

Describe the solution you'd like
I would suggest that if ratio for a class is already 0 set by the user, then such warnings should not be printed.

I would like to see something similar:

for i, array in enumerate(indices):
  if len(array) == 0:
    if ratios_[i] != 0:  # suggested change
      ratios_[i] = 0
      if warn:
          warnings.warn(f"no available indices of class {i} to crop, set the crop ratio of this class to zero.")

Describe alternatives you've considered
Suppressing such warnings could be an option too, but I think the other option would be friendlier.

Additional context
Found slightly related issue and PR: #6094 #6121 , but it's not completely the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions