Spaces:
Running
on
Zero
Running
on
Zero
feat: preset batch editing
Browse files- presets.py +101 -0
presets.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
presets.py - Batch Generation Presets for Qwen Image Editor
|
| 3 |
+
|
| 4 |
+
Predefined prompt templates that enable batch generation
|
| 5 |
+
of images with common variations. Each preset defines a set of related prompts
|
| 6 |
+
that can be automatically applied to a base instruction to create multiple
|
| 7 |
+
diverse outputs.
|
| 8 |
+
|
| 9 |
+
Structure:
|
| 10 |
+
Each preset contains:
|
| 11 |
+
- 'count': Number of images to generate (1-4 depending on the preset and requirements)
|
| 12 |
+
- 'prompts': List of template strings to append to the base prompt
|
| 13 |
+
- 'description': Human-readable description shown in the UI
|
| 14 |
+
|
| 15 |
+
Example:
|
| 16 |
+
Base prompt: "a red car"
|
| 17 |
+
Multiview preset generates:
|
| 18 |
+
1. "a red car, frontal view of the subject, facing camera directly"
|
| 19 |
+
2. "a red car, left side view of subject, profile view from the left side"
|
| 20 |
+
3. "a red car, right side view of subject, profile view from the right side"
|
| 21 |
+
4. "a red car, back side view of subject, showing the rear/back view"
|
| 22 |
+
|
| 23 |
+
Borderless R&D
|
| 24 |
+
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
PRESETS = {
|
| 28 |
+
"Multiview": {
|
| 29 |
+
"count": 4,
|
| 30 |
+
"prompts": [
|
| 31 |
+
"frontal view of the subject, facing camera directly",
|
| 32 |
+
"left side view of subject, profile view from the left side",
|
| 33 |
+
"right side view of subject, profile view from the right side",
|
| 34 |
+
"back side view of subject, showing the rear/back view"
|
| 35 |
+
],
|
| 36 |
+
"description": "Generate 4 different views of the subject"
|
| 37 |
+
},
|
| 38 |
+
"Style Variations": {
|
| 39 |
+
"count": 3,
|
| 40 |
+
"prompts": [
|
| 41 |
+
"in realistic photography style, high detail",
|
| 42 |
+
"in cartoon/anime style, vibrant colors",
|
| 43 |
+
"in sketch drawing style, black and white outline"
|
| 44 |
+
],
|
| 45 |
+
"description": "Apply different artistic styles to the subject"
|
| 46 |
+
},
|
| 47 |
+
"Lighting Conditions": {
|
| 48 |
+
"count": 3,
|
| 49 |
+
"prompts": [
|
| 50 |
+
"in bright daylight, clear sunny conditions",
|
| 51 |
+
"in golden hour lighting, warm sunset glow",
|
| 52 |
+
"in studio lighting, professional portrait setup"
|
| 53 |
+
],
|
| 54 |
+
"description": "Render the subject under different lighting"
|
| 55 |
+
},
|
| 56 |
+
"Quick Hairstyles": {
|
| 57 |
+
"count": 3,
|
| 58 |
+
"prompts": [
|
| 59 |
+
"with long straight dark hair",
|
| 60 |
+
"with short blonde combover",
|
| 61 |
+
"with brunette hair tied up into updo style"
|
| 62 |
+
],
|
| 63 |
+
"description": "Show the subject in different hairstyles"
|
| 64 |
+
},
|
| 65 |
+
"Color Comparison": {
|
| 66 |
+
"count": 2,
|
| 67 |
+
"prompts": [
|
| 68 |
+
"painted in matte black paint and red accents",
|
| 69 |
+
"covered in gold glitter over white fabric"
|
| 70 |
+
],
|
| 71 |
+
"description": "Simple two-tone color comparison"
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
def get_preset_choices():
|
| 76 |
+
"""
|
| 77 |
+
Return list of preset choices for Gradio dropdown.
|
| 78 |
+
|
| 79 |
+
Returns:
|
| 80 |
+
list: [None] + list of preset names for dropdown selection
|
| 81 |
+
"""
|
| 82 |
+
return [None] + list(PRESETS.keys())
|
| 83 |
+
|
| 84 |
+
def get_preset_info(preset_name):
|
| 85 |
+
"""
|
| 86 |
+
Get preset configuration by name.
|
| 87 |
+
|
| 88 |
+
Args:
|
| 89 |
+
preset_name (str): Name of the preset to retrieve
|
| 90 |
+
|
| 91 |
+
Returns:
|
| 92 |
+
dict or None: Preset configuration dictionary or None if not found
|
| 93 |
+
"""
|
| 94 |
+
return PRESETS.get(preset_name, None)
|
| 95 |
+
|
| 96 |
+
# To add presets at runtime:
|
| 97 |
+
# PRESETS["New Preset Name"] = {
|
| 98 |
+
# "count": 2,
|
| 99 |
+
# "prompts": ["variation 1", "variation 2"],
|
| 100 |
+
# "description": "Description of new preset"
|
| 101 |
+
# }
|