0 votes
by (20.3k points)
1 year agoIntroduction.
Marquee NFT projects like Cryptopunks and Bored Ape Yacht Club have generated hundreds of millions of dollars in revenue, and have made several of their owners millionaires.
What the aforementioned projects (and most other successful NFT projects today) have been in common is that they are PFP projects. This means that they usually are a collection of 10,000+ avatars where each avatar is unique and has a set of traits.
In this tutorial, we will show you how to generate a collection like this with custom rarities. We will be using a library created by the Scrappy Squirrels team to accomplish this. At the end of this tutorial, you would have generated your own custom avatar collection with associated metadata.
Python and pip installed on your computer.
Our library is written in Python so you will need to have this installed on your computer. You will also need pip which will install important packages for us.
Go to this website and download the latest version of Python. You do not need to know how to program (in Python or otherwise) to follow this tutorial.
An Artist (preferred but not required)
You will also need an artist who knows their way around digital art to create your own custom collection. However, this is not required to follow this tutorial. We will be providing you with certain test images to play around with.
The Scrappy Squirrels Collection.
As part of this tutorial, we will walk you through the process of creating the Scrappy Squirrels NFTs, a real project that we have launched. This tutorial (and every subsequent one) has been created as part of our roadmap goals to make NFTs and blockchains more accessible to people. Do check out our Discord for more details. (Go on, we will wait :))
The squirrels have been generated using over 85 traits. Here are a few samples.
Sample Scrappy Squirrels.
The Generation Process.
The squirrels that you see above were generated by stacking PNG images on top of one another. Although no blue-chip NFT projects describe how they generate their art, we are certain that this is what they do too. Almost every NFT avatar that you see is a set of stacked PNG images (which makes the claims that they are just JPEGs false. Checkmate, NFT critics).
Stacking Trait Images to generate the final squirrel.
Starting from the top right, if you stack every trait image clockwise, one after the other, you will end up with the image in the center. Here are few things to note:
Each trait image (and the final squirrel avatar) is of exactly the same dimension. Apart from the background trait (which is the first trait), every other trait image has a transparent background. The trait images must be stacked in order to get the correct squirrel avatar (i.e clockwise from top-right). The trait images are drawn in such a way that their positioning makes sense with respect to all other traits. We can swap any trait with another trait of the same category (for instance, a red shirt for a blue shirt). Therefore, in this case, if we had 10 traits for each category of trait, we could theoretically produce 100 million distinct squirrels.
Therefore, the artist’s job is to create multiple images of various trait categories. You can have as many or as few trait categories as you want. Do keep in mind though that the number of possible combinations increases exponentially with the number of traits categories.
In the Scrappy Squirrels project, we created 8 trait categories.
Trait Categories.
Each trait category had a varying number of trait images. For instance, we had 11 different shirts to work with.
Now, it’s your turn. You will need to decide on trait categories that you want to work with and generate trait images for each category. Make sure they satisfy the conditions mentioned above (should be of the same dimension, should be correctly positioned, etc). Also, make sure you name the trait images appropriately. What you name your image is what will appear in the metadata file.
Once you are done with this, we are now ready to use the library to generate our collection automatically! If you are not an artist (or do not have access to one), don’t worry! We have some sample images that you can play around with.
NOTE: At present, the library is only capable of handling PNG images. We will be adding support for other media types soon.
Download repository and install required packages.
Once you’ve downloaded the repository, open your Terminal or Command Prompt, and run the following command:
pip install Pillow pandas progressbar2.
Running this command will install three important Python packages that our library depends on:
Pillow: An image-processing library that will help us stack trait images. Pandas: A data analysis library that will help us in generating and saving our image metadata. Progressbar: A library that will tell us about the progress when the image generation takes place.
Add your custom assets.
In the generative-art-nft repository that you downloaded, you will see that there is an assets folder. If you have your custom trait artwork available with you, go ahead and replace the contents of this folder with your assets. In our case, our assets folder had 8 subfolders representing categories named appropriately (see above), and each subfolder had trait images of that particular category.
If you do not have custom artwork, leave the default assets folder as is.
Configure the config.py file.
This is the last (and perhaps, the most important step) before we can generate our avatar collection. Open the config.py file and fill it up according to the instructions below.
The config file consists of a single Python variable called CONFIG. CONFIG is a Python list (encapsulated by []). It contains a list of trait categories in the order that they need to be stacked. The order here is extremely important. Here is a sample configuration.
CONFIG = [ 'id': 1, 'name': 'background', 'directory': 'Background', 'required': True, 'rarity_weights': None, >, 'id': 2, 'name': 'body', 'directory': 'Body', 'required': True, 'rarity_weights': 'random' >, 'id': 3, 'name': 'eyes', 'directory': 'Expressions', 'required': True, 'rarity_weights': None >, 'id': 4, 'name': 'head_gear', 'directory': 'Head Gear', 'required': False, 'rarity_weights': None >, 'id': 5, 'name': 'clothes', 'directory': 'Shirt', 'required': False, 'rarity_weights': None >, 'id': 6, 'name': 'held_item', 'directory': 'Misc', 'required': True, 'rarity_weights': None, >, 'id': 7, 'name': 'hands', 'directory': 'Hands', 'required': True, 'rarity_weights': None, >, 'id': 8, 'name': 'wristband', 'directory': 'Wristband', 'required': False, 'rarity_weights': [100, 5, 5, 15, 5, 5, 15, 15, 5, 1] >, ]
Each trait category is represented as a Python dictionary (encapsulated by <>). All that needs to be done is define these trait category dictionaries in order in the CONFIG list.
A trait category dictionary has 5 keys that it needs. These are id, name, directory, required, and rarity_weights. When creating a new layer (or replacing an existing one), make sure all these keys are defined.
This is how you go about assigning value to each key.
id: crypto wallet may make money The layer number. For instance, if the body is the second trait category (or crypto wallet may make money layer) that needs to be stacked, crypto wallet it will have an id of 2. Please note that layers must still be defined in the correct order. name: The name of the trait category. This can be anything you choose it to be. It will appear in the metadata. directory: The name of the folder inside assets that contain images of that particular trait category. required: If this category is required for every image.

When you loved this informative article and you would want to receive more information with regards to interest NFT projects kindly visit our internet site.

Please log in or register to answer this question.