Lesson 11 of 12
Module 5 Practice
Build a structured image prompt generator to practice what you have learned.
Mini Project: Image Prompt Builder
Mini Project: Image Prompt Builder
# Mini Project: Build a structured image prompt from components
def build_image_prompt(
subject,
setting,
style,
lighting,
mood,
camera_angle,
quality_modifiers
):
"""
Combine image prompt components into a well-structured prompt.
"""
prompt_parts = [
subject,
"in" if setting else "",
setting,
f", {style} style" if style else "",
f", {lighting}" if lighting else "",
f", {mood} mood" if mood else "",
f", {camera_angle}" if camera_angle else "",
f", {quality_modifiers}" if quality_modifiers else "",
]
# Build the prompt, removing empty parts
prompt = " ".join([p for p in prompt_parts if p])
return prompt.strip()
# Example 1: Professional product photo
prompt_1 = build_image_prompt(
subject="a sleek black smartphone on a marble surface",
setting="a minimalist studio",
style="professional product photography",
lighting="soft diffused lighting with subtle reflections",
mood="premium and modern",
camera_angle="45-degree overhead angle",
quality_modifiers="4K, sharp focus, commercial photography quality"
)
# Example 2: Fantasy landscape
prompt_2 = build_image_prompt(
subject="an ancient stone castle covered in ivy",
setting="a misty mountain valley at dawn",
style="digital painting",
lighting="soft golden light breaking through clouds",
mood="mysterious and epic",
camera_angle="wide establishing shot",
quality_modifiers="highly detailed, concept art, 4K"
)
print("=== Generated Image Prompts ===")
print()
print("Prompt 1 (Product photo):")
print(f" {prompt_1}")
print()
print("Prompt 2 (Fantasy landscape):")
print(f" {prompt_2}")
print()
print("Copy these prompts into DALL-E, Midjourney, or Adobe Firefly to generate images.")Diagram
Loading diagram…
Practice Diagram
Try It Yourself
Try It YourselfHTML
HTML Editor
✓ ValidTab = 2 spaces
HTML|26 lines|1058 chars|✓ Valid syntax
UTF-8
Key Takeaways from Module 5
- AI image generation creates entirely new images from text descriptions using diffusion models
- Text-to-image converts a text prompt into a matching image
- Image-to-image uses an existing image as input and generates a new image based on it plus a prompt
- Good image prompts include: subject, setting, style, lighting, mood, camera angle, and quality modifiers
- Common limitations include incorrect hands, unreadable text, and inconsistent characters
- AI image generation is used commercially in marketing, e-commerce, publishing, and design
Key Takeaways
- Build a structured image prompt generator to practice what you have learned.
- AI image generation creates entirely new images from text descriptions using diffusion models
- Text-to-image converts a text prompt into a matching image
- Image-to-image uses an existing image as input and generates a new image based on it plus a prompt
Finished this lesson?
0 of 12 in Module 5