This is a python art generative code, which uses 'Pillow' python module to merge various layers into one.
- Clone this repository into your working directory.
git clone https://github.com/adarsh-mamgain/NFT-art-generator.git
cd NFT-art-generator
- Install and create a virtualenv to install python modules
pip3 install virtualenv
virtualenv venv
-
Start using the virtual environment.
- On Windows
venv\scripts\activate
- On Linux and MacOS
source venv/bin/activate
- On Windows
-
Run the following command to install
Pillow
and other dependencies
pip3 install -r requirements.txt
Arrange all the .png files inside respective folder types and rename the file. If filename in background directory is Blue.png then the metadata stores the metadata in the below way.
...
"attributes": [
{
"trait_type": "background",
"value": "Blue"
},
...
]
...
All the required configurations are stored and accessed from code/config.py
The rarity_percent for original, rare and super_rare out of your total edition_size (eg: 10000).
NOTE: You can modify the variable values in code/config.py file to get the required ouput.
This file serves all elements and it's details in each layers inside the input folder.
NOTE: Please change the relative path name inside the called get_element()
function for each element in the races -> layers -> elements -> inside the list
key.
...
...
"background": {
"layer_id": "A",
"elements": {
"original": {
"rarity_id": 0,
"list": [
{
"element_id": 0,
"name": "Bazaar",
"location": "./input/background/original/Bazaar.png"
},
{
"element_id": 1,
"name": "Yellow",
"location": "./input/background/original/Yellow.png"
}
]
}
}
},
"armour": {
"layer_id": "B",
"elements": {
"original": {
"rarity_id": 0,
"list": [
{
"element_id": 0,
"name": "Blue",
"location": "./input/armour/original/Blue.png"
},
{
"element_id": 1,
"name": "Violet",
"location": "./input/armour/original/Violet.png"
}
]
}
}
...
...
This code regenerates the metadata inside the build/metadata/ for all the #.json files and metadata.json.
The new attributes DESCRIPTION
, BASE_IMAGE_URI
must be changed inside the code/config.py
CODE/MAIN.PY
is the main file to generate art. The code performs the following functions clear_data
, get_rarity
, create_dna
, is_dna_unique
, save_metadata
and create_image
.
python3 code/main.py
Founder: Adarsh Mamgain
Contact: LinkedIn