This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Import necessary libraries | |
| from PIL import Image | |
| import random | |
| # Connect to Github repo to load images for the collage | |
| !rm -r /content/NFT_tutorial_python | |
| !git clone https://github.com/jackty9/NFT_tutorial_python.git | |
| # Define the size of the collage | |
| collage = Image.new("RGBA", (5000,2500), color=(255,255,255,255)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create a directory for output images | |
| os.mkdir("/content/images/") | |
| # Generate Images | |
| for item in all_images: | |
| im1 = Image.open(f'/content/NFT_tutorial_python/nft_raw_images/backgrounds/{background_files[item["Background"]]}.png').convert('RGBA') | |
| im2 = Image.open(f'/content/NFT_tutorial_python/nft_raw_images/triangles/{triangle_files[item["Triangle"]]}.png').convert('RGBA') | |
| im3 = Image.open(f'/content/NFT_tutorial_python/nft_raw_images/circles/{circle_files[item["Circle"]]}.png').convert('RGBA') | |
| im4 = Image.open(f'/content/NFT_tutorial_python/nft_raw_images/squares/{square_files[item["Square"]]}.png').convert('RGBA') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Generate Traits | |
| # Number of random unique images to be generated | |
| TOTAL_IMAGES = 50 | |
| all_images = [] | |
| # A recursive function to generate unique image combinations | |
| def create_new_image(): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Each image is made up a series of traits | |
| # The weitages for each trait distribute the rarity and add up to 100% | |
| background = ["Silver", "Salmon", "Cantaloupe", "Mocha", "Teal"] | |
| background_weights = [40, 30, 15, 10, 5] | |
| triangle = ["Red", "Orange", "Yellow", "Green", "Blue"] | |
| triangle_weights = [40, 30, 15, 10, 5] | |
| circle = ["Red", "Orange", "Yellow", "Green", "Blue"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import necessary libraries | |
| from PIL import Image | |
| import random | |
| import json | |
| import os | |
| #connect to Github repo to load raw images and metadata file | |
| !rm -r /content/NFT_tutorial_python | |
| !git clone https://github.com/jackty9/NFT_tutorial_python.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #uncomment to import library | |
| #import pandas as pd | |
| #import datetime | |
| #create first datetime dataframe df1 | |
| df1 = pd.DataFrame( | |
| pd.to_datetime(["13:45:33", '14:17:25',"14:13:25", "15:16:43", "16:51:19"]), | |
| columns=["MsgTime"], | |
| ) | |
| print(df1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #uncomment to import library | |
| #import pandas as pd | |
| #from datetime import datetime | |
| #import pytz, tzlocal | |
| #convert a naive datetime to an aware datetime | |
| dt_naive = pd.to_datetime('2021-11-27T12:24:30') | |
| japan = pytz.timezone("Asia/Tokyo") | |
| dt_aware = dt_naive.tz_localize(japan) | |
| print(dt_aware) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #uncomment to import library | |
| #import pandas as pd | |
| #import datetime as dt | |
| #converting string into datetime | |
| df1 = pd.DataFrame( | |
| { | |
| "DateTime": pd.to_datetime(["2021-11-13 13:45:33", '2021-11-14 14:13:25',"2021-11-15 14:39:25", "2021-11-16 15:16:43", "2021-11-17 16:51:19"]), | |
| } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from google.colab import files | |
| customers_df.to_csv('customers_df.csv') | |
| files.download('customers_df.csv') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import random | |
| from faker import Faker | |
| from random import randrange | |
| from datetime import datetime | |
| nr_of_customers = 1000 | |
| fake = Faker('de_DE') |
NewerOlder