PaddleSeg icon indicating copy to clipboard operation
PaddleSeg copied to clipboard

[Bug] 在AIStudio上试图训练自定义数据集时报错,"cannot identify image file %r" % (filename if filename else fp) PIL.UnidentifiedImageError: cannot identify image file

Open htlbayytq opened this issue 3 years ago • 1 comments

在AIStudio上试图训练自定义数据集时报错。

运行代码: !export CUDA_VISIBLE_DEVICES=0 !python train.py
--config configs/pp_liteseg/pp_liteseg_111.yml

报错如下: 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 218, in _thread_loop self._thread_done_event) 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/PaddleSeg/paddleseg/datasets/dataset.py", line 155, in getitem data = self.transforms(data) File "/home/aistudio/PaddleSeg/paddleseg/transforms/transforms.py", line 68, in call data['label'] = np.asarray(Image.open(data['label'])) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/PIL/Image.py", line 3148, in open "cannot identify image file %r" % (filename if filename else fp) PIL.UnidentifiedImageError: cannot identify image file 'custom_dataset/labels/00000004.json'

------------Environment Information------------- platform: Linux-5.4.0-104-generic-x86_64-with-debian-stretch-sid Python: 3.7.4 (default, Aug 13 2019, 20:35:49) [GCC 7.3.0] Paddle compiled with cuda: False GCC: gcc (Ubuntu 7.5.0-3ubuntu1~16.04) 7.5.0 PaddleSeg: 2.6.0 PaddlePaddle: 2.3.2 OpenCV: 4.1.1

htlbayytq avatar Sep 03 '22 03:09 htlbayytq

根据报错信息可以看出图片读取时读取了json文件,因此需要查看train.txt,删去json等不能被PIL读取的文件名称。

shiyutang avatar Sep 05 '22 02:09 shiyutang