Subscribe to Untitled
Subscribe to Untitled
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
Karma is not always a bitch. I’ll start this piece with this grand opening. The fact that today an artist can make not only a living, but millions online is a concrete and tangible sign that what goes around really comes around.
I am 31 now, and for years I’ve seen just a handful of artists (that is people that draw, paint and create visual content) achieve success in their career. These people have been lucky and talented enough to show their work to the right people, who in return paid very well. But not all artists have this luxury.
Most are grinders and hustlers, and some of them can’t even dedicate themselves to their passions because of economic constraints. I am not an artist, but I rejoice to see how this job’s history is about to change, and this is just the beginning.
But I am not here to talk about artists alone — what I really want to do is share with you the opportunities that are out there for us data enthusiasts. In fact, I will explain how I used my data skills to create a useful NFT generation software for the crypto community.
The NFT space is a weird beast. It is an extremely risk but profitable niche that attracts increasingly more people every day. What makes it cool is that this field (at the moment) leverages primarily artwork to create value. As a matter of fact, artists are seeing opportunities to make great profit by selling NFT collections.
I won’t be introducing what NFTs are. There are plenty of resources here on Medium that go dive deep in this topic. I will, however, give you a brief intro on how I got involved with the field.
I have recently launched an NFT project of my own as co-founder with an artist friend (learn more here). The idea is that the artist would create the artwork, and I would help him build and setup the tech structure. For this project, we chose the Solana blockchain.
The artwork came along just fine and in no time we had the assets ready for NFT generation. A brief research online provided a popular solution: Hashlips Art Engine. I quickly explored the codebase and realized that the software was well written and offered cool features.
But what we had in mind was not obtainable through Hashlips: we wanted to code explicit rarity classes (like legendary, epic, rare, common, …) and control their behavior during generation. We wanted to set probabilities for layers to occur during generation and also exclude specific combinations to happen together. In addition, the software’s target is the artist: its UI had to be simple enough for non-technical users so that they could generate their NFT collection by only having the artwork done.
I ended up coding the software in pure Python, and made it open-source for the community to use and improve. I will give a brief explanation of what it is all about in the following sections of this article.
I started coding the software starting by the configuration file. Users can set the parameters of their collection in by simply manipulating a series of Python dictionaries. While it can seem daunting for people that are completely new to the language, people with very basic intro knowledge in data structures will feel at home.
The idea was to allow users to control rarity classes and their probability of occurrence in an image. Let’s see an example.
Say you are an artist and you want to create a gothic-themed NFT collection based on monsters. Take an orc as an example. You want to give this orc the chance to wield weapons, armor and more. In turn, each of these items should be stronger or weaker based on probability.
You do just that with this software, and it is pretty easy to do.
You create your item classes for each layer, like legenary, epic, rare, etc. and then you assign probabilities to these classes. For instance, a legendary armor can occur once every ten items, i.e. 10%.
You can also configure the behavior of special items. Special items are items that are so rare they are even more valuable than legendary items. You can specify a list of unique items and relative probability and voilà, you now have a set of items that behave differently within the same rarity class.
We’ve published a YouTube video covering the workings of the software in detail.
This is one of our first videos, so please share your feedback to help us improve in future iterations.
This is all you need to run the software successfully:
Python 3.7+ installed on your machine
Image layers
That’s it. You literally need Python, initialize a virtual environment (which is optional, but highly suggested) and install Pillow. Detailed info on how to install the software is found in the Github repo.
Let’s go briefly through the configuration file to see what we need to change in order to customize our NFT collection. At the moment of writing this article, the software is suited only for the Solana blockchain. In the future it will also allow for Ethereum collections.
./src/config.py is the file you need to edit to customize your project. It all starts with the Solana project metadata dictionary.
How project metadata is defined. Image by author.
These initial parameters serve as a base for the creation of metadata files for each NFT. In Solana, each NFT is associated with a metadata.json file, and enumeration starts from 0.
Next was allowing users to specify name and number of layers to combine to create an image.
Layering system. Image by Author.
Images are put together through the Pillow library. It is in fact the only external library used in this software, the rest is all standard lib.
The layer order should follow a simple principle: layers should be ordered from background to foreground. This is to ensure the correct overlapping of items during image creation.
The next dictionary to edit is held in the SETUP variable*.* This is where the magic happens (it’s not really magic, just some simple math!).
You can add classes under the scheme key and items to that class in a simple Python list.
How the SETUP variable is set in the config.py file. Image by author.
Rarity class names are arbitrary. We used the gamified convention of legendary, epic, and so on, but you can really use whatever you want.
The p key is where you define the probability of that class. If Legendary has p = 0.1 then it means that the legendary class for that layer will occur about once every ten NFTs. Cool, right? :) This is valid for all classes you decide to add.
All items in the class have the same probability of occurring. So how do we control the rarity of special items? My specifying a dictionary, we can multiply the underlying probability of the items in the class by that multiplier. We are essentially multiplying two probabilities.
In the example below, the legendary class has a 10% chance of appearing. Given that all items inside that class have the same chance of appearing (they follow a uniform distribution), the chance of an item to appear is around 16% (1/6). We set Tengu mask, Vader mask and Gas mask as special items: we want them to appear less than 16%. By using 0.2, we are basically saying 16% * 20% = ~3%.
Of course, since the probability now for three items is lower, the chances of the other items to appear are higher.
This is how you can not only manipulate probabilities for classes, but also for single items. Neat.
The last piece of the puzzle is optional, but still powerful if you as an artist have created complex combinations among your layers. In this field, you can specify combinations to exclude from your collection. Why would you want to do this? One case would be to avoid conflicts and glitches among incompatible layers. We excluded Tengu mask and other items because of how they look together. We didn’t like them, so we decided to allow the user to control this aspect as well.
How to exclude combinations. Image by author.
Again, if you feel like you need a deeper dive, feel free to watch the YouTube video that goes through all of these functionalities.
Now that we’ve setup everything in the config.py file, we are ready to create our NFT collection.
Drop your Layers folder in the project root if you haven’t already, and make sure that the naming conventions used are consistent everywhere.
Now reach ./src/run.py and set the number of elements you want in your collection.
Launch this script to create your collection from config.py. Image by author.
The terminal should populate with the genetic sequence of our NFTs.
Genetic sequence of our NFTs. Image by author.
If a genetic sequence is invalid (for instance if the combination is found in EXCLUDE_COMBINATIONS) then the software will destroy the sequence and create a new one.
Once completed, you will find the collections folder that will contain your images and metadata folders, together with some reports on item and class rarity.
Karma is not always a bitch. I’ll start this piece with this grand opening. The fact that today an artist can make not only a living, but millions online is a concrete and tangible sign that what goes around really comes around.
I am 31 now, and for years I’ve seen just a handful of artists (that is people that draw, paint and create visual content) achieve success in their career. These people have been lucky and talented enough to show their work to the right people, who in return paid very well. But not all artists have this luxury.
Most are grinders and hustlers, and some of them can’t even dedicate themselves to their passions because of economic constraints. I am not an artist, but I rejoice to see how this job’s history is about to change, and this is just the beginning.
But I am not here to talk about artists alone — what I really want to do is share with you the opportunities that are out there for us data enthusiasts. In fact, I will explain how I used my data skills to create a useful NFT generation software for the crypto community.
The NFT space is a weird beast. It is an extremely risk but profitable niche that attracts increasingly more people every day. What makes it cool is that this field (at the moment) leverages primarily artwork to create value. As a matter of fact, artists are seeing opportunities to make great profit by selling NFT collections.
I won’t be introducing what NFTs are. There are plenty of resources here on Medium that go dive deep in this topic. I will, however, give you a brief intro on how I got involved with the field.
I have recently launched an NFT project of my own as co-founder with an artist friend (learn more here). The idea is that the artist would create the artwork, and I would help him build and setup the tech structure. For this project, we chose the Solana blockchain.
The artwork came along just fine and in no time we had the assets ready for NFT generation. A brief research online provided a popular solution: Hashlips Art Engine. I quickly explored the codebase and realized that the software was well written and offered cool features.
But what we had in mind was not obtainable through Hashlips: we wanted to code explicit rarity classes (like legendary, epic, rare, common, …) and control their behavior during generation. We wanted to set probabilities for layers to occur during generation and also exclude specific combinations to happen together. In addition, the software’s target is the artist: its UI had to be simple enough for non-technical users so that they could generate their NFT collection by only having the artwork done.
I ended up coding the software in pure Python, and made it open-source for the community to use and improve. I will give a brief explanation of what it is all about in the following sections of this article.
I started coding the software starting by the configuration file. Users can set the parameters of their collection in by simply manipulating a series of Python dictionaries. While it can seem daunting for people that are completely new to the language, people with very basic intro knowledge in data structures will feel at home.
The idea was to allow users to control rarity classes and their probability of occurrence in an image. Let’s see an example.
Say you are an artist and you want to create a gothic-themed NFT collection based on monsters. Take an orc as an example. You want to give this orc the chance to wield weapons, armor and more. In turn, each of these items should be stronger or weaker based on probability.
You do just that with this software, and it is pretty easy to do.
You create your item classes for each layer, like legenary, epic, rare, etc. and then you assign probabilities to these classes. For instance, a legendary armor can occur once every ten items, i.e. 10%.
You can also configure the behavior of special items. Special items are items that are so rare they are even more valuable than legendary items. You can specify a list of unique items and relative probability and voilà, you now have a set of items that behave differently within the same rarity class.
We’ve published a YouTube video covering the workings of the software in detail.
This is one of our first videos, so please share your feedback to help us improve in future iterations.
This is all you need to run the software successfully:
Python 3.7+ installed on your machine
Image layers
That’s it. You literally need Python, initialize a virtual environment (which is optional, but highly suggested) and install Pillow. Detailed info on how to install the software is found in the Github repo.
Let’s go briefly through the configuration file to see what we need to change in order to customize our NFT collection. At the moment of writing this article, the software is suited only for the Solana blockchain. In the future it will also allow for Ethereum collections.
./src/config.py is the file you need to edit to customize your project. It all starts with the Solana project metadata dictionary.
How project metadata is defined. Image by author.
These initial parameters serve as a base for the creation of metadata files for each NFT. In Solana, each NFT is associated with a metadata.json file, and enumeration starts from 0.
Next was allowing users to specify name and number of layers to combine to create an image.
Layering system. Image by Author.
Images are put together through the Pillow library. It is in fact the only external library used in this software, the rest is all standard lib.
The layer order should follow a simple principle: layers should be ordered from background to foreground. This is to ensure the correct overlapping of items during image creation.
The next dictionary to edit is held in the SETUP variable*.* This is where the magic happens (it’s not really magic, just some simple math!).
You can add classes under the scheme key and items to that class in a simple Python list.
How the SETUP variable is set in the config.py file. Image by author.
Rarity class names are arbitrary. We used the gamified convention of legendary, epic, and so on, but you can really use whatever you want.
The p key is where you define the probability of that class. If Legendary has p = 0.1 then it means that the legendary class for that layer will occur about once every ten NFTs. Cool, right? :) This is valid for all classes you decide to add.
All items in the class have the same probability of occurring. So how do we control the rarity of special items? My specifying a dictionary, we can multiply the underlying probability of the items in the class by that multiplier. We are essentially multiplying two probabilities.
In the example below, the legendary class has a 10% chance of appearing. Given that all items inside that class have the same chance of appearing (they follow a uniform distribution), the chance of an item to appear is around 16% (1/6). We set Tengu mask, Vader mask and Gas mask as special items: we want them to appear less than 16%. By using 0.2, we are basically saying 16% * 20% = ~3%.
Of course, since the probability now for three items is lower, the chances of the other items to appear are higher.
This is how you can not only manipulate probabilities for classes, but also for single items. Neat.
The last piece of the puzzle is optional, but still powerful if you as an artist have created complex combinations among your layers. In this field, you can specify combinations to exclude from your collection. Why would you want to do this? One case would be to avoid conflicts and glitches among incompatible layers. We excluded Tengu mask and other items because of how they look together. We didn’t like them, so we decided to allow the user to control this aspect as well.
How to exclude combinations. Image by author.
Again, if you feel like you need a deeper dive, feel free to watch the YouTube video that goes through all of these functionalities.
Now that we’ve setup everything in the config.py file, we are ready to create our NFT collection.
Drop your Layers folder in the project root if you haven’t already, and make sure that the naming conventions used are consistent everywhere.
Now reach ./src/run.py and set the number of elements you want in your collection.
Launch this script to create your collection from config.py. Image by author.
The terminal should populate with the genetic sequence of our NFTs.
Genetic sequence of our NFTs. Image by author.
If a genetic sequence is invalid (for instance if the combination is found in EXCLUDE_COMBINATIONS) then the software will destroy the sequence and create a new one.
Once completed, you will find the collections folder that will contain your images and metadata folders, together with some reports on item and class rarity.
No activity yet