Gan is a typical probabilistic generation model, and its core idea is to find out the statistical laws within the given observational data and to produce new data similar to the observed data based on the obtained probabilistic distribution model.
Probabilistic generation models can be used for the generation of natural images. Assuming that 10 million images are given, the build model automatically learns its internal distribution, explaining a given training picture and generating new pictures at the same time.
Compared with the large real data, the number of parameters of probabilistic generation model is much smaller than that of data. Therefore, during the training process, the generation model is forced to discover the more simple statistical laws behind the data, thus generating the data.
As the unsupervised learning of Gan has become a new technology point of deep learning, and many applications have come out, therefore, some applications of Gan are gradually studied, and the conversion between image and image is a typical application. Therefore, the technology is studied and operated.
The main reference code of this experiment is: Https://github.com/affinelayer/pix2pix-tensorflow
(1) First download data set, https://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/, from this site can download a lot of classic application data set. In this paper, only facades is chosen as the data set, because the remaining principles are the same.
(2) Conduct training
In the program pix2pix.py code, manually add the test parameters, this article only lets run 200 times.
# The parameters of the training time
# A.input_dir = "/home/ndscbigdata/work/imgdata/facades/train"
# A.mode = "Train"
# A.output_dir = "/home/ndscbigdata/work/imgdata/facades/ckt"
# a.max_epochs=200
# a.which_direction = "BtoA"
(3) Parameters for test # test
A.input_dir = "/home/ndscbigdata/work/imgdata/facades/val"
A.mode = "Test"
A.output_dir = "/home/ndscbigdata/work/imgdata/facades/facades_test"
A.checkpoint= "/home/ndscbigdata/work/imgdata/facades/ckt"
the results of the test run are as shown in the figure:
The test results screenshot is as follows: You can see the result is quite good, but if the training max_epochs set a little more, it may be better.
the specific code has been posted on GitHub: Https://github.com/ndscigdata/tensorflow-pratice