tags | license | ||||
---|---|---|---|---|---|
|
mit |
A repository of image-to-image translation models developed for the Huggan hackaton here.
Currently it supports the cyclegan architecture for image-to-image translation
Firstly, after cloning this repository, run
cd image2image
pip install .
Then, set the wandb API_KEY if you wish to log all results to wandb with:
wandb login API_KEY
If you plan on uploading the resulting models to an huggingface repository, make sure to also login with your huggingface API_KEY with the following command:
huggingface-cli login
Before starting the model training, it is necessary to configure the accelerate environment according to your available computing resource with the command:
accelerate config
After this, everything is setup to start training the image2image models
To train an image2image translation model, one must only specify the dataset names
following the huggingface dataset convention {organization_name}/{dataset_name} in the following command line args:
- --source_dataset_name
- --target_dataset_name
In order to correctly configure the training procedure, it is necessary to first launch in a shell the accelerate config command(Only needs to be done once).
Note that in order to launch multi gpu single machine training, you need to set the accelerate config with multi-gpu training and
to the question How many processes in total will you use?
Answer with the number of gpus that you intend to use
accelerate config
After this, cd into im2im/train to launch the training script as follows
Single or multi gpu training is automatically set up by accelerate by running the following command to easily start the training of the image translation model
accelerate launch --config_file ~/.cache/huggingface/accelerate/default_config.yaml \
train.py \
--source_dataset_name Chris1/GTA5 \
--target_dataset_name Chris1/cityscapes \
--batch_size 8 \
--beta1 0.5 \
--beta2 0.999 \
--channels 3 \
--checkpoint_interval 5 \
--decay_epoch 80 \
--epoch 0 \
--image_size 256 \
--lambda_cyc 10.0 \
--lambda_id 5.0 \
--lr 0.0002 \
--mixed_precision no \
--model_name cyclegan \
--n_residual_blocks 9 \
--num_epochs 200 \
--num_workers 8 \
--organization_name Chris1 \
--push_to_hub \
--sample_interval 10 \
--wandb \
--output_dir experiments
* [x] CycleGAN
* [ ] Cycada
* [ ] ...
* [ ] FID loss CycleGAN
* [ ] ...
Adapted by Christian Cancedda and inspired by Hugging Face with love ❤️# image2image