Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the failure model of generating Pok é mon with pytorch and GAN?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

How to generate the failure model of Pok é mon with pytorch and GAN. In order to solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Preface

Pok é mon is already a household name in animation, and today we will confirm whether it is possible to use deep learning to automatically create a new Pokemon for him.

I finally succeeded in using the generate confrontation Network (GAN) to generate an image similar to Pokemon, but this image doesn't look like Pok é mon.

Although this attempt failed, I think others may like the process, so share it now.

GAN generates countermeasure network

I don't want to spend a lot of time talking about what GAN is, but the image above is a very simple explanation.

Two networks are trained-the discriminator and the generator. The generator learns how to absorb random noise and generate images that look like images from the training data. It sends the generated image to the discriminator network, which is trained to distinguish the real image from the generated image.

The generator is optimized to better deceive the discriminator, and the discriminator is optimized to better detect the generated image. Therefore, the two of them made progress together.

data

So my assumption is that I can use real Pok é mon images as a training set to train GAN. The result will be a generator that will then be able to create novel Pok é mon!

My first challenge was to find an image of Pok é mon. Fortunately, the Kaggle dataset was rescued!

Someone has thought of a similar idea, and although it sounds like he didn't have much success in generating new Pokemon images, he decided to upload them to the Kaggle dataset because he took the time to collect them. It saves me a lot of time.

Let's take a look at this dataset:

This is a picture of garlic Wang Bamao frog seed, the size is 256mm 256.

Now that you have the data, the next step is to select the type of GAN to use. There may be hundreds of variants of GAN, but you can see good results with DCGAN in the past.

DCGAN removes all fully connected layers from the neural network, uses transpose convolution for up-sampling, and replaces the maximum pool with convolution span (among other things).

I like DCGAN because they seem to be more robust than other GAN I've tried, so it's easier to train without major adjustments to hyperparameters.

In fact, DCGAN is so popular that the PyTorch example works well. Just as important, their examples can read input directly from a folder. So, with the following command, I can start training my GAN:

Python main.py-dataset folder-dataroot / pokemon/-cuda-niter 10000-workers 8

This command reads the image from the folder, runs it on GPU with eight working programs to load the data, and runs 10000 iterations.

It turns out that this problem requires 10000 iterations, but I want to see how far I can push. Let's see!

Result

The first step starts with an unknown network, so all that is generated is noise:

Each box is a 64 x 64 pixel image that attempts to generate Pok é mon from our generator. Because our grid is 8 x 8, we try to generate 64 different Pok é mon. I reduced the image to 64 x 64 because the algorithm became unstable when trying to generate a larger image.

After 50 iterations, it's kind of interesting.

After 150 iterations, the image became clear.

After 3700, some good pictures will appear. Since then, it has tended to produce worse results:

None of these look like Pok é mon at all!

But please shrink the browser to about 25%, and then check it again. In the distance, they look strikingly similar to real Pok é mon.

Why? Because we are training 64 x 64 images, the discriminator is easily confused by images with shapes and colors similar to Pokemon, so the generator does not need to be improved.

Next step?

The obvious next step is to train a higher resolution GAN. In fact, I have made some attempts at this.

The first attempt is to rewrite the PyTorch code to zoom to a 256 x 256 image. The code worked, but DCGAN crashed and I couldn't train steadily. The main reason is that there are only about 800 images. And, although I have made some data expansion, it is not enough to train a higher resolution DCGAN.

Then I tried to use the relativistic GAN, which has been successfully trained for high-resolution data with smaller data sets, but has not been able to work properly.

At present, the problem should be on the data, the amount of data is too small, or can not meet the needs of training. But I will continue to try some other ideas to produce a higher resolution Pokemon, and if I have the need to work, I will release the technology I use.

This is the answer to the question about how to generate the failure model of Pok é mon with pytorch and GAN. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report