【问题标题】:How Can I change the value of "maxdets" in Faster R-CNN by Pytorch?如何在 Pytorch 的 Faster R-CNN 中更改“maxdets”的值?
【发布时间】:2020-08-19 07:31:16
【问题描述】:

我正在 pytorch 上实现更快的 RCNN 网络。我已按照下一个教程进行操作。

https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html

在一些图像中,我有 100 多个对象要分类。但是,在本教程中,我最多只能检测 100 个对象,因为参数“maxdets” = 100。

有没有办法改变这个值以适应我的项目?

IoU metric: bbox
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.235
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.655
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.105
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.238
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.006
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.066
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.331
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.331
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000

如果只改变下一个参数,问题就解决了吗?

cocoeval.Params.setDetParams.maxDets = [1, 10, 100]

谢谢!

【问题讨论】:

    标签: pytorch faster-rcnn coco


    【解决方案1】:

    “有些图像中我有超过 100 个对象要分类。”

    maxDets = 100 并不意味着它只会对 100 个图像进行分类,而是指% AverageRecall given 100 detections per image

    inshort maxDets 与指标无关。分类的图像。

    欲了解更多信息,请访问: http://cocodataset.org/#detection-eval

    Tensorboard graph recall

    https://github.com/matterport/Mask_RCNN/issues/663

     # Limit to max_per_image detections **over all classes**
        if number_of_detections > self.detections_per_img > 0:
            cls_scores = result.get_field("scores")
            image_thresh, _ = torch.kthvalue(
                cls_scores.cpu(), number_of_detections - self.detections_per_img + 1
            )
            keep = cls_scores >= image_thresh.item()
            keep = torch.nonzero(keep).squeeze(1)
            result = result[keep]
        return result
    

    根据这段代码 sn-p 我发现它检查了否。检测的 所以model.roi_heads.detections_per_img=300 对你的目的是正确的。 而且我在 maxdets 上没有找到太多合适的文档,但我想上面的代码应该可以工作。

     # non-maximum suppression, independently done per class
       keep = box_ops.batched_nms(boxes, scores, labels, self.nms_thresh)
     # keep only topk scoring predictions
       keep = keep[:self.detections_per_img]
    

    这段代码 sn-p 表示我们只能过滤掉我们希望在模型中拥有的一些顶级检测。

    【讨论】:

    • 好吧。我想说的是,我有每个图像有超过 100 个相同类别的对象。我找到了一个参数,可以让我的模型检测超过 100 个对象。 model.roi_heads.detections_per_img=300 这对我的目的是否正确?不知道Faster RCNN的训练是否正确,只要我改变before参数。您是否认为我还应该更改指标中的“maxdets”参数以使一切正常工作?谢谢!
    • 完美。我想第一个代码 sn-p 属于link。我试图更改参数model.roi_heads.detections_per_img,实际上,我的模型检测到超过 100 个对象,并且比输入的数字少。第二个 sn-p 代码,如果检测到的对象不超过某个阈值,它是否用于删除这些对象?关于 maxdets 的信息很少,你是对的!
    • "第二个sn-p代码,如果检测到的对象不超过某个阈值,它是用来删除的吗?" 是的,我猜算法检测到很多对象,我们可以得到前K不。我们想要的对象。
    猜你喜欢
    • 2020-05-06
    • 2018-01-03
    • 1970-01-01
    • 2021-03-26
    • 1970-01-01
    • 2020-02-10
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    相关资源
    最近更新 更多