当前位置:网站首页>Use cyclegan to train self-made data sets, popular tutorials, and get started quickly
Use cyclegan to train self-made data sets, popular tutorials, and get started quickly
2022-07-25 07:25:00 【Saga】
The use of CycleGAN Training your own data sets , The tutorial example here is mainly the zebra changing into a horse given on the official website , Horses change into zebras , Mutual transformation between two different domains . The tutorial provides the source code package provided by the official website and the source code package debugged and optimized by myself , You can download and use according to your own situation , It is recommended that learners download the source code package provided by me , You can take fewer detours , Follow my tutorial , It can be used for faster hands-on training .
Catalog
One 、 Download of source package
The official source package download link : Add link description

Download link of supporting tutorial source package : Add link description Extraction code :96as
Download the source package of the supporting tutorial, and see the sample paper after decompression :

notes : If you download the children's shoes with the source code package provided on the official website , Create two files in the root directory after downloading , Namely :checkpoints file ( Used to store the trained model weight file ) and results file ( Used to store the test results ).
Two 、 Install the necessary library files for training
Python The version of 3.7 perhaps 3.8 Fine .

3、 ... and 、 Prepare the dataset
Prepare the dataset
Data sets can be self prepared , You can also download the official website , The link to download the dataset provided on the official website is : Add link description , As shown in the sample paper below , Open the link and click directly to download the data set , In the source code package I provide , I've downloaded horse2zebra.zip, The following tutorials are also based on this data set .

After downloading and extracting, copy the file to the root directory datasets In file , as follows :

See the sample paper in the training set below , If you use your own data set of children's shoes , Put the images of two different domains , Copy to the corresponding test set and training set respectively .

The following is a supplementary explanation of the corresponding A Domain ,B The category corresponding to each field :

Four 、 Training data set
1、 Configure training files
Before formal training , You need to configure training files in the compiled software , The configuration method I provide here is in Pycharm Compiling software , The configuration method of other compiled software is similar , The specific configuration method is shown below :
(1) Run it first train.py file , At this time, there will be an error prompt , Prompt that you need to configure training files , as follows :

The prompt of error reporting is as follows :error: the following arguments are required: --dataroot

(2) open Run The drop-down menu for , Click on Edit Configurations, as follows :


As shown in the figure above , Enter the following commands in the open edit box and click OK You can add a training Profile :

2、 Modification of training parameters
The following parameters of children's shoes can be modified according to their computer configuration
(1) Number of training rounds epoch, See the following for the modified position :

(2) Number of pictures fed at a time , namely batch_size Modification of , because CycleGAN The network is particularly complex , Training takes up a lot of video memory , Generally speaking, it is suggested to change the computer configuration to 1 Can , If your computer's video memory is 8G, The parameter is changed to 2, See below :

The following figure shows the usage of my own computer video memory , My computer video memory is 8G,batch_size Parameter is 2, Please refer to my computer configuration and modify the training parameters by yourself :

3、 Start training
After the above steps are ready Terminal Enter the following command in the console to start the training , as follows :
python train.py --dataroot ./datasets/horse2zebra --name horse2zebra_cyclegan --model cycle_gan

The following sample paper after entering , It means that you are training normally :

4、 Visualize the training process
Use visdom Visualize the training process . Install well visdom After this library , Enter the folder where the library is located , Open file server.py file , Comment the code in one line , Prevent each opening visdom Automatically connect to the Internet to update , See below :


4.1 start-up visdom
Enter the virtual environment first , After entering the following command , Copy the output URL to the browser and you can watch it in real time CycleGAN The prediction result of the network , You can also see in real time loss Value transformation , See below :
python -m visdom.server


5、 ... and 、 Test the trained model
1、 Configure test files
The training above is very long , After all the training, you can start to test the trained model , The model trained above , Stored in the root folder checkpoints in , as follows :

Similar to the above method , Configure test files , First run the following test.py file , There will also be an error prompt , as follows :


Start configuring test files :



Copy the weight file to the new folder horse2zebra_pretrained in , And change the name of the copied weight file to latest_net_G.pth, as follows :

2、 Start testing
stay Terminal Enter the following command in the console , And enter the car to start the test , as follows :
python test.py --dataroot datasets/horse2zebra/testA --name horse2zebra_pretrained --model test --no_dropout

The following sample paper shows that the test is completed , The final results of the test will be saved to the root directory results In this folder , See below :

The above is the use of CycleGAN Network training own data set , And test the process of the final model .
6、 ... and 、 Test the model weight given by the official
Of course, some children's shoes can also use the officially trained model weight file if they are too lazy to train , The link to download the official model weight file is : Add link description , as follows :
Directly click download and copy to the root directory checkpoints Under the document , Create a new folder , Then copy the weight file into the new folder , as follows :
Modify before the final test test.py Configuration file for , The specific operation is the same as above , as follows :

Last in Terminal Enter the following command in the console and press enter , You can test the training results of the model weight , The image results of the final test are also saved in the root directory results In the folder , See below :
python test.py --dataroot datasets/horse2zebra/testA --name horse2zebra.pth_pretrained --model test --no_dropout


7、 ... and 、 summary
The above is the use of CycleGAN Training your own data sets , A quick and popular tutorial , It also provides the method of directly downloading the model weight file provided by the official , I hope the tutorial I summarized can help you get started quickly , thank you !
边栏推荐
- Summary of learning notes of deep learning application development (II)
- Oracle19采用自动内存管理,AWR报告显示SGA、PGA设置的过小了?
- [programmer 2 Civil Servant] IV. common problems
- Default value of dart variable
- Simulation Implementation of list
- Learn no when playing 10. Is enterprise knowledge management too boring? Use it to solve!
- JS note 17: the whole process of jest project configuration of typescript project
- Completely replace the redis+ database architecture, and JD 618 is stable!
- Growth path - InfoQ video experience notes [easy to understand]
- Have you got the advanced usage of pytest?
猜你喜欢

js无法获取headers中Content-Disposition

leetcode刷题:动态规划06(整数拆分)

Before Oracle 19C migration, how important is it to do a good job of rat playback test?

QT6 with vs Code: compiling source code and basic configuration

Gan series of confrontation generation network -- Gan principle and small case of handwritten digit generation

"Game illustrated book": a memoir dedicated to game players

How to use network installation to deploy multiple virtual servers in KVM environment

30 times performance improvement -- implementation of MyTT index library based on dolphin DB

第一启富金怎么样

OpenAtom XuperChain 开源双周报 |2022.7.11-2022.7.22
随机推荐
Beijing internal promotion | Microsoft STCA recruits nlp/ir/dl research interns (remote)
Million level element optimization: real-time vector tile service based on PG and PostGIS
Introduction to cesium
paddlepaddle 34 调整模型的layer结构与forward流程(实现layer的增删改与forward的修改)
YUV player
Matlab self programming series (1) -- angular distribution function
Leetcode skimming: dynamic programming 06 (integer splitting)
Enable the free pan domain SSL certificate for kubesphere cluster and realize the automatic update and distribution of certificates
List derivation
About --skip networking in gbase 8A
10 key points and 5 measures for good project management
关于GBase 自动关闭连接问题
Leetcode118. Yanghui triangle
[programmer 2 Civil Servant] III. resource collection
Luo min from qudian, prefabricate "leeks"?
从ACL 2022 Onsite经历看NLP热点
Pads export Gerber file
[semidrive source code analysis] [drive bringup] 39 - touch panel touch screen debugging
Completely replace the redis+ database architecture, and JD 618 is stable!
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (V)