FCOS empty box images
See original GitHub issueI am playing around with new FCOS models (thanks for that) and am encountering issues when providing images without box annotations. This is a common use case in object detection, and also works for other detector models in torchvision.
A simple example to replicate:
model = fcos_resnet50_fpn(pretrained=True)
model(torch.zeros((1,3,512,512)), targets=[{"boxes": torch.empty(0,4), "labels": torch.empty(0,1).to(torch.int64)}])
An indexing error happens in FCOSHead
when running compute_loss
in this part:
all_gt_classes_targets = []
all_gt_boxes_targets = []
for targets_per_image, matched_idxs_per_image in zip(targets, matched_idxs):
gt_classes_targets = targets_per_image["labels"][matched_idxs_per_image.clip(min=0)]
gt_classes_targets[matched_idxs_per_image < 0] = -1 # backgroud
gt_boxes_targets = targets_per_image["boxes"][matched_idxs_per_image.clip(min=0)]
all_gt_classes_targets.append(gt_classes_targets)
all_gt_boxes_targets.append(gt_boxes_targets)
A workaround seems to be necessary, when having empty targets. Happy for any guidance, maybe there is also a different way necessary for me to train on empty images.
@jdsgomes @xiaohu2015 @zhiqwang
Versions
Torchvision @ master
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:18 (8 by maintainers)
Top Results From Across the Web
A Ship Detection Method via Redesigned FCOS in Large ...
Ship detection in large-scale synthetic aperture radar (SAR) images has ... tend to contain empty backgrounds, and only a few anchor boxes contain...
Read more >Empty box Images | Free Vectors, Stock Photos & PSD - Freepik
Find & Download Free Graphic Resources for Empty Box. 85000+ Vectors, Stock Photos & PSD files. ✓ Free for commercial use ✓ High...
Read more >FCOS unusually slow on Raspberry Pi 3B - Fedora Discussion
Has anyone run FCOS on a Pi 3B and noticed such slowness? ... but I only found an empty journal file and I...
Read more >Forget the hassles of Anchor boxes with FCOS
Anchor-Based Detectors; FCOS proposed idea; Multi-level detection ... Following is a simple image describing use of anchor boxes in Yolov3:.
Read more >Photos are loading as black boxes, empty boxes or broken ...
If you can't see photos on Facebook and you're seeing black boxes, empty boxes or broken images instead, you can report a problem....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
But shouldn’t the anchor size then be adjusted manually from the multi-level feature map stride? I can see in detectron2 implementation, that they are calculating the stride each time for a backbone that is passed. Here in this case the anchor size is hardcoded, and I am wondering how these hard-coded values have been decided, the default ones seem not right to me.
SGD with AMP, and Adam without AMP seem to both run fine. Adam with AMP and gradient clipping runs into instability (NaN) issues, also with different learning rates.