Jupyter-Image-GAN-Compression-PyTorch is to perform style conversion after compressing the GAN model. The compressed model not only reduces the amount of calculation, reduces the size of the model, but also maintains a certain degree of accuracy. This solution can be applied to the style conversion of horses or shoes.

## [Instruction]

There are two ways of style conversion:

(1) CycleGan compression. The process of turning the horse in the image into a zebra is as follows:

Train the original size CycleGan model -> test the original size CycleGan model -> distill the original size CycleGan model -> test the distilled model -> train the supernet with the distilled model -> test the supernet model -> compress the supernet model -> Test the compressed model

(2) Compression of pix2pix. The process of converting the outline drawing of the shoe into a sample drawing of the shoe is as follows:

Train the original size pix2pix model -> test the original size pix2pix model -> distill the original size pix2pix model -> test the distilled model -> train the supernet with the distilled model -> compress the supernet model -> Test the compressed model

Note: Please confirm whether the pip numpy version is 1.18.1 before running.

CycleGan:

1. 1_train_CycleGan.ipynb

Train the CycleGan model. The data set is "horse2zebra", images of horses and zebras.

2. 2_test_CycleGan_model_mobile.ipynb

Test the CycleGan model trained at point 1. If the CycleGan model test result is not good, it will affect the subsequent model training, please go back to the first point and retrain.

3. 3_train_CycleGan_distill.ipynb

Distill the model from the CycleGan model at point 1.

4. 4_test_CycleGan_distill_model.ipynb

Test the distillation model of Cycle Gan at point 3. If you think the result is not good, please go back to point 3 and retrain.

5. 5_train_CycleGan_supernet.ipynb

Train the supernet with the distilled CycleGan model and the original CycleGan model.

6. 6_test_CycleGan_supernet_model.ipynb

Test Point 5 CycleGan's supernet model. If you think the result is not good, please go back to point 3 and retrain.

7.7_model_compression_CycleGan.ipynb

Use CycleGan's supernet model for training to produce a compressed model.

8. 8_inference_CycleGan_compression.ipynb

Test the compressed CycleGan model.

real_A is the image of horse, fake_B is the image of horse converted into zebra.

pix2pix:

1. 1_train_Pix2pix.ipynb

Train the pix2pix model. The data set is "edges2shoes-r", the image of the shoe outline.

2. 2_test_Pix2pix_model_mobile.ipynb

Test the pix2pix model trained at point 1. If the pix2pix model test result is not good, it will affect the subsequent model training, please go back to the first point and retrain.

3. 3_train_Pix2pix_distill.ipynb

Distill the model from the pix2pix model at point 1.

4. 4_test_Pix2pix_distill_model.ipynb

Test the distillation model of pix2pix at point 3. If you think the result is not good, please go back to point 3 and retrain.

5. 5_train_Pix2pix_supernet.ipynb

Train the supernet with the distilled pix2pix model and the original pix2pix model.

6. 7_model_compression_Pix2pix.ipynb

Use pix2pix 's supernet model for training to produce a compressed model.

7. 8_inference_Pix2pix_compression.ipynb

Test the compressed pix2pix model.

real_A is the contour image of the shoe, fake_B is the contour image of the shoe converted into a sample image of the shoe, and real_B is the real sample image of the contour image of the shoe.

# Contact Us and How to Buy

Welcome to contact us. Please refer to the following link:

https://www.leaderg.com/article/index?sn=11059