-
Notifications
You must be signed in to change notification settings - Fork 7.1k
MaskRCNN Training on Images with no Annotations #3022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@gatordevin please take a look at reference example here : https://github.com/pytorch/vision/tree/master/references/detection vision/references/detection/coco_utils.py Line 244 in 8c28175
|
Okay, so my understanding of this code is that the transforms are applied once to the dataset upon initialization. Then any images that had annotations removed from the transforms are then removed from the dataset. Thats all fine but what if I would like to apply the randomized transforms to the images every batch. |
During the training random horizontal flip is applied on the images and targets: vision/references/detection/train.py Line 55 in 8c28175
|
Oh alright, I see that now. In that case, how would I include a random crop transformation in my dataset since it introduces the chance of removing annotations? From what I have seen the images are only removed when the dataset is initialized not after transform meaning if a random crop is applied and annotations are gone this won't be recognized. |
If you are using albumentations, as far as I remember they have transformations aware of target's geometry such that for example random crop will reduce image such that target still present. If you'd like to use torchvision's transforms, I'd suggest to use functional part to perform image transforms. As for transforming targets, this should be, for instance, manually implemented. Same for random parameters sampling. |
@gatordevin I hit a potentially similar issue as you did. Would it be possible to update the ticket to include the full error message? |
Hi all,
I am working on a little MaskRCNN training program and ran into an issue. I know it is common practice to remove any images from the dataset that lack annotations upon initializing the dataset which I am doing. However, I am running a series of transforms using albumentations on my image and my mask. One of these transforms is a random crop and sometimes the resulting mask image no longer contains any instances. I was trying to find a way to pass in an empty tensor of some kind without much success. Would it be common practice just to remove it from the batch, and if so what happens if you had a batch size of 1 or an image that only had one annotation and the chances the random crop came across it are really low. I was able to create an empty tensor and pass it in but then received this error.
RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] because the unspecified dimension size -1 can be any value and is ambiguous
This is because my box tensor had a shape of 0, 4 which is what I want since there are no instances. I read some of the other issue reports and they talked about creating a background class and just making a small bounding box and having an empty segmentation mask but this seems a little hacky and I was wondering if there would be a better solution for my specific use case.
The text was updated successfully, but these errors were encountered: