Here's a revised and more understandable version of your script that collects inputs from the customer, saves the answers to pre.json, and then automatically starts random.py. This script is designed to help generate great prompts by randomly selecting answers provided by the customer.
# setup.py
import json
import subprocess
def main():
data = {}
# 1. Business Name
data['business_name'] = input("Enter your business name: ")
# 2. Business Slogan
data['business_slogan'] = input("Enter your business slogan: ")
# 3. Business Field
data['business_field'] = input("Enter your business field: ")
# 4. Style Selection
styles = [
"Photorealistic",
"Cartoon",
"3D Render",
"Vintage",
"Minimalist",
"Abstract",
"Pop Art",
"Surrealism",
"Fantasy",
"Pixel Art",
# Add more styles if desired
]
print("\nPlease select styles you like from the following list (enter numbers separated by commas):")
for i, style in enumerate(styles, 1):
print(f"{i}. {style}")
selected_styles_input = input("Your choices: ")
selected_style_indices = [int(x.strip()) - 1 for x in selected_styles_input.split(",") if x.strip().isdigit() and 1 <= int(x.strip()) <= len(styles)]
selected_styles = [styles[i] for i in selected_style_indices]
data['selected_styles'] = selected_styles
# 5. Keywords Describing the Business
keywords_valid = False
while not keywords_valid:
keywords_input = input("\nList at least 5 keywords describing your business (separated by commas): ")
keywords = [k.strip() for k in keywords_input.split(",") if k.strip()]
if len(keywords) >= 5:
keywords_valid = True
else:
print("Please enter at least 5 keywords.")
data['keywords'] = keywords
# 6. Mini Prompts
print("\nWrite a few mini prompts (separated by commas).")
print("Examples:")
print("- A shark underwater hitting jackpot on a slots game, gold coins floating around.")
print("- A mid-30's couple at home, happy and playing slots on their phone.")
# You can provide more examples if desired
mini_prompts_input = input("Your mini prompts: ")
mini_prompts = [p.strip() for p in mini_prompts_input.split(",") if p.strip()]
data['mini_prompts'] = mini_prompts
# 8. Famous Artists or Styles
artists_styles = [
"Andy Warhol",
"Salvador Dalí",
"Pablo Picasso",
"Vincent van Gogh",
"Leonardo da Vinci",
"Frida Kahlo",
"Henri Matisse",
"Claude Monet",
"Jackson Pollock",
"Georgia O'Keeffe",
# Add more artists or styles if desired
]
print("\nPlease select famous artists or styles you like from the following list (enter numbers separated by commas):")
for i, artist in enumerate(artists_styles, 1):
print(f"{i}. {artist}")
selected_artists_input = input("Your choices: ")
selected_artist_indices = [int(x.strip()) - 1 for x in selected_artists_input.split(",") if x.strip().isdigit() and 1 <= int(x.strip()) <= len(artists_styles)]
selected_artists = [artists_styles[i] for i in selected_artist_indices]
data['selected_artists'] = selected_artists
# 9. Color Palettes
color_palettes = [
"Red and Gold",
"Blue and Silver",
"Black and White",
"Green and Yellow",
"Purple and Orange",
"Pink and Turquoise",
# Add more color combinations if desired
]
palettes_valid = False
while not palettes_valid:
print("\nPlease select 3 color palettes you prefer from the following list (enter numbers separated by commas):")
for i, palette in enumerate(color_palettes, 1):
print(f"{i}. {palette}")
selected_palettes_input = input("Your choices: ")
selected_palette_indices = [int(x.strip()) - 1 for x in selected_palettes_input.split(",") if x.strip().isdigit() and 1 <= int(x.strip()) <= len(color_palettes)]
if len(selected_palette_indices) >= 3:
palettes_valid = True
else:
print("Please select at least 3 color palettes.")
selected_palettes = [color_palettes[i] for i in selected_palette_indices]
data['selected_palettes'] = selected_palettes
# Save data to pre.json
with open('pre.json', 'w') as f:
json.dump(data, f, indent=4)
print("\nYour inputs have been saved to pre.json.")
# Automatically start random.py
print("Starting random.py...")
subprocess.run(["python", "random.py"])
if __name__ == "__main__":
main()
Explanation:
- Questions 1-3: The script collects the business name, slogan, and field directly from the user's input.
- Question 4 (Style Selection): Presents a list of styles for the user to choose from. They can select multiple styles by entering numbers separated by commas. Their selections are stored and one style will be randomly chosen for each image generation in the next script.
- Question 5 (Keywords): The user is prompted to provide at least 5 keywords that describe their business. The script ensures they enter at least 5 keywords. Two keywords will be randomly selected each time an image is generated.
- Question 6 (Mini Prompts): The user writes several mini prompts, separated by commas. Examples are provided to guide them. These prompts will be randomly used (not always) and combined with other answers when generating images.
- Question 8 (Famous Artists or Styles): A list of 10 famous artists or styles is presented. The user selects their preferred ones by number. One style will be randomly chosen for each image generation.
- Question 9 (Color Palettes): The user selects 3 preferred color palettes from a list of 6. The script ensures they select at least 3. One palette will be randomly selected for each image generation.
Note:
- Skipping Question 7: There's an intentional skip of question 7 as per your original instructions.
- Data Saving: All the collected data is saved to a JSON file
pre.json for use in random.py.
- Starting
random.py: At the end of the script, it automatically starts random.py.
Usage:
- Run the script using the command:
python setup.py.
- Follow the on-screen prompts to enter your information.
- Ensure
random.py is in the same directory as setup.py to allow the automatic start.
Next Steps in random.py:
Using the data saved in pre.json, random.py can:
- Randomly select one style from
selected_styles for each image.
- Randomly select two keywords from
keywords for each image.
- Optionally include a mini prompt from
mini_prompts.
- Randomly select one artist or style from
selected_artists.
- Randomly select one color palette from
selected_palettes.
By combining these elements, the script can generate varied and creative prompts for image generation, tailored to the customer's preferences.
Example of Data in pre.json:
{
"business_name": "Lucky Spin Casino",
"business_slogan": "Your Chance to Win Big Every Day!",
"business_field": "Online Gaming",
"selected_styles": ["Cartoon", "3D Render", "Pop Art"],
"keywords": ["exciting", "rewarding", "entertaining", "thrilling", "innovative"],
"mini_prompts": ["A jackpot bursting with coins", "Players celebrating a big win"],
"selected_artists": ["Andy Warhol", "Salvador Dalí"],
"selected_palettes": ["Red and Gold", "Purple and Orange", "Blue and Silver"]
}
Feel free to copy and modify this script to suit your needs. The information collected aligns with what will be used in the next script (random.py) for generating tailored image prompts.