Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to export Image #22

Open
stm233 opened this issue Jun 5, 2019 · 5 comments
Open

Failed to export Image #22

stm233 opened this issue Jun 5, 2019 · 5 comments

Comments

@stm233
Copy link

stm233 commented Jun 5, 2019

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
Copy link

same problem, waiting for the solution

@tlvu2697
Copy link

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
Copy link

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

@aviadpinis
Copy link

Show in #11 (comment).

@Tenoke
Copy link
Contributor

Tenoke commented Mar 23, 2020

Fixed in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants