brandontrabucco / da-fusion

Effective Data Augmentation With Diffusion Models
MIT License
221 stars 18 forks source link

Little mistake alarming #8

Closed tsWen0309 closed 1 year ago

tsWen0309 commented 1 year ago

When I tried to run this code in pycharm and set the relevant parameters according to the instructions. image An error occurred: "float" objective is not iterable when we tried to zip these parameters into an iterable one. image These parameters should be in list forms rather than a single int/float

brandontrabucco commented 1 year ago

Hello Flu0XeT1n,

Thanks for your interest in DA-Fusion and getting in touch! The scripts that reproduce results in our paper are located in the da-fusion/scripts folder of the repo. For example, the following snippet will run DA-Fusion on the PASCAL-based task:

python train_classifier.py --logdir pascal-baselines/textual-inversion-1.0-0.75-0.5-0.25 \
--synthetic-dir "aug/textual-inversion-1.0-0.75-0.5-0.25/{dataset}-{seed}-{examples_per_class}" \
--dataset pascal --prompt "a photo of a {name}" \
--aug textual-inversion textual-inversion textual-inversion textual-inversion \
--guidance-scale 7.5 7.5 7.5 7.5 \
--strength 1.0 0.75 0.5 0.25 \
--mask 0 0 0 0 \
--inverted 0 0 0 0 \
--probs 0.25 0.25 0.25 0.25 \
--compose parallel --num-synthetic 10 --synthetic-probability 0.5 \
--num-trials 8 --examples-per-class 1 2 4 8 16

Note that when using textual inversion, tokens for each class need to be extracted first, which we have released here: https://drive.google.com/drive/folders/1JxPq05zy1_MGbmgHfVIeeFMjL56Cef53?usp=sharing

When calling train_classifier.py with --guidance-scale and --strength the Argparse package automatically converts passed values into a list available in the scripts as args.guidance_scale and args.strength. We set the default value for these as None to encourage users to choose the values that work best for their individual use-cases.

As for why these are a list, we found using a pool of multiple augmentations with different parameters and intensities to work better than just one augmentation. If you pass --guidance-scale 2.5 7.5 and --strength 0.2 0.7 two augmentations will be constructed by "zipping" together the settings you passed in the command line. At inference time, one augmentation is sampled from this list to be applied to your images (https://github.com/brandontrabucco/da-fusion/blob/main/semantic_aug/augmentations/compose.py#L38).

Let us know if you have additional questions about how the code and method work!

-Brandon