dorarad / gansformer

Generative Adversarial Transformers
MIT License
1.33k stars 149 forks source link

Custom Dataset Error #13

Closed Iceofsky closed 3 years ago

Iceofsky commented 3 years ago

Hi! Thank you for the amazing work!

I encountered a problem when preparing a custom dataset from a custom directory.

  File "prepare_data.py", line 211, in <module>
    run_cmdline(sys.argv)
  File "prepare_data.py", line 208, in run_cmdline
    prepare(**vars(args))
  File "prepare_data.py", line 156, in prepare
    print(misc.bold("Preparing the {} dataset...".format(c.name)))
AttributeError: 'dict' object has no attribute 'name'

I've followed the instruction in using the following commands, replacing the default values with my own values:

python prepare_data.py --task <dataset-name> --images-dir <source-dir> --format png --ratio 0.7 --shards-num 5

However, it seems that there is no name attribute in this command and the dictionary passed by specifying a custom task name lacks some keys.

Any tips will be helpful!

profour commented 3 years ago

I ran into this same issue. I was able to fix it by wrapping a raw dict with "EasyDict" in prepare_data.py here.

c = catalog.get(task, EasyDict({ "local": True, "name": task, "dir": images_dir, "ratio": ratio, "process": formats_catalog.get(format) }))

I also had to move another line referencing "c.filename" since that is not defined for custom datasets here. I simply moved that line inside the if "local" check below it.

Iceofsky commented 3 years ago

Thank you! That solved the issue!

dorarad commented 3 years ago

Will make sure to incorporate the changes into the codebase so that there will be no need for a workaround!

dorarad commented 3 years ago

Alright added in those changes to the repository, thanks @profour !