""" presets.py - Batch Generation Presets for Qwen Image Editor Predefined prompt templates that enable batch generation of images with common variations. Each preset defines a set of related prompts that can be automatically applied to a base instruction to create multiple diverse outputs. Structure: Each preset contains: - 'count': Number of images to generate (1-4 depending on the preset and requirements) - 'prompts': List of template strings to append to the base prompt - 'description': Human-readable description shown in the UI Example: Base prompt: "a red car" Multiview preset generates: 1. "a red car, frontal view of the subject, facing camera directly" 2. "a red car, left side view of subject, profile view from the left side" 3. "a red car, right side view of subject, profile view from the right side" 4. "a red car, back side view of subject, showing the rear/back view" Borderless R&D """ PRESETS = { "Multiview": { "count": 3, "prompts": [ "frontal view of the subject, facing camera directly", "side view of subject, profile view from the side", "dutch angle shot of subject, candid photography" ], "description": "Generate three different views of the subject" }, "Style Variations": { "count": 3, "prompts": [ "in realistic photography style, high detail", "in cartoon/anime style, vibrant colors", "in sketch drawing style, black and white outline" ], "description": "Apply different artistic styles to the subject" }, "Lighting Conditions": { "count": 3, "prompts": [ "in bright daylight, clear sunny conditions", "in golden hour lighting, warm sunset glow", "in studio lighting, professional portrait setup" ], "description": "Render the subject under different lighting" }, "Quick Hairstyles": { "count": 3, "prompts": [ "with long straight dark hair", "with short blonde combover", "with brunette hair tied up into updo style" ], "description": "Show the subject in different hairstyles" }, "Seasonal Themes": { "count": 4, "prompts": [ "in a snowy winter landscape, snowflakes falling gently", "in a sunny summer meadow, bright sunshine", "in a crisp autumn forest, leaves turning orange", "in a misty spring garden, blooming flowers" ], "description": "Render the subject in each of the four seasons" }, "Emotional Mood": { "count": 4, "prompts": [ "with a joyful grin, eyes sparkling", "with a thoughtful expression, slightly furrowed brow", "with a dramatic, intense stare", "with a gentle, serene smile" ], "description": "Show the subject’s emotions in four different moods" }, "Historical Eras": { "count": 4, "prompts": [ "in Victorian England, ornate lace and corset", "in the 1980s, neon lights and big hair", "in a medieval castle, knight armor", "in a futuristic cyber‑punk city, holographic backdrop" ], "description": "Place the subject in four iconic time periods" }, "Camera Lens Effects": { "count": 4, "prompts": [ "captured with a wide‑angle lens, exaggerated perspective", "shot with a telephoto lens, shallow depth of field", "taken with a fisheye lens, circular distortion", "rendered with a macro lens, extreme close‑up detail" ], "description": "Play with different lens styles for the same subject" }, "Fantasy Elements": { "count": 3, "prompts": [ "surrounded by a swirling vortex of light", "hovering above a floating island in the clouds", "paired with a companion dragon, breathing fire", ], "description": "Add a fantastical twist to each rendition" }, "Texture Variations": { "count": 3, "prompts": [ "covered in soft velvet, plush texture", "painted with glossy enamel, shiny finish", "wrapped in intricate lace patterns", ], "description": "Show the subject in three distinct surface textures" }, "Color Palette Swaps": { "count": 3, "prompts": [ "in pastel colors, soft hues", "with neon saturation, high‑contrast glow", "in monochrome black & white, dramatic contrast" ], "description": "Recolor the subject with three distinct palettes" } } def get_preset_choices(): """ Return list of preset choices for Gradio dropdown. Returns: list: [None] + list of preset names for dropdown selection """ return [None] + list(PRESETS.keys()) def get_preset_info(preset_name): """ Get preset configuration by name. Args: preset_name (str): Name of the preset to retrieve Returns: dict or None: Preset configuration dictionary or None if not found """ return PRESETS.get(preset_name, None) def update_preset_prompt(preset_name, prompt_index, new_prompt): """ Update a specific prompt in a preset. Args: preset_name (str): Name of the preset to update prompt_index (int): Index of the prompt to update (0-3) new_prompt (str): New prompt text Returns: dict: Updated PRESETS dictionary """ if preset_name in PRESETS and 0 <= prompt_index < len(PRESETS[preset_name]["prompts"]): PRESETS[preset_name]["prompts"][prompt_index] = new_prompt return PRESETS[preset_name] if preset_name in PRESETS else None # To add presets at runtime: # PRESETS["New Preset Name"] = { # "count": 2, # "prompts": ["variation 1", "variation 2"], # "description": "Description of new preset" # }