<jupyter_start><jupyter_text>Take a look at the original (junyanz) [repository](https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix) for more information  Install<jupyter_code>!git clone https://github.com/eayumba/pytorch-CycleGAN-and-pix2pix
import os
os.chdir('pytorch-CycleGAN-and-pix2pix/')
!pip install -r requirements.txt<jupyter_output><empty_output><jupyter_text>**Don't forget to create the ./mycheckpoints folder within the cloned repo.**  DatasetsUse your own dataset by creating the appropriate folders and adding in the images.-   Create a dataset folder under `/datasets` for your dataset.-   Create subfolders `testA`, `testB`, `trainA`, and `trainB` under your dataset's folder. Place any images you want to transform from a to b (cat2dog) in the `testA` folder, images you want to transform from b to a (dog2cat) in the `testB` folder, and do the same for the `trainA` and `trainB` folders.  **Pretrained Models**Add your own pretrained model to `./checkpoints/{NAME}_pretrained/latest_net_G.pth`- Alternatively, you can upload the formatted mycheckpoints/modelName folder with the latest_net_G_A.pth and latest_net_G_B.pth generator models files within the modelName folder, from which you can skip to testing, or modify train.py and train_options.py to begin improving on your pretrained model.  Training-   `python train.py --dataroot ./datasets/datasetName --name horse2zebra --model cycle_gan`Change the `--dataroot` and `--name` to your own dataset's path and model's name. Use `--gpu_ids 0,1,..` to train on multiple GPUs and `--batch_size` to change the batch size. I've found that a batch size of 16 fits onto 4 V100s and can finish training an epoch in ~90s.Once your model has trained, copy over the last checkpoint to a format that the testing model can automatically detect:Use `cp ./checkpoints/modelName/latest_net_G_A.pth ./checkpoints/modelName/latest_net_G.pth` if you want to transform images from class A to class B and `cp ./checkpoints/modelName/latest_net_G_B.pth ./checkpoints/modelName/latest_net_G.pth` if you want to transform images from class B to class A.<jupyter_code>!python train.py --dataroot ./datasets/MELSpectro --name MELSpectro --model cycle_gan
# USE THIS TO ZIP UP AND DOWNLOAD EVERYTHING RELATED TO THE TRAINED MODEL: WARNING: VERY LARGE FILE, includes 8 images from each epoch.
!zip -r ./mycheckpoints/MELSpectro.zip ./mycheckpoints/MELSpectro
# from google.colab import files
# files.download("./mycheckpoints/MELSpectro.zip")<jupyter_output><empty_output><jupyter_text>Testing-   `python test.py --dataroot datasets/modelName/testA --name modelName_pretrained --model test --no_dropout`Change the `--dataroot` and `--name` to be consistent with your trained model's configuration.> from https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix:> The option --model test is used for generating results of CycleGAN only for one side. This option will automatically set --dataset_mode single, which only loads the images from one set. On the contrary, using --model cycle_gan requires loading and generating results in both directions, which is sometimes unnecessary. The results will be saved at ./results/. Use --results_dir {directory_path_to_save_result} to specify the results directory.> For your own experiments, you might want to specify --netG, --norm, --no_dropout to match the generator architecture of the trained model.<jupyter_code>#USED TO PLACE YOUR MODEL TESTING FILES AS DESCRIBED AT THE BOTTOM OF THE TRAINING SECTION DESCRIPTION
!cp ./mycheckpoints/MELSpectro/latest_net_G_B.pth ./mycheckpoints/MELSpectro/latest_net_G.pth
!python test.py --dataroot datasets/MELSpectro/testA --name MELSpectro --model test --no_dropout
#USE THIS TO SAVE YOUR TESTING RESULTS IN A ZIP FILE IN THE ./ DIRECTORY, WHICH YOU CAN THEN DOWNLOAD FROM THE COLAB FILESYSTEM
!zip -r ./results.zip ./results<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08635312259059368, 'fraction_numerical': 0.004626060138781804, 'mean_word_length': 4.835082458770614, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '456904', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1159, 'n_words': 459, 'path': 'Our_CycleGAN.ipynb', 'repo_name': 'eayumba/pytorch-CycleGAN-and-pix2pix', 'size': '3891'}