当前位置:网站首页>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 !
边栏推荐
- The idea of the regular crawler of the scratch
- [programmer 2 Civil Servant] IV. common problems
- 【程序员2公务员】关于体制调研的一些常见问题总结
- CTF Crypto---RSA KCS1_ Oaep mode
- RPC通信原理与项目技术选型
- Offline base tile, which can be used for cesium loading
- runtimecompiler 和 runtimeonly是什么
- About --skip networking in gbase 8A
- RPC communication principle and project technology selection
- [semidrive source code analysis] [drive bringup] 39 - touch panel touch screen debugging
猜你喜欢

钉钉最新版,怎么清除登录手机号历史记录数据

Robot Framework移动端自动化测试----01环境安装

数据提交类型 Request Payload 与 Form Data 的区别总结

Talk about practice, do solid work, and become practical: tour the digitalized land of China
![[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (V)](/img/cf/44b3983dd5d5f7b92d90d918215908.png)
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (V)

Leetcode skimming: dynamic programming 06 (integer splitting)
![[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!](/img/11/24f92b4362026ec2c01492d195560b.png)
[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!

Oracle19 adopts automatic memory management. The AWR report shows that the settings of SGA and PGA are too small?

BOM概述

Paper reading: UNET 3+: a full-scale connected UNET for medical image segmentation
随机推荐
Bingbing's learning notes: classes and objects (Part 1)
Summary of differences between data submission type request payload and form data
Devops has been practiced for many years. What is the most painful thing?
Leetcode skimming: dynamic programming 06 (integer splitting)
Scavenging vultures or woodpeckers? How to correctly understand short selling
Nailing the latest version, how to clear the login phone number history data
QT学习日记20——飞机大战项目
What are runtimecompiler and runtimeonly
leetcode刷题:动态规划06(整数拆分)
Xinku online | cnopendata shareholder information data of A-share listed companies
微信小程序wx.request接口
Delete in elasticserach_ by_ What is the mechanism of query?
Leetcode118. Yanghui triangle
With apple not making money, the 2trillion "fruit chain" abandons "fruit" and embraces "special"
Wechat applet wx.request interface
Learn no when playing 10. Is enterprise knowledge management too boring? Use it to solve!
[computer explanation] what should I pay attention to when I go to the computer repair shop to repair the computer?
新库上线| CnOpenDataA股上市公司股东信息数据
JS cannot get content disposition in headers
[programmer 2 Civil Servant] summary of some common problems about system research