5 minutes to generate CryptoPunks style images with GANs

In 2021, NFT digital artworks and digital collections will quickly come out of the circle. In this wave, the “CryptoPunks” project established in 2017 has become the most valuable due to its popularity among collectors and constantly refreshed transaction prices. One of his collections, and has become a symbol of the status of pioneer investors and art collectors.

minutes

Image credit: larvalabs

The success of several NFT digital artwork projects has also brought AI-generated digital artwork to the forefront. In this “wave out of the circle”, many artists choose to use AI technology as a tool for image creation, and finally cast artworks into NFTs. The possibility of using AI technology to create NFT digital artworks has been fully explored. AL/ML work related to art generation focuses on the creation of artistic styles, and many teams and individuals also pay attention to artworks, generating works of specific styles in “batches” through Generative Adversarial Networks (GANs).

Recently, a project called “CryptoPunks GAN” was published on Github for generating a simple SN-GAN for CryptoPunks, project address: https://github.com/teddykoker/cryptopunks-gan. This project was done in Python, and we reproduced it through Moment Pool Cloud http://www.matpool.com. Moment Pool Cloud provides solutions for the Metaverse. Creators can use the platform to easily train and deploy their AI models, speeding up processes in the Metaverse, such as NLP virtual humans and image content generation. This time, machine learning is used to generate the recurrence of the CryptoPunks project. The process of getting started is very simple. It does not require any installation and debugging. When you open the interface, you can feel the creative process of generative art in the cloud.

Analyze project dependencies, rent machines

Analyze project dependencies

First of all, through the requirements.txt file of the open source project, we know that the project mainly needs Pytorch1.10.2 and CUDA11.3 environment, and also needs third-party packages such as pandas and Pillow. If it is installed locally, we still need to spend a certain amount of time. , but we don’t need these complicated steps.

minutes

Analyze project dependencies

We enter Moment Pool Cloud. If you haven’t registered an account, you can register an account first. New registered users who follow and bind Moment Pool Cloud WeChat Official Account will receive a 5 yuan experience fee, which will be directly deducted when renting the machine. (It will be available later).

Rent a suitable machine in Mochi Cloud

In the host market of Moment Pool Cloud, we can choose the machine we need to use. Here we choose the cheapest NVIDIA Tesla K80 (tested, code model and training can be used).

minutes

Choose a machine

After clicking the rent button, we can configure the machine:

  • 1 Select the base image, we directly search for Pytorch1.10
  • 2 It is found that there are related images, and other dependencies such as CUDA11.3 also meet the requirements, click to select
  • 3 After selecting the image, we can perform other configurations, such as: VNC function opening, public key settings, custom ports in advanced options, etc. (you can also ignore these functions for the first time)

minutes

select mirror

After setting the basic environment of the machine, we can click to place an order. (As mentioned above, if you are a new user, the experience fee obtained after binding the Moment Pool Cloud WeChat Official Account can be directly deducted when the machine is released)

Download code, data and models

After renting the machine, we choose the easiest way to use it and directly click the JupyterLab connection on the rental interface to quickly use the server.

minutes

Open JupyterLab

After entering the JupyterLab page, we first click Terminalto enter the terminal, and enter the following command.

minutes

Open Terminal

5vz9hs5X7UW4U3YnlUO1sCb6Kzht39kGotNgBSKJ.png

We only need to copy and paste the above code. When Checking out files: 100% appears, it means that the download of the open source project CryptoPunks-GAN project is successful, and you can go to the next step.

minutes

Checking out files: 100%

We can understand the meaning of entering this code just now, it represents

  • First enter the /mntdirectory (moment pool cloud network disk mount directory)
  • Create a new folder MyCodeand enter the folder (for storing project files)
  • git clone to download open source projectscryptopunks-gan

Using the model and training

Test with pretrained model

We enter the cryptopunks-ganproject directory. The specific way is to find the folder named mnt

minutes

mnt folder

Go to MyCode, then go to cryptopunks-gan

minutes

path

Then click +to create a new Launcher in the upper left corner, and click in Notebook myconda. You can create a new jupyter notebook file.

minutes

New ipynb steps

We can use the pre-trained model to test the use first, and the test code has been officially provided to us.

minutes

You can copy all the code below directly, or run it piece by piece like I did

kAR9wEDailECVAX1rPbbt6LKA1nx7yR7l3Pp36mi.png

The run button is as follows

minutes

run button

After successful operation, a file will be generated in the project directory punks.png.

minutes

punks.png

We can directly click to view the pre-training results

minutes

Train the model

According to the tutorial, in addition to using the pre-trained model, we can also train the model, the training code is in the train.pyfile in the project directory.

minutes

We’re back in JupyterLab’s Terminal

minutes

Open Terminal

Enter the following command (first enter the project directory, then run train.py):

4o7BNpvHBGuiaodLX6givEVYJNnKT1o1NthHu8Ko.png

minutes

working process

This process is relatively long, and it is expected to take about 1 hour. After the training is completed, a outdirectory will be generated in the project directory by default, which will store the trained weight files and sample image files. The image that finally completes the training is the one with the largest serial number, which is the file numbered 999 in this case.

minutes

out directory

At this point, go back to “My Network Disk”, and you can see the out folder, where the training process and result pictures just now are in it.

minutes

my network disk

During the training process, you can also view the machine monitoring and see the usage of the machine’s GPU and memory.

minutes

machine usage

release the machine

When your code is finished and you don’t need to use the machine, you can choose to release the machine.

On the machine rental page, you can see 释放机器the button, and in the 更多button you can also see the 保存环境function.

minutes

Free and save environment

If you have installed some other packages in the basic environment and want to continue to use it next time, you can choose to save the environment, and the saved environment will be stored in your network disk.

If you don’t need to save the environment, just click it 释放机器.

The following part is the image generated after epoch training:

minutes

The final completion diagram of the training is as follows

minutes

GANs generate graphs

About GANs

Generative Adversarial Networks (GANs) were first proposed in a 2014 paper by Ian Goodfellow et al., which are implemented by using both a generative and a discriminative model, where the two models compete with each other to train images. This process can be explained simply. The role of the generative model is similar to that of a person who constantly creates a fake “Mona Lisa”. During the process of creation, he has to continuously improve the similarity with the real painting. The discriminant model is similar to the identification of the real painting. Teacher, who is responsible for identifying and confirming fake paintings. The two men competed with each other, each improving their respective methods of creation and identification, until the fake paintings were indistinguishable from the real ones.

The algorithm used in the CrypoPunks GAN project is SN-GAN, that is, Spectral Normalization for Generative Adversarial Network. The training process is more stable and easier to converge. The content of the literature can be referred to https://arxiv.org/abs/1802.05957 .

Posted by:CoinYuppie,Reprinted with attribution to:https://coinyuppie.com/5-minutes-to-generate-cryptopunks-style-images-with-gans/
Coinyuppie is an open information publishing platform, all information provided is not related to the views and positions of coinyuppie, and does not constitute any investment and financial advice. Users are expected to carefully screen and prevent risks.

Like (0)
Donate Buy me a coffee Buy me a coffee
Previous 2022-03-28 09:28
Next 2022-03-28 09:30

Related articles