""" 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", "back side view of subject, showing the rear/back view" ], "description": "Generate 4 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" }, "Color Comparison": { "count": 2, "prompts": [ "painted in matte black paint and red accents", "covered in gold glitter over white fabric" ], "description": "Simple two-tone color comparison" } } 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" # }