简体   繁体   English

AttributeError: 在给定的实例中找不到字段“pred_masks”

[英]AttributeError: Cannot find field 'pred_masks' in the given Instances

I trained a model with RetinaNet Detectron2 on colab.我在 colab 上用 RetinaNet Detectron2 训练了一个模型。 The training is successful but i am unable to test it on images.培训成功,但我无法在图像上对其进行测试。

Code:代码:

from detectron2.utils.visualizer import ColorMode
import glob

for imageName in glob.glob('/content/drive/My Drive/Detectron/test/*jpg'):
    print(imageName)
    im = cv2.imread(imageName)
    outputs = predictor(im)
    v = Visualizer(im[:, :, ::-1],
                metadata=test_metadata, 
                scale=0.8,
                instance_mode=ColorMode.IMAGE_BW
                 )
    out = v.draw_instance_predictions(outputs["instances"].to("cpu"))
    cv2_imshow(out.get_image()[:, :, ::-1])

Error:错误:

/content/drive/My Drive/Detectron/test/wh_dresscode_4969_jpg.rf.5a2702518691d3d6f9cef7ad7977e5c8.jpg data type: <class 'detectron2.structures.instances.Instances'> AttributeError Traceback (most recent call last) /content/drive/My Drive/Detectron/test/wh_dresscode_4969_jpg.rf.5a2702518691d3d6f9cef7ad7977e5c8.jpg 数据类型:<class 'detectron2.structures.instances.Instances'> AttributeError Traceback(最近一次调用)

AttributeError: Cannot find field 'pred_masks' in the given Instances! AttributeError: 在给定的实例中找不到字段“pred_masks”!

it seems that your model was trained to predict only bounding boxes;似乎您的模型被训练为仅预测边界框; that is you do not predict segmentations masks as in maskrcnn.也就是说,您不像在 maskrcnn 中那样预测分段掩码。 If that is the case, you can remove instance_mode=ColorMode.IMAGE_BW from Visualizer如果是这种情况,您可以从Visualizer删除instance_mode=ColorMode.IMAGE_BW

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有给定掩码的“无稀疏” numpy数组 - “Unsparsing” numpy Arrays with Given Masks AttributeError: &#39;Node&#39; 对象没有属性 &#39;output_masks&#39; - AttributeError: 'Node' object has no attribute 'output_masks' AttributeError: &#39;Node&#39; 对象在 Keras 中没有属性 &#39;output_masks&#39; - AttributeError: 'Node' object has no attribute 'output_masks' in Keras AttributeError:“节点”object 没有属性“输入掩码” - AttributeError: 'Node' object has no attribute 'input_masks' 无法获取查找功能以突出显示目标的所有实例(文本编辑器) - Cannot get find function to highlight all instances of the target (text editor) 将 model 的实例保存到 ManyToMany 字段 AttributeError 'Post' object 没有属性 'save_m2m' 但是当检查 db 时,已保存 - Saving instances of model to ManyToMany field thows AttributeError 'Post' object has no attribute 'save_m2m' but when db is checked, has saved init 中定义的字段上的 AttributeError - AttributeError on field defined in init 给定一个值随时间的子区间,可以在函数中找到该模式的“相似实例” - Given a subinterval of a value over time find “similar instances” of that pattern along the function pred = model.predict_classes([prepare(file_path)]) AttributeError: 'Functional' object 没有属性 'predict_classes' - pred = model.predict_classes([prepare(file_path)]) AttributeError: 'Functional' object has no attribute 'predict_classes' 由于资源原因,无法将 model 与我的所有图像和蒙版配合使用 - Cannot fit model with all my images and masks, because of resources
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM