fyu / lsun

LSUN Dataset Documentation and Demo Code
531 stars 175 forks source link

Failed to export Image #22

Open stm233 opened 5 years ago

stm233 commented 5 years ago

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)
pkuanjie commented 5 years ago

same problem, waiting for the solution

tlvu2697 commented 5 years ago

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.

i-chaochen commented 4 years ago

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

aviadpinis commented 4 years ago

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

Tenoke commented 4 years ago

Fixed in this PR.