lsun icon indicating copy to clipboard operation
lsun copied to clipboard

Failed to export Image

Open stm233 opened this issue 5 years ago • 5 comments

In my folder: bedroom_val, there are data.mdb and lock.mdb.

Then I use

export_images('./bedroom_val', './data',True)

result:

Traceback (most recent call last):
  File "/Users/pegasus/Downloads/lsun-master/data.py", line 90, in <module>
    export_images('./bedroom_val', './data',True)
  File "/Users/pegasus/Downloads/lsun-master/data.py", line 48, in export_images
    image_out_path = join(image_out_dir, key + '.webp')
TypeError: can't concat str to bytes

Then i added key.decode() where image_out_path = join(image_out_dir, key.decode() + '.webp')

However, there still has an error:

Traceback (most recent call last):
  File "/Users/pegasus/Downloads/lsun-master/data.py", line 90, in <module>
    export_images('./bedroom_val', './data',True)
  File "/Users/pegasus/Downloads/lsun-master/data.py", line 50, in export_images
    fp.write(val)
TypeError: write() argument must be str, not bytes

I don't know how to fix this problem where

  with open(image_out_path, 'w') as fp:
      fp.write(val)

stm233 avatar Jun 05 '19 06:06 stm233

same problem, waiting for the solution

pkuanjie avatar Jul 25 '19 09:07 pkuanjie

The output file needs to be written in binary mode. Try changing line 48 from

with open(image_out_path, 'w') as fp:

to

with open(image_out_path, 'wb') as fp:

Hope it helps you.

tlvu2697 avatar Jul 29 '19 19:07 tlvu2697

@tlvu2697 do you know how to convert it to jpg?

i-chaochen avatar Dec 18 '19 11:12 i-chaochen

Show in https://github.com/fyu/lsun/issues/11#issuecomment-567390245.

aviadpinis avatar Dec 19 '19 08:12 aviadpinis

Fixed in this PR.

Tenoke avatar Mar 23 '20 12:03 Tenoke