application_vnd.jupyter.stderr_output_1.png
from PIL import Image

import random

face = ['BlueF', 'BlackF', 'OrangeF', 'WhiteF']
face_weights = [2, 47, 3, 48]
eyes = ['BlueE', 'BrownE', 'GreenE', 'PurpleE', 'RedE', 'YellowE']
eye_weights = [20, 50, 20, 6, 3, 1]
hair = ['BlackdevH', 'DanH', 'DevH', 'PeteH', 'SophH']
hair_weights = [22, 25, 25, 3, 25]
mouth = ['frownM', 'indiffM', 'smileM', 'redroboM', 'blueroboM', 'zipM']
mouth_weights = [15, 25, 50, 2, 4, 4]
nose = ['DnoseN', 'PointN', 'TetnoseN']
nose_weights = [40, 55, 5]
glasses = ['leoG', 'blank']
glasses_weights = [15, 85]

total_images = 100
all_images = []
def create_new_image():
    new_image = {}
    new_image['Face'] = random.choices(face, face_weights)[0]
    new_image['Eyes'] = random.choices(eyes, eye_weights)[0]
    new_image['Hair'] = random.choices(hair, hair_weights)[0]
    new_image['Mouth'] = random.choices(mouth, mouth_weights)[0]
    new_image['Nose'] = random.choices(nose, nose_weights)[0]
    new_image['Glasses'] = random.choices(glasses, glasses_weights)[0]
    if new_image in all_images:
        return create_new_image()
    else:
        return new_image
for i in range(total_images):
    new_trait_image = create_new_image()
    all_images.append(new_trait_image)

for item in all_images:
    im1 = Image.open(f"../input/FacesDatanft/{item['Face']}.png").convert('RGBA')
    im2 = Image.open(f"../input/FacesDatanft/{item['Eyes']}.png").convert('RGBA')
    im4 = Image.open(f"../input/FacesDatanft/{item['Hair']}.png").convert('RGBA')
    im5 = Image.open(f"../input/FacesDatanft/{item['Mouth']}.png").convert('RGBA')
    im6 = Image.open(f"../input/FacesDatanft/{item['Nose']}.png").convert('RGBA')
    com1 = Image.alpha_composite(im1, im2)
    plt.imshow(com1)
    plt.savefig('NFT.png')