PaddleDetection使用问题01_COCODataSet_object_has_no_attribute

本文档讲述了在使用PaddleDetection进行模型预测时遇到的错误,原因在于TestDataset配置中误将ImageFolder设置为COCODataSet。解决方案是修正配置,确保EvalDataset使用COCODataSet,同时提供正确的训练和验证集配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 问题

Traceback (most recent call last):
  File "tools/infer.py", line 177, in <module>
    main()
  File "tools/infer.py", line 173, in main
    run(FLAGS, cfg)
  File "tools/infer.py", line 134, in run
    save_txt=FLAGS.save_txt)
  File "/home/zhangxin/github/PaddleDetection/ppdet/engine/trainer.py", line 541, in predict
    self.dataset.set_images(images)
AttributeError: 'COCODataSet' object has no attribute 'set_images'

2 解决办法:

错误原因是TestDataset配置错了,在改配置文件时把ImageFolder错改成了COCODataSet。

metric: COCO
num_classes: 80

TrainDataset:
  !COCODataSet
    image_dir: train2017
    anno_path: annotations/instances_train2017.json
    dataset_dir: dataset/coco
    data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd']

EvalDataset:
  !COCODataSet
    image_dir: val2017
    anno_path: annotations/instances_val2017.json
    dataset_dir: dataset/coco

TestDataset:
  !ImageFolder
    anno_path: annotations/instances_val2017.json
    dataset_dir: dataset/coco
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张欣-男

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值