[MYAI Studio SDK] Image-GAN-Compression-PyTorch-Jupyter

Image-GAN-Compression-PyTorch-Jupyter 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.

Gan compress cyclegan.png

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.

GAN Compression pix2pix.png

This SDK is built in AppForAI - AI Dev Tools.

Purchase license separately: USD 600, permanent authorization, single APP authorization, single machine authorization, one-year activation, one-year download, one-year update, one-year email technical support.

Further Reading

1.
MYAI Studio for Windows

2.
MYAI Studio for Linux

3.
AI PC

Thanks for the support from our clients

National Taiwan University, National Tsing Hua University, National Yang Ming Chiao Tung University, National Cheng Kung University, Taipei Medical University, Kaohsiung Medical University, National Taipei University of Nursing and Health Sciences, China Medical University, National Chung Hsing University, National Central University, National Sun Yat-sen University, National Chung Cheng University, National Chi Nan University, National Chiayi University, National Ilan University, National Taipei University of Education, National United University, Tamkang University, Feng Chia University, Chang Gung University, I-Shou University, Shih Chien University, Tatung University, Chung Yuan Christian University, Soochow University, Tzu Chi University, Tzu Chi University of Science and Technology, National Taiwan University of Science and Technology, National Taipei University of Technology, National Taichung University of Science and Technology, National Yunlin University of Science and Technology, National Chin-Yi University of Technology, National Formosa University, National Pingtung University of Science and Technology, National Kaohsiung University of Science and Technology, Chaoyang University of Technology, Ming Chi University of Technology, Minghsin University of Science and Technology, Southern Taiwan University of Science and Technology, Asia Eastern University of Science and Technology, China University of Technology, National Taiwan Sport University, National Defense University, Republic of China Naval Academy, Republic of China Army Academy, Luodong Senior High School, Gushan Senior High School, Kaohsiung Girls Senior High School, National Taiwan University Hospital, National Cheng Kung University Hospital, Taipei Veterans General Hospital, Chang Gung Memorial Hospital, Tzu Chi Hospital, E-Da Hospital, Far Eastern Memorial Hospital, Lien Hsin International Hospital, National Chung-Shan Institute of Science and Technology, Armaments Bureau, Ministry of National Defense, Ministry of Justice Investigation Bureau, Industrial Technology Research Institute, Institute for Information Industry, Institute of Nuclear Energy Research, Atomic Energy Council, Endemic Species Research Institute, Council of Agriculture, Institute of Labor, Occupational Safety and Health, Ministry of Labor, Taiwan Textile Research Institute, Metal Industries Research & Development Centre, Taiwan Instrument Research Institute, Automotive Research & Testing Center, Chunghwa Telecom, Taiwan Water Corporation, Taiwan Semiconductor Manufacturing Company, United Microelectronics Corporation, Nanya Technology Corporation, Winbond Electronics Corporation, Wafer Works Corporation, Grandtop Optoelectronics, AU Optronics, Innolux Corporation, HannStar Display Corporation, Formosa Plastics Corporation, Formosa Petrochemical Corporation, Formosa Technologies Corporation, Nan Ya Plastics Corporation, Formosa Chemicals & Fibre Corporation, CPC Corporation, Taiwan, Logitech, Elan Microelectronics Corporation, Lextar Electronics Corporation, Darfon Electronics Corporation, Sercomm Corporation, EZconn Corporation, Foxconn Technology Group, WPG Holdings, World Peace Industrial Co., Ltd., Mirle Automation Corporation, Shuttle Machinery Co., Ltd., ChipMOS Technologies Inc., Simplo Technology Co., Ltd., Primax Electronics Ltd., Intesys Technology, Feng Hsin Iron & Steel Co., Ltd., China Ecotek Corporation, Zhu Sheng Technology, Advantech Co., Ltd., Stark Technology Inc., Hong Teng Technology, MiTAC International Corp., SYNNEX Technology International Corp., Allion Labs, Inc., Co-in International, Feng An Auto, Hong Hu International, Blue Ocean Intelligence, TOPPAN IDGATE Co., LTd., Far EasTone Telecommunications, SYSTEX Corporation, Cooler Master, Lion Travel, Beigang Wude Temple, Xiluo Fuxing Temple, etc.