#!/usr/bin/env python3

from itertools import product
import os
import random

resource_path = '/Users/dancrosby/Downloads/coreml-stable-diffusion-2-1-base-palettized_split_einsum_v2_compiled'
output_path_base = '~/Documents/headshots/no_profession/'
image_count = 5

genders = ["male", "female"]
nationalities = ["mexican", "peruvian", "brazilian", "venezuelan", "argentinian", "dominican", "persian", "egyptian", "arab", "moroccan", "nordic", "slavic", 
                 "italian", "english", "irish", "scottish", "welsh", "french", "nigerian", "ethiopian", "aborigine", "native american", "japanese", "korean",
                 "chinese", "indian", "spanish", "portuguese", "vietnamese", "armenian", "mongolian", "turkish", "hungarian", "maori", "hawaiian", "cherokee",
                 "aztec", "mixtec", "inca", "iraqi", "canaanite", "ashkenazi", "yiddish", "german", "bavarian", "polish"]
nationalities.reverse()
trades = ["craftsman", "peddler", "warrior", "vagrant", "beggar", "artisan", "cutpurse", "highwayman", "politician", "aristocrat", "peasant", "thief", "apprentice"]

for nationality, trade, gender in product(nationalities, trades, genders):
    prompt = f'A photorealistic headshot of a {nationality} {gender} medieval {trade}. Highly detailed and realistic.'
    output_path = f'{output_path_base}{gender}/'

    seed = random.randint(0, 2_000_000_000)

    command = f'swift run StableDiffusionSample "{prompt}" --resource-path {resource_path} --seed {seed} --output-path {output_path} --compute-units all --image-count {image_count}'
    print(command)
    os.system(command)
