PaddlePaddle / PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Apache License 2.0
12.81k stars 2.89k forks source link

按官方步骤来的,数据集格式没有问题,求解 #8515

Open NGIWS719 opened 1 year ago

NGIWS719 commented 1 year ago

问题确认 Search before asking

请提出你的问题 Please ask your question

[08/07 11:31:43] reader WARNING: fail to map sample transform [Decode_bf5711] with error: 'bytes' object has no attribute 'shape' and stack: Traceback (most recent call last): File "/home/aistudio/work/PaddleDetection/ppdet/data/reader.py", line 59, in call data = f(data) File "/home/aistudio/work/PaddleDetection/ppdet/data/transform/operators.py", line 103, in call sample[i] = self.apply(sample[i], context) File "/home/aistudio/work/PaddleDetection/ppdet/data/transform/operators.py", line 139, in apply elif sample['h'] != im.shape[0]: AttributeError: 'bytes' object has no attribute 'shape'

Traceback (most recent call last): File "tools/train.py", line 202, in Exception in thread Thread-2: Traceback (most recent call last): File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/dataloader_iter.py", line 505, in _thread_loop batch = self._get_data() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/dataloader_iter.py", line 634, in _get_data batch.reraise() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/worker.py", line 169, in reraise raise self.exc_type(msg) AttributeError: DataLoader worker(0) caught AttributeError with message: Traceback (most recent call last): File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/worker.py", line 329, in _worker_loop batch = fetcher.fetch(indices) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/fetcher.py", line 121, in fetch data.append(self.dataset[idx]) File "/home/aistudio/work/PaddleDetection/ppdet/data/source/dataset.py", line 102, in getitem return self.transform(roidb) File "/home/aistudio/work/PaddleDetection/ppdet/data/reader.py", line 65, in call raise e File "/home/aistudio/work/PaddleDetection/ppdet/data/reader.py", line 59, in call data = f(data) File "/home/aistudio/work/PaddleDetection/ppdet/data/transform/operators.py", line 103, in call sample[i] = self.apply(sample[i], context) File "/home/aistudio/work/PaddleDetection/ppdet/data/transform/operators.py", line 139, in apply elif sample['h'] != im.shape[0]: AttributeError: 'bytes' object has no attribute 'shape'

hukelin commented 1 year ago

我也遇到了,是预测推理阶段

hukelin commented 1 year ago

解决了吗

kitterive commented 10 months ago

同样问题,有解决的吗

yistiger commented 10 months ago

已解决,到PaddleDetection/ppdet/data/transform/operators.py,原代码:with open(sample['im_file'], 'rb') as f:

sample['image'] = f.read() 改为 sample['image'] = cv2.imread(sample['im_file'])

        打印sample print("image",sample["image"])
         print(sample),会发现有image是为None的,把None的图片在数据集、标注文件删除掉就可以了
buqi2yu commented 6 months ago

syriacus99 commented 4 months ago

同样的问题,解决了吗

yistiger commented 4 months ago

同样的问题,解决了吗

解决了 参考我上面给别人的回复哈

syriacus99 commented 4 months ago

同样的问题,解决了吗

解决了 参考我上面给别人的回复哈

那可能还是有不一样的问题,你说的那个我其实试了的,直接cv2.imread(sample['im_file'])读出来每个都是None,然后fread其实内存读到了同样大的数据,就是无法解码。最后我用docker环境了,我实在不知道是啥问题导致的,这段代码甚至单独拎出来都能成功读取到图片。