Here's an explanation and a Python example that implements your pseudo-code logic:
What your code does:
- Takes an input number
n (defaults to 1 if no input).
- Takes an input list of subjects and activities; if not provided, generates random lists of length
n.
- For each index from 1 to
n, generates:
p1: a composition of a pose, camera shot, subject with an outfit, and an activity.
p2: a composition of setting, place, and background.
p3: a composition of photo style repeated twice, film stock, and technical keywords.
- Prints these composed strings separated by
" | ".
Full Python example implementation:
import random
def input_num():
try:
return int(input("Enter number of items (default 1): "))
except:
return 1
def input_list(prompt):
line = input(f"Enter list of {prompt}s separated by commas (leave empty to randomize): ")
if line.strip() == "":
return None
return [item.strip() for item in line.split(",")]
def randomList(category, n):
random_data = {
"subject": ["man", "woman", "child", "dog", "cat", "couple", "group", "athlete"],
"activity": ["running", "jumping", "reading", "cooking", "dancing", "painting", "swimming", "playing guitar"],
"pose": ["standing", "sitting", "lying down", "crouching", "jumping"],
"cameraShot": ["close-up", "wide shot", "medium shot", "overhead shot"],
"outfit": ["red jacket", "blue jeans", "white shirt", "black suit", "green dress"],
"setting": ["forest", "beach", "urban", "mountain", "desert"],
"place": ["park", "cafe", "street", "gallery", "stadium"],
"background": ["trees", "buildings", "skyline", "lake", "mountains"],
"photoStyle": ["vintage", "HDR", "soft focus", "black and white", "studio lighting"],
"filmstock": ["Kodak Portra 400", "Fujifilm Velvia 50", "Ilford HP5 Plus", "Cinestill 800T"],
"techKeywords": ["f/1.8", "1/200s shutter", "ISO 100", "35mm lens"]
}
# For subjects and activities we already have specific calls, but adding fallback here
return random.choices(random_data.get(category, ["item"]), k=n)
def pose():
return random.choice(["standing", "sitting", "lying down", "crouching", "jumping"])
def cameraShot():
return random.choice(["close-up", "wide shot", "medium shot", "overhead shot"])
def outfit():
return random.choice(["red jacket", "blue jeans", "white shirt", "black suit", "green dress"])
def setting():
return random.choice(["forest", "beach", "urban", "mountain", "desert"])
def place():
return random.choice(["park", "cafe", "street", "gallery", "stadium"])
def background():
return random.choice(["trees", "buildings", "skyline", "lake", "mountains"])
def photoStyle():
return random.choice(["vintage", "HDR", "soft focus", "black and white", "studio lighting"])
def filmstock():
return random.choice(["Kodak Portra 400", "Fujifilm Velvia 50", "Ilford HP5 Plus", "Cinestill 800T"])
def techKeywords():
return random.choice(["f/1.8", "1/200s shutter", "ISO 100", "35mm lens"])
def main():
n = input_num() or 1
subs = input_list("subject") or randomList("subject", n)
acts = input_list("activity") or randomList("activity", n)
for idx in range(n):
p1 = f"{pose()} {cameraShot()} {subs[idx]} wearing a {outfit()} {acts[idx]}"
p2 = f"{setting()} {place()} {background()} in the background"
p3 = f"{photoStyle()} {photoStyle()} {filmstock()} {techKeywords()}"
print(p1 + " | " + p2 + " | " + p3)
if __name__ == "__main__":
main()
How to use:
- Run the script.
- Enter the number of items or leave empty (defaults to 1).
- Enter subjects separated by commas or leave empty for random.
- Enter activities separated by commas or leave empty for random.
- The script prints out the creative photo prompt segments.
If you'd like me to adapt or add anything, just let me know!