map_classes_to_indices() ClassesToIndices() update #6468
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
map_classes_to_indices utility (and ClassesToIndices transforms) currently returns a list of coordinates for each class, but the type is List[ of MetaTensors], where each class coordinate sub-list is its own MetaTensor. This PR changes it to return a list of torch.Tensors (or ndarray), since we don't need a MetaTensor here.
I ran into an issue with current MetaTensor list, where it would just freeze without any errors, when trying to save the cached indices (returned from ClassesToIndices to cache, which is ListProxy shared mem). It randomly happens, but much more frequently when the number of classes is large (e.g. 105 output classes, so ClassesToIndices returns a list of 105 MetaTensors). I'm not sure what the cause of the freeze is, but my guess is that ListProxy tries to pickle each element of this list (and struggles with MetaTensors). Disabling MetaTensor return type here, solves the issue.
since we don't really need meta tensor return type for each class (coordinates), this seems like harmless fix. the original image/label always will have meta info.
@wyli plz check.
Description
A few sentences describing the changes proposed in this pull request.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.