【问题标题】:Type of input images for object detection in Detectron2Detectron2 中用于对象检测的输入图像类型
【发布时间】:2021-05-10 15:51:19
【问题描述】:

我正在使用 Detectron2 训练 Faster R-CNN 模型进行对象检测,我想训练模型 zoo 给出的模型,输入范围为 [0 1] 而不是 [0 255] 所以我使用了颜色变换调用我的函数 scale_transform

def scale_transform(img):
    return img/255.

这个函数正在接收一个 numpy 数组并将其按比例返回。但是,在训练时会出现此错误

RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same

有人知道我该如何解决这个问题吗?或其他方式来缩放检测器2的图像?

谢谢

【问题讨论】:

    标签: python object-detection image-preprocessing detectron


    【解决方案1】:

    我认为这里的相关词是type

    也许确保输入定义为浮点数。虽然它在正确的范围 (0-1) 内,但它可能会发现数据类型不正确,因此会跳到那里。

    以下可能对它-

    def scale_transform(img):
        img = img/255
        img = img.astype(np.float32)
        return img
    

    【讨论】:

    • 太好了,@MichaelPatiño!可能值得接受它作为帮助他人的答案
    猜你喜欢
    • 2020-11-24
    • 2022-08-26
    • 2014-09-11
    • 2021-06-06
    • 2018-05-08
    • 1970-01-01
    • 1970-01-01
    • 2021-04-25
    • 2012-06-05
    相关资源
    最近更新 更多