question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FCOS empty box images

See original GitHub issue

I 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
barschiiiicommented, Jan 25, 2022

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.

2reactions
barschiiiicommented, Jan 24, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found