NVlabs / stylegan3

Official PyTorch implementation of StyleGAN3
Other
6.28k stars 1.1k forks source link

dataset_tool raise Value Error: not enough image data? #637

Open yellowAcute opened 3 months ago

yellowAcute commented 3 months ago

I am using a dataset for infrared image dim-small aircraft target to train a model by the stylegan3 code. The datasets are infrared images. I want to use dataset_tool.py for data preprocessing on the dataset. But it can't work when I run the code. The information is followed. error: root@interactive74491:/opt/data/private/stylegan3# python3 dataset_tool.py --source raw_datasets/infrared_img.zip --dest /pre_datasets/infrared_256x256.zip --transform=center-crop --resolution=256x256 2%|██▉ | 399/16491 [00:01<01:06, 241.86it/s] Traceback (most recent call last): File "dataset_tool.py", line 465, in convert_dataset() # pylint: disable=no-value-for-parameter File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 754, in invoke return __callback(args, *kwargs) File "/usr/local/lib/python3.6/dist-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), args, **kwargs) File "dataset_tool.py", line 421, in convert_dataset img = transform_image(image['img']) File "dataset_tool.py", line 235, in center_crop img = PIL.Image.fromarray(img, 'RGB') File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2670, in fromarray return frombuffer(mode, size, obj, "raw", rawmode, 0, 1) File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2613, in frombuffer return frombytes(mode, size, data, decoder_name, args) File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 2546, in frombytes im.frombytes(data, decoder_name, args) File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 833, in frombytes raise ValueError("not enough image data") ValueError: not enough image data

What can I do about that? Thanks for helping me solve the problem.

Neilstid commented 3 months ago

Hi,

Here are 2 relative topics that may help you to solve your issue: https://github.com/NVlabs/stylegan3/issues/211 https://stackoverflow.com/questions/8328198/pil-valueerror-not-enough-image-data

To solve you will have to slightly modify the image loader in order to PIL to load the image. I Hope it will help you :)