Git Product home page Git Product logo

generative-art-nft's Introduction

Generative NFT Art

Introduction

The generative-art-nft repository is a library for creating generative art. It was developed for the purpose of creating NFT avatar & collectible projects. This library was used to generate the artwork for the Scrappy Squirrels project.

Features

Generate over a million distinct images with less than 60 traits

The library allows you to generate images every distinct possible combination of your traits. For context, if you had trait art for a project like Bored Apes, the library could generate upwards of 1.2 billion distinct apes.

Add rarity weights

The library also allows you to configure the image generation process in such a way that you have complete control over how rare each and every trait is.

Generate compliant JSON metadata for your NFTs

There is now an added functionality to generate JSON metadata for your NFTs that are in compliance with OpenSea metadata requirements (and by extension, the general NFT metadata standard).

Fuzzy friendly

You can use this library even if you do not know how to program (in Python or otherwise). Do check out the Tutorial for more details on how to use (non-technical) and extend (technical) the library.

Installation

Clone this repository

git clone https://github.com/rounakbanik/generative-art-nft.git

Install required packages

pip install Pillow pandas progressbar2

Upload your input assets in the assets folder, fill up the config.py file, and then run python nft.py.

In order to generate JSON metadata, define BASE_NAME, BASE_IMAGE_URL, and BASE_JSON in metadata.py and then run python metadata.py.

Usage

I have authored a detailed tutorial explaining how to use this library. Check it out here

About Scrappy Squirrels

This library was created as part of the Scrappy Squirrels Project.

Scrappy Squirrels is a collection of 10,000 randomly generated NFTs on the Ethereum Blockchain. Scrappy Squirrels are meant for buyers, creators, and developers who are completely new to the NFT ecosystem.

The community is built around learning about the NFT revolution, exploring its current use cases, discovering new applications, and finding members to collaborate on exciting projects with.

generative-art-nft's People

Contributors

biranchi2018 avatar imartinez avatar rounakbanik avatar thomasoss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generative-art-nft's Issues

Rank?

Hi! This is awesome thank you so much...just..is possible to have a rank of that nft? if i set some accessories at 5% rarity, is possible to have a list of rarity or something similar withouth have to check every nft one by one?

Error on Thumbs.db

I have hidden files turned on and cannot see Thumbs.db, but the script throws errors for various folders and Thumbs.db.
Any clue how to get it to ignore it?

Starting task...
0% (0 of 4200) | | Elapsed Time: 0:00:00 ETA: --:--:--Traceback (most recent call last):
File "nft.py", line 237, in
main()
File "nft.py", line 228, in main
rt = generate_images(edition_name, num_avatars)
File "nft.py", line 172, in generate_images
generate_single_image(trait_paths, os.path.join(op_path, image_name))
File "nft.py", line 72, in generate_single_image
img = Image.open(os.path.join('assets', filepath))
File "C:\Python37\lib\site-packages\PIL\Image.py", line 2896, in open
"cannot identify image file %r" % (filename if filename else fp)
PIL.UnidentifiedImageError: cannot identify image file 'assets\Body\Thumbs.db'

Create just Metadata

Is it possible to just create metadata json files?

I have 10000 images all loaded on piñata.
I don’t require a ‘traits’ or ‘attributes’ section in the metadata.

TypeError: 'module' object is not callable

Checking assets...
Assets look great! We are good to go!

You can create a total of 16 distinct avatars

How many avatars would you like to create? Enter a number greater than 0:
1
What would you like to call this edition?:
edition3
Starting task...
Traceback (most recent call last):
File "nft.py", line 238, in
main()
File "nft.py", line 229, in main
rt = generate_images(edition_name, num_avatars)
File "nft.py", line 164, in generate_images
for n in progressbar(range(count)):
TypeError: 'module' object is not callable

Feature Request: Add branching logic to config

It would be great if config.py supported more of a tree-like structure than a linear structure.

For example, I have a trait that is 50/50 in terms of rarity. Depending on which one of the two options is selected, I want to add different traits on top of it.

For reference, https://nft-generator.art/app supports a similar capability.

A way this could be implemented in the config.py would be to add 2 keys named: next_trait_id and next_trait_rarity. next_trait would be a field that takes the id of the trait to follow and next_trait_rarity represents the odds that the trait will be applied.

Resulting Images don't come out as expected

I have followed the instructions and yet the generated images came out strange. Here's the output:
`C:\Users\Kalin\Documents\GitHub\generative-art-nft>python nft.py
Checking assets...
Assets look great! We are good to go!

You can create a total of 153900 distinct avatars

How many avatars would you like to create? Enter a number greater than 0:
5
What would you like to call this edition?:
1
Starting task...
100% (5 of 5) |#############################################################################################################################################################| Elapsed Time: 0:00:03 Time: 0:00:03
Generated 5 images, 5 are distinct
Removing 0 images...
Saving metadata...
Task complete!`
The result for the first image is:
0
And here are the images that make it up (In order):
darkpurple and yellow polkadots
Amogdarkred
Heldarkred
bone
What can I do to get it to work?

Progressbar doesn't works well.

I installed the "progressbar" package but it occur issue.
after I remove the progressbar feature from the script, it works fine.

Base Image URL for generating metadata

When generating metadata using the metadata.py, what should be used as the BASE_IMAGE_URL? I haven't uploaded my images on any website yet. I have generated multiple sets and those are still in my local storage. Can you please provide some guidance on how to use the metadata.py? Thanks.

TypeError: 'module' object is not callable

Using python 3.9.7, I got this error while running python3 nft.py

Traceback (most recent call last): File "/Users/imartinez/Documents/Dev/crypto/generative-art-nft/nft.py", line 237, in <module> main() File "/Users/imartinez/Documents/Dev/crypto/generative-art-nft/nft.py", line 228, in main rt = generate_images(edition_name, num_avatars) File "/Users/imartinez/Documents/Dev/crypto/generative-art-nft/nft.py", line 163, in generate_images for n in pb(range(count)): TypeError: 'module' object is not callable

After checking stackoverflow I found this similar issue

Fix:
I pip install progressbar2 along with the rest of dependencies and everything worked perfectly.

Object of type int64 is not JSON serializable

When trying to run metadata.py, I'm getting this error.

encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type int64 is not JSON serializable

Miss image after generation

Hi,

I generate a collection with your tools but i have a problem.
I try to generate 11 000 NFT.

The return of the script is good, the metadata.csv contain the date of 11 000 distincts NFT but only 1500 images are created when i open the folder.

You can create a total of 36578304000 distinct avatars How many avatars would you like to create? Enter a number greater than 0: 11000 What would you like to call this edition?: test#1 Starting task... 100% (11000 of 11000) |############################################################| Elapsed Time: 0:03:26 Time: 0:03:26 Generated 11000 images, 10500 are distinct Removing 500 images... Saving metadata... Task complete!

NoneType' object is not subscriptable

Starting task...
Traceback (most recent call last):
File "D:\Google Indirilenler\generative-art-nft-099c93f6cd918a124e9f6e7e044a157eee9b49bd\nft.py", line 259, in
main()
File "D:\Google Indirilenler\generative-art-nft-099c93f6cd918a124e9f6e7e044a157eee9b49bd\nft.py", line 250, in main
rt = generate_images(edition_name, num_avatars)
File "D:\Google Indirilenler\generative-art-nft-099c93f6cd918a124e9f6e7e044a157eee9b49bd\nft.py", line 186, in generate_images
if is_duplicated(rarity_dict, trait_sets, image_index):
File "D:\Google Indirilenler\generative-art-nft-099c93f6cd918a124e9f6e7e044a157eee9b49bd\nft.py", line 151, in is_duplicated
if rarity_dict[CONFIG[idx]['name']][index] != trait[: -1 * len('.png')]:
TypeError: 'NoneType' object is not subscriptable

I got this error. Can anybody help me?

Animated PNG layers

Hello, is it possible to use animated PNG layers? I’ve tried but i can’t get it to work

thanks.

I got a situation: List index out of range

71% (60 of 84) |################# | Elapsed Time: 0:00:44 ETA: 0:00:21Traceback (most recent call last):
File "/Users/liaozhedeng/Desktop/NFT_Turtle/nft.py", line 238, in
main()
File "/Users/liaozhedeng/Desktop/NFT_Turtle/nft.py", line 229, in main
rt = generate_images(edition_name, num_avatars)
File "/Users/liaozhedeng/Desktop/NFT_Turtle/nft.py", line 173, in generate_images
generate_single_image(trait_paths, os.path.join(op_path, image_name))
File "/Users/liaozhedeng/Desktop/NFT_Turtle/nft.py", line 67, in generate_single_image
bg = Image.open(os.path.join('assets', filepaths[0]))
IndexError: list index out of range

Only background in output, or asset if I delete background

I've been trying to generate background with 6 traits. But I've stumbled into problem that output only shows background or one asset. Files are 24x24 pixel and in a .png form transparent. I get no errors or anything like that. The weirdest part is that I can get on my laptop background + next trait but on my main only background or a trait if I deselect background.

How I should proceed?

image
image

feature discussion: Add resolution (detection) to output

To document: The first layer will define the output resolution at the moment.
To implement: Warn if resolutions of asset are different, display output resolution.

It does give for an interesting cropped output:

02

But I would like to add the following parameters:

RESOLUTION_AUTO=True # process the first image, detect resolution and proceed with that resolution
RESOLUTION_OUT="600x600" # This only applies if RESOLUTION_AUTO=False

What would be the consensus on where to put this tunable?
Into the config list or into each and every dictionary item, feels superfluous and inefficient.

ImportError re PIL

When I run nft.py I get the following error message:

File "nft.py", line 5, in
from PIL import Image
ImportError: No module named PIL

I've tried uninstalling pil and pillow and reinstalling pillow, but the error keeps arising. Any thoughts??

Thanks!

Setting layers which impact on variety

Hi, @rounakbanik! I suppose it is the most user-friendly code to work with on this subject. Thanks a lot!
However, I have a challenge: I have 6 layers in total, and I want only 2 of them that program will treat as unique, and others wont.
I explain, there are layers, such as backgound (4 layers) that are needed just "for beauty" and 2 important layers. So I want program to work like this: when it is mixing layers and have combination like (XXXX XX) and (XXXX XY) - are distinct, but (XXXX XX) and (XXYX XX) as "the same" puctures and DO NOT create such picture. So the maximum number of combinations is less than multiplication of all layers by all treats.
Sorry, I am not so pro in coding)
Thanks in advance!

What Edition?

What is the "edition" I'm being asked for supposed to be? I can't find any sort of information on what it is, or even where I should look to check what edition I'm supposed to be using.

NameError: name 'version_1' is not defined

What would you like to call this edition?:
version_1
Traceback (most recent call last):
File "nft.py", line 238, in
main()
File "nft.py", line 226, in main
edition_name = input()
File "", line 1, in
NameError: name 'version_1' is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.