Prioritize regional subjects before environment
Browse files- API.md +1 -1
- app.py +11 -1
- workflow_api.py +6 -0
API.md
CHANGED
|
@@ -56,7 +56,7 @@ Content-Type: application/json
|
|
| 56 |
}
|
| 57 |
```
|
| 58 |
|
| 59 |
-
Returns a PNG with ComfyUI workflow and parameter metadata, scaled after generation by the decimal `return_scale` from `0.01` through `1`, with content type `image/png`. Regional prompts and soft mask-conditioning nodes are included in the metadata. Use `1` for full resolution. `regions` accepts up to four spatial prompts on a 5 by 5 grid.
|
| 60 |
|
| 61 |
## Archive
|
| 62 |
|
|
|
|
| 56 |
}
|
| 57 |
```
|
| 58 |
|
| 59 |
+
Returns a PNG with ComfyUI workflow and parameter metadata, scaled after generation by the decimal `return_scale` from `0.01` through `1`, with content type `image/png`. Regional prompts and soft mask-conditioning nodes are included in the metadata. Use `1` for full resolution. `regions` accepts up to four spatial prompts on a 5 by 5 grid. Regional prompts establish subjects from the first sampling step. The reduced-strength global prompt starts after the first fifth to complete the environment while regions remain active. Each internal region edge feathers by half a grid cell, so overlap adjacent regions by one cell for a smooth crossfade. `area` accepts `full`, `tl`, `tc`, `tr`, `ml`, `mc`, `mr`, `bl`, `bc`, `br`, `th`, `mh`, `bh`, `lh`, `ch`, or `rh`. It also accepts any single cell from `a1` through `e5`, or a rectangular inclusive range such as `a1:c5`. Columns run left to right and rows run top to bottom. Region strength defaults to `1`. Use the global `prompt` for environment, lighting, shared style, and composition outside regions. Omitting `regions` keeps whole-image generation unchanged. Set either scheduler to `AlignYourSteps` to use `AlignYourStepsScheduler` with fixed model type `SDXL` and the corresponding steps and denoise values. Only `prompt` is required for the built-in site defaults. LoRAs run in array order. Each request creates fresh sampler seeds. When `upscale` is true, the request performs latent upscaling followed by a second sampler. Leave `second_model` empty to reuse the first model and LoRA chain; otherwise `second_loras` applies to the selected second model. Width and height must be multiples of 8 from 64 through 2048; steps must be from 1 through 100.
|
| 60 |
|
| 61 |
## Archive
|
| 62 |
|
app.py
CHANGED
|
@@ -77,6 +77,7 @@ IMAGE_SUFFIXES = (".epng", ".png")
|
|
| 77 |
PREVIEW_QUALITY = 75
|
| 78 |
PREVIEW_SCALE = .25
|
| 79 |
DEFAULT_RETURN_SCALE = 1
|
|
|
|
| 80 |
REGIONAL_GLOBAL_STRENGTH = .6
|
| 81 |
AREA_PRESETS = {
|
| 82 |
"full": "a1:e5",
|
|
@@ -655,7 +656,15 @@ def encode_positive(clip, prompt, regions, image_width, image_height):
|
|
| 655 |
positive = state["encode"].encode(clip=clip, text=prompt)[0]
|
| 656 |
if regions:
|
| 657 |
positive = [
|
| 658 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 659 |
for item in positive
|
| 660 |
]
|
| 661 |
for region in regions:
|
|
@@ -1151,6 +1160,7 @@ def generate_image(request, from_api=True):
|
|
| 1151 |
[first_seed, second_seed],
|
| 1152 |
[first_vae, second_vae],
|
| 1153 |
regions,
|
|
|
|
| 1154 |
REGIONAL_GLOBAL_STRENGTH,
|
| 1155 |
)
|
| 1156 |
)
|
|
|
|
| 77 |
PREVIEW_QUALITY = 75
|
| 78 |
PREVIEW_SCALE = .25
|
| 79 |
DEFAULT_RETURN_SCALE = 1
|
| 80 |
+
ENVIRONMENT_START = .2
|
| 81 |
REGIONAL_GLOBAL_STRENGTH = .6
|
| 82 |
AREA_PRESETS = {
|
| 83 |
"full": "a1:e5",
|
|
|
|
| 656 |
positive = state["encode"].encode(clip=clip, text=prompt)[0]
|
| 657 |
if regions:
|
| 658 |
positive = [
|
| 659 |
+
[
|
| 660 |
+
item[0],
|
| 661 |
+
{
|
| 662 |
+
**item[1],
|
| 663 |
+
"start_percent": ENVIRONMENT_START,
|
| 664 |
+
"end_percent": 1,
|
| 665 |
+
"strength": REGIONAL_GLOBAL_STRENGTH,
|
| 666 |
+
},
|
| 667 |
+
]
|
| 668 |
for item in positive
|
| 669 |
]
|
| 670 |
for region in regions:
|
|
|
|
| 1160 |
[first_seed, second_seed],
|
| 1161 |
[first_vae, second_vae],
|
| 1162 |
regions,
|
| 1163 |
+
ENVIRONMENT_START,
|
| 1164 |
REGIONAL_GLOBAL_STRENGTH,
|
| 1165 |
)
|
| 1166 |
)
|
workflow_api.py
CHANGED
|
@@ -635,6 +635,7 @@ def image_metadata(
|
|
| 635 |
seeds,
|
| 636 |
vaes,
|
| 637 |
regions,
|
|
|
|
| 638 |
global_strength,
|
| 639 |
):
|
| 640 |
api = {}
|
|
@@ -731,6 +732,11 @@ def image_metadata(
|
|
| 731 |
"conditioning": positive,
|
| 732 |
"strength": global_strength,
|
| 733 |
}), 0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
for prompt, x, y, width, height, strength in regions:
|
| 735 |
conditioning = [add("CLIPTextEncode", {
|
| 736 |
"text": prompt, "clip": clip,
|
|
|
|
| 635 |
seeds,
|
| 636 |
vaes,
|
| 637 |
regions,
|
| 638 |
+
environment_start,
|
| 639 |
global_strength,
|
| 640 |
):
|
| 641 |
api = {}
|
|
|
|
| 732 |
"conditioning": positive,
|
| 733 |
"strength": global_strength,
|
| 734 |
}), 0]
|
| 735 |
+
positive = [add("ConditioningSetTimestepRange", {
|
| 736 |
+
"conditioning": positive,
|
| 737 |
+
"start": environment_start,
|
| 738 |
+
"end": 1,
|
| 739 |
+
}), 0]
|
| 740 |
for prompt, x, y, width, height, strength in regions:
|
| 741 |
conditioning = [add("CLIPTextEncode", {
|
| 742 |
"text": prompt, "clip": clip,
|