Python
Expand Image fills its border from a blurred canvas; Cinema Studio writes looks, not gear
neuregex3cfc4143177d
diff --git a/apps/ai-influencer/app.json b/apps/ai-influencer/app.jsonindex c05bed4..419e1ff 100644--- a/apps/ai-influencer/app.json+++ b/apps/ai-influencer/app.json@@ -4,7 +4,7 @@"name": "AI Influencer","section": "image","summary": "Makes a feed-ready photo of a made-up influencer in their niche, with natural skin (Z-Image Turbo).",- "higgsfield_feature": "Influencer IA",+ "higgsfield_feature": "AI Influencer","pack": "image","status": "ready","workflow": "workflow.api.json",diff --git a/apps/cinema-studio/app.json b/apps/cinema-studio/app.jsonindex c9363cd..b10f176 100644--- a/apps/cinema-studio/app.json+++ b/apps/cinema-studio/app.json@@ -11,7 +11,7 @@"source": {"template": "image_z_image_turbo_int8.json","comfyui": "0.42.0",- "notes": "Camera and lens vocabulary from open-higgsfield-ai (MIT), src/lib/promptUtils.js."+ "notes": "Camera and lens vocabulary from open-higgsfield-ai (MIT), src/lib/promptUtils.js. Camera, lens and focal options write the look they give, not the gear: with \"shot on a <camera>\" Z-Image drew the camera into the picture (run 20261020-133620-l40s), and \"no camera in the frame\" did not stop it (run 20261024-172353-h100)."},"inputs": [{@@ -19,12 +19,12 @@"type": "textarea","label": "Scene","required": true,- "default": "A detective lighting a cigarette under a streetlamp",+ "default": "A detective in a trench coat lights a cigarette under a streetlamp on a rainy night","bind": [{"node": "57:27","field": "text",- "template": "A cinematic film still: {prompt}. The picture looks as if it was shot on a {camera} with a {lens} at {focal}, {aperture}; no camera, lens or film gear appears in the frame. Cinematic lighting, natural color science, high dynamic range, ultra-detailed"+ "template": "A cinematic film still: {prompt}. The look: {camera}; {lens}; {focal}; {aperture}. Cinematic lighting, natural color science, high dynamic range, ultra-detailed"}]},@@ -32,30 +32,30 @@"id": "camera","type": "select","label": "Camera",- "default": "full-frame digital cinema camera",+ "default": "the full-frame digital cinema look, natural and smooth","options": [{- "value": "modular 8K digital cinema camera",+ "value": "the crisp, clean detail of 8K digital cinema","label": "Modular 8K Digital"},{- "value": "full-frame digital cinema camera",+ "value": "the full-frame digital cinema look, natural and smooth","label": "Full-Frame Cine Digital"},{- "value": "grand format 70mm film camera",+ "value": "the rich detail and fine grain of large-format 70mm film","label": "Grand Format 70mm Film"},{- "value": "Super 35 studio digital camera",+ "value": "the polished Super 35 digital studio look","label": "Studio Digital S35"},{- "value": "classic 16mm film camera",+ "value": "the soft, grainy texture of 16mm film","label": "Classic 16mm Film"},{- "value": "premium large-format digital cinema camera",+ "value": "the smooth, wide-latitude large-format digital look","label": "Premium Large Format Digital"}]@@ -64,50 +64,50 @@"id": "lens","type": "select","label": "Lens",- "default": "classic anamorphic lens",+ "default": "a classic anamorphic widescreen look with oval bokeh and blue streak flares","options": [{- "value": "creative tilt lens effect",+ "value": "tilt-shift selective focus","label": "Creative Tilt Lens"},{- "value": "compact anamorphic lens",+ "value": "subtle anamorphic oval bokeh and horizontal flares","label": "Compact Anamorphic"},{- "value": "extreme macro lens",+ "value": "extreme macro detail","label": "Extreme Macro"},{- "value": "1970s cinema prime lens",+ "value": "the warm, slightly soft rendering of 1970s cinema glass","label": "70s Cinema Prime"},{- "value": "classic anamorphic lens",+ "value": "a classic anamorphic widescreen look with oval bokeh and blue streak flares","label": "Classic Anamorphic"},{- "value": "premium modern prime lens",+ "value": "clean, sharp modern rendering","label": "Premium Modern Prime"},{- "value": "warm-toned cinema prime lens",+ "value": "warm-toned cinematic rendering","label": "Warm Cinema Prime"},{- "value": "swirl bokeh portrait lens",+ "value": "swirling vintage bokeh","label": "Swirl Bokeh Portrait"},{- "value": "vintage prime lens",+ "value": "soft vintage rendering with gentle flare","label": "Vintage Prime"},{- "value": "halation diffusion filter",+ "value": "a halation glow around the highlights","label": "Halation Diffusion"},{- "value": "ultra-sharp clinical prime lens",+ "value": "ultra-sharp clinical detail","label": "Clinical Sharp Prime"}]@@ -116,30 +116,30 @@"id": "focal","type": "select","label": "Focal length",- "default": "35mm (natural cinematic perspective)",+ "default": "a natural 35mm perspective","options": [{- "value": "8mm (ultra-wide perspective)",+ "value": "an ultra-wide 8mm perspective","label": "8 mm"},{- "value": "14mm (wide-angle perspective)",+ "value": "a wide-angle 14mm perspective","label": "14 mm"},{- "value": "24mm (wide-angle dynamic perspective)",+ "value": "a dynamic wide 24mm perspective","label": "24 mm"},{- "value": "35mm (natural cinematic perspective)",+ "value": "a natural 35mm perspective","label": "35 mm"},{- "value": "50mm (standard portrait perspective)",+ "value": "a standard 50mm perspective","label": "50 mm"},{- "value": "85mm (classic portrait perspective)",+ "value": "a classic 85mm portrait perspective","label": "85 mm"}]diff --git a/apps/expand-image/app.json b/apps/expand-image/app.jsonindex 7dc2af5..b32b2e1 100644--- a/apps/expand-image/app.json+++ b/apps/expand-image/app.json@@ -11,7 +11,7 @@"source": {"template": "image_flux3_klein_distilled_image_edit.json","comfyui": "0.42.0",- "notes": "Template app written by tools/template_apps.py: the workflow is apps/edit's (built by tools/build_apps.py); the sampler starts from the photo scaled to 1 MP and padded by ImagePadForOutpaint (the select sets the padding), with a noise mask on the border only, and the unpadded photo stays Klein's reference; the prompt below is fixed and \"Extra direction\" is appended to it."+ "notes": "Template app written by tools/template_apps.py: the workflow is apps/edit's (built by tools/build_apps.py); the photo, scaled to 1 MP, sits on a stretched and blurred copy of itself as big as ImagePadForOutpaint's canvas (the select sets the padding); the sampler starts from that canvas with a noise mask on the border only, and the canvas is Klein's reference; the prompt below is fixed and \"Extra direction\" is appended to it."},"inputs": [{@@ -58,6 +58,16 @@"node": "op_pad","field": "bottom","value": 192+ },+ {+ "node": "op_fill",+ "field": "x",+ "value": 192+ },+ {+ "node": "op_fill",+ "field": "y",+ "value": 192}]},@@ -84,6 +94,16 @@"node": "op_pad","field": "bottom","value": 0+ },+ {+ "node": "op_fill",+ "field": "x",+ "value": 320+ },+ {+ "node": "op_fill",+ "field": "y",+ "value": 0}]},@@ -110,6 +130,16 @@"node": "op_pad","field": "bottom","value": 320+ },+ {+ "node": "op_fill",+ "field": "x",+ "value": 0+ },+ {+ "node": "op_fill",+ "field": "y",+ "value": 320}]}@@ -125,7 +155,7 @@{"node": "4","field": "text",- "template": "Extend this photo outward into the gray border around it: continue the scene, its objects, light and perspective naturally past the original edges, as if the camera had pulled back. The original part of the photo stays exactly the same; no frame, no border, no text. {details}"+ "template": "The outer part of this photo is blurred: redraw it sharp, continuing the scene, its objects, light and perspective naturally out to all four edges, as if the camera had pulled back. The sharp center stays exactly the same; one continuous photo, no frame, no border, no text. {details}"}]},diff --git a/apps/expand-image/workflow.api.json b/apps/expand-image/workflow.api.jsonindex 13a01f9..0af7799 100644--- a/apps/expand-image/workflow.api.json+++ b/apps/expand-image/workflow.api.json@@ -126,7 +126,7 @@0],"images.image0": [- "11",+ "op_fill",0],"resolution": "resize",@@ -177,14 +177,81 @@"feathering": 24},"_meta": {- "title": "Border to draw"+ "title": "Border to draw (its mask)"+ }+ },+ "op_size": {+ "class_type": "GetImageSize",+ "inputs": {+ "image": [+ "op_pad",+ 0+ ]+ },+ "_meta": {+ "title": "Canvas size"+ }+ },+ "op_stretch": {+ "class_type": "ImageScale",+ "inputs": {+ "image": [+ "op_scale",+ 0+ ],+ "upscale_method": "bilinear",+ "width": [+ "op_size",+ 0+ ],+ "height": [+ "op_size",+ 1+ ],+ "crop": "disabled"+ },+ "_meta": {+ "title": "Photo stretched to the canvas"+ }+ },+ "op_blur": {+ "class_type": "ImageBlur",+ "inputs": {+ "image": [+ "op_stretch",+ 0+ ],+ "blur_radius": 31,+ "sigma": 10.0+ },+ "_meta": {+ "title": "Blurred"+ }+ },+ "op_fill": {+ "class_type": "ImageCompositeMasked",+ "inputs": {+ "destination": [+ "op_blur",+ 0+ ],+ "source": [+ "op_scale",+ 0+ ],+ "x": 192,+ "y": 192,+ "resize_source": false+ },+ "_meta": {+ "title": "Photo on its blurred canvas"}},"op_encode": {"class_type": "VAEEncode","inputs": {"pixels": [- "op_pad",+ "op_fill",0],"vae": [@@ -193,7 +260,7 @@]},"_meta": {- "title": "Encode the padded photo"+ "title": "Encode the canvas"}},"op_latent": {diff --git a/lab/cases.json b/lab/cases.jsonindex 4ed7278..8f58d14 100644--- a/lab/cases.json+++ b/lab/cases.json@@ -105,7 +105,7 @@"note": "Only the jacket changes; face, hair and background stay."},{"id": "character-market", "showcase": true, "app": "character", "values": {"reference": "@case:ref-face-a", "scene": "walking through a night market, string lights, light rain"},"note": "Same woman (face, hair) in a new scene."},- {"id": "cinema-studio-detective", "showcase": true, "app": "cinema-studio", "values": {"camera": "grand format 70mm film camera", "lens": "1970s cinema prime lens"},+ {"id": "cinema-studio-detective", "showcase": true, "app": "cinema-studio", "values": {"prompt": "A detective in a trench coat lights a cigarette under a streetlamp on a rainy night", "camera": "the rich detail and fine grain of large-format 70mm film", "lens": "the warm, slightly soft rendering of 1970s cinema glass"},"note": "The camera and lens words should show: film grain and a vintage look."},{"id": "remove-bg-product", "showcase": true, "app": "remove-bg", "values": {"image": "@case:ref-product"},"note": "A clean cut-out of the bottle with transparency."},@@ -579,7 +579,7 @@{"id": "tpl-expand-image", "showcase": true, "app": "expand-image", "values": {"image": "@case:ref-fx-lake", "direction": "out"},"note": "Expand Image. Does the border continue the lake, rock and sky, with no seam or gray left?"},{"id": "tpl-ai-influencer", "showcase": true, "app": "ai-influencer", "values": {"niche": "fitness influencer stretching on a rooftop at sunrise in workout clothes"},- "note": "Influencer IA. A believable person, not a glossy render?"},+ "note": "AI Influencer. A believable person, not a glossy render?"},{"id": "tpl-bullet-time-scene", "showcase": true, "app": "bullet-time-scene", "values": {"image": "@case:ref-fx-jump", "subject": "a parkour athlete in a black t-shirt leaping between two rooftops"},"note": "Bullet Time Scene. Does the camera orbit while the athlete and the city stay frozen?"},{"id": "tpl-bullet-time-white", "showcase": true, "app": "bullet-time-white", "values": {"image": "@case:ref-character", "subject": "a man in a red jacket, jeans and white sneakers"},diff --git a/tools/template_apps.py b/tools/template_apps.pyindex ebe83c5..b002b85 100644--- a/tools/template_apps.py+++ b/tools/template_apps.py@@ -21,8 +21,8 @@ these bases, all workflows built by tools/build_apps.py:effect Wan 2.1 image-to-video with one effect LoRA fixed (apps/effects); "effect_lora" names iteffect-klein the same, after FLUX 3 Klein redraws the photo with the fixed "klein" instruction(merged in as edit:*): for effects that need another background or something added first- edit + outpaint the edit pipeline on a padded canvas: the sampler starts from the photo with gray borders- and a noise mask on them, so only the new border is drawn; a select sets the padding+ edit + outpaint the edit pipeline on a bigger canvas: the photo sits on a stretched, blurred copy of itself,+ with a noise mask on the border, so only the border is drawn; a select sets the paddingThe app folder gets the base workflow (copied, or with the few edits noted in BASES) and a manifestwhose "details" input carries the prompt as a bind template; selects feed {placeholders} in thatprompt. The base app's models and credits are copied as they are (qwen-edit swaps the LoRA).@@ -126,8 +126,10 @@ def A(id_, name, feature, cat, base, image_label, summary, prompt, inputs=(), redef pad(left, top, right, bottom):- """The sets of an outpaint select option: pixels added on each side of the photo (scaled to 1 MP first)."""- return [{"node": "op_pad", "field": f, "value": v} for f, v in (("left", left), ("top", top), ("right", right), ("bottom", bottom))]+ """The sets of an outpaint select option: pixels added on each side of the photo (scaled to 1 MP first), and+ where the photo sits on the filled canvas."""+ return ([{"node": "op_pad", "field": f, "value": v} for f, v in (("left", left), ("top", top), ("right", right), ("bottom", bottom))]+ + [{"node": "op_fill", "field": "x", "value": left}, {"node": "op_fill", "field": "y", "value": top}])# ---------------------------------------------------------------- ads & products (apps/edit pipeline, a product photo)@@ -504,14 +506,14 @@ A("idol", "Idol", "Idol", "clips", "video", "Your photo",# ---------------------------------------------------------------- the canvas, a new person, one effect LoRAA("expand-image", "Expand Image", "Expand Image", "style", "edit", "Your photo","Grows a photo past its edges: FLUX 3 Image Klein draws only the new border, so the original stays as it was.",- "Extend this photo outward into the gray border around it: continue the scene, its objects, light and perspective naturally past the "- "original edges, as if the camera had pulled back. The original part of the photo stays exactly the same; no frame, no border, no text.",+ "The outer part of this photo is blurred: redraw it sharp, continuing the scene, its objects, light and perspective naturally out to all "+ "four edges, as if the camera had pulled back. The sharp center stays exactly the same; one continuous photo, no frame, no border, no text.",[{"id": "direction", "type": "select", "label": "Expand", "default": "out", "options": [{"value": "out", "label": "Zoom out", "sets": pad(192, 192, 192, 192)},{"value": "wide", "label": "Wider", "sets": pad(320, 0, 320, 0)},{"value": "tall", "label": "Taller", "sets": pad(0, 320, 0, 320)}]}],LAKE, {"direction": "out"}, "Does the border continue the lake, rock and sky, with no seam or gray left?", outpaint=True)-A("ai-influencer", "AI Influencer", "Influencer IA", "portraits", "z-image", None,+A("ai-influencer", "AI Influencer", "AI Influencer", "portraits", "z-image", None,"Makes a feed-ready photo of a made-up influencer in their niche, with natural skin (Z-Image Turbo).","A vertical phone photo for a social media feed of {who}, a {niche}. Natural skin texture with visible pores, candid moment, ""realistic photo, no text, no logos.",@@ -667,8 +669,8 @@ def manifest(t: dict) -> dict:notes += (f", after FLUX 3 Klein (apps/edit, merged in as edit:*) redraws the photo with a fixed instruction (node edit:4: \"{t['klein']}\"); ""Wan starts from Klein's image")if t["outpaint"]:- notes += ("; the sampler starts from the photo scaled to 1 MP and padded by ImagePadForOutpaint (the select sets the padding), with a noise "- "mask on the border only, and the unpadded photo stays Klein's reference")+ notes += ("; the photo, scaled to 1 MP, sits on a stretched and blurred copy of itself as big as ImagePadForOutpaint's canvas (the select "+ "sets the padding); the sampler starts from that canvas with a noise mask on the border only, and the canvas is Klein's reference")if t["lora"]:lora = QWEN_LORAS[t["lora"]]models = [m for m in models if "Relight" not in m["file"]] + [{"repo": lora["repo"], "file": lora["file"], "dir": "loras", "gb": lora["gb"], "phase": "denoise", "license": lora["license"]}]@@ -737,15 +739,23 @@ def workflow(t: dict) -> dict:n["inputs"][k] = ["52", 0]elif is_link(v) and v[0] == "52" and not i.startswith("edit:"):n["inputs"][k] = ["edit:8", 0]- if t["outpaint"]: # draw only the border: start from the padded photo, noise mask on the padding, the photo as reference+ if t["outpaint"]: # draw only the border. The canvas around the photo is the photo itself, stretched and blurred: on a flat+ # gray border (ImagePadForOutpaint's own fill) Klein drew a gray frame around the photo (run 20261024-172353-h100)api["op_scale"] = {"class_type": "ImageScaleToTotalPixels", "inputs": {"image": ["11", 0], "upscale_method": "lanczos", "megapixels": 1.0,"resolution_steps": 16}, "_meta": {"title": "Photo at 1 MP"}}api["op_pad"] = {"class_type": "ImagePadForOutpaint", "inputs": {"image": ["op_scale", 0], "left": 192, "top": 192, "right": 192, "bottom": 192,- "feathering": 24}, "_meta": {"title": "Border to draw"}}- api["op_encode"] = {"class_type": "VAEEncode", "inputs": {"pixels": ["op_pad", 0], "vae": ["3", 0]}, "_meta": {"title": "Encode the padded photo"}}+ "feathering": 24}, "_meta": {"title": "Border to draw (its mask)"}}+ api["op_size"] = {"class_type": "GetImageSize", "inputs": {"image": ["op_pad", 0]}, "_meta": {"title": "Canvas size"}}+ api["op_stretch"] = {"class_type": "ImageScale", "inputs": {"image": ["op_scale", 0], "upscale_method": "bilinear", "width": ["op_size", 0],+ "height": ["op_size", 1], "crop": "disabled"}, "_meta": {"title": "Photo stretched to the canvas"}}+ api["op_blur"] = {"class_type": "ImageBlur", "inputs": {"image": ["op_stretch", 0], "blur_radius": 31, "sigma": 10.0}, "_meta": {"title": "Blurred"}}+ api["op_fill"] = {"class_type": "ImageCompositeMasked", "inputs": {"destination": ["op_blur", 0], "source": ["op_scale", 0], "x": 192, "y": 192,+ "resize_source": False}, "_meta": {"title": "Photo on its blurred canvas"}}+ api["op_encode"] = {"class_type": "VAEEncode", "inputs": {"pixels": ["op_fill", 0], "vae": ["3", 0]}, "_meta": {"title": "Encode the canvas"}}api["op_latent"] = {"class_type": "SetLatentNoiseMask", "inputs": {"samples": ["op_encode", 0], "mask": ["op_pad", 1]},"_meta": {"title": "Only the border is drawn"}}api["7"]["inputs"]["latent_image"] = ["op_latent", 0]+ api["17"]["inputs"]["images.image0"] = ["op_fill", 0] # the reference has the canvas's shape, so Klein fills it edge to edgeif t["base"] in ("morph", "effect-klein"): # the image Klein draws is fixed per template (placeholders filled with the defaults)defaults = {i["id"]: i.get("default", "") for i in t["inputs"]}api[base["klein"][0]]["inputs"][base["klein"][1]] = re.sub(r"\{([a-z][a-z0-9_]*)\}", lambda m: str(defaults.get(m.group(1), "")), t["klein"])@@ -797,6 +807,7 @@ def readme() -> str:for t in T:ins = [x.lower() for x in (t["image_label"], t["image2_label"]) if x] + [i["label"].lower() for i in t["inputs"]]base = BASES[t["base"]]["app"] + (f" + {QWEN_LORAS[t['lora']]['repo'].split('/')[1]}" if t["lora"] else "")+ base = "edit + effects" if t["base"] == "effect-klein" else baserows.append(f"| `{t['id']}` | {t['feature']} | `{base}` | {', '.join(ins)} |")return "\n".join(rows)