{
"visual_evidence": [
- "A small dark website address sits against the white background at the bottom-left edge.",
- "The kite and its curved string of lettering are separate from the website address.",
- "The area immediately above the address is blank and provides matching background pixels."
- ],
- "target_object": "The website address at the bottom left",
- "target_region": "The narrow strip along the bottom-left edge, spanning roughly the leftmost 23% of the image width.",
- "editing_intent": "Remove the website address, including its faint letter edges, so the white background looks continuous.",
- "editing_plan": [
- "Compare the address area with a clean white patch directly above it to identify the text pixels.",
- "Expand the mask slightly to cover antialiased edges and nearby compression traces.",
- "Copy pixels from the clean patch, match their brightness to the adjacent background, and feather the outer edge of the repair."
- ],
- "preservation_constraints": [
- "Keep the kite and its curved lettering unchanged.",
- "Leave all pixels outside the repair mask unchanged.",
- "Preserve the original dimensions and framing."
+ "A black dog lies across a skateboard.",
+ "The skateboard has a dark deck, a visible wooden edge, and a pale yellow wheel.",
+ "Light-colored paving surrounds the dog and skateboard.",
+ "A decorative border surrounds the photograph."
+ ],
+ "target_object": "The paved ground surrounding and beneath the skateboard",
+ "target_region": "The photograph interior, excluding the dog, skateboard, wheel, and decorative border",
+ "editing_intent": "Replace the paving with textured grass so the skateboard rests on grass while retaining the dog and skateboard.",
+ "editing_plan": [
+ "Trace separate masks for the dog, skateboard deck, and visible wheel using relative coordinates.",
+ "Refine the dog's silhouette using the dark fur along its boundary.",
+ "Synthesize a natural lawn using multiscale color variation, overlapping fine grass blades, highlights, and photographic grain.",
+ "Add soft cast shadows beneath the dog and skateboard and a tighter contact shadow beneath the wheel.",
+ "Blend the grass around the preserved foreground and leave the decorative border unchanged."
+ ],
+ "preservation_constraints": [
+ "Preserve the dog's appearance, pose, eyes, and fur.",
+ "Preserve the skateboard's shape, deck texture, wooden edge, and visible wheel.",
+ "Do not move or resize the foreground objects.",
+ "Preserve the decorative border and original image dimensions."
]
}
def edit(image):
- import math
- import cv2
import numpy as np
+ import cv2
from PIL import Image
+ image = image.convert('RGB')
w, h = image.size
- rgb = np.array(image.convert('RGB'), dtype=np.uint8)
- x1 = min(w, max(1, math.ceil(0.23 * w)))
- y0 = int(0.938 * h)
- y1 = min(h, math.ceil(0.988 * h))
- shift = min(y0, max(1, round(0.060 * h)))
- patch = rgb[y0 - shift:y1 - shift, :x1].astype(np.float32)
- target = rgb[y0:y1, :x1].astype(np.float32)
-
- # Match the patch to the background using clean pixels to the right.
- ref0 = max(x1, math.ceil(0.246 * w))
- ref1 = min(w, math.ceil(0.40 * w))
- if ref1 > ref0:
- here = rgb[y0:y1, ref0:ref1].astype(np.float32)
- above = rgb[y0 - shift:y1 - shift, ref0:ref1].astype(np.float32)
- offset = np.median(here - above, axis=(0, 1))
- patch = np.clip(patch + offset, 0, 255)
-
- # Include faint lettering, then grow the mask over the antialiased fringe.
- delta = cv2.cvtColor(patch, cv2.COLOR_RGB2GRAY) - cv2.cvtColor(target, cv2.COLOR_RGB2GRAY)
- seeds = (delta > 2.5).astype(np.uint8)
- radius = max(1, round(0.004 * min(w, h)))
- kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * radius + 1, 2 * radius + 1))
- core = cv2.dilate(seeds, kernel)
- if not core.any():
- return image.copy()
-
- # Feather only outside the solid mask; keep the copied background texture.
- distance = cv2.distanceTransform(1 - core, cv2.DIST_L2, cv2.DIST_MASK_PRECISE)
- alpha = np.clip(1.0 - distance / max(1.5, 0.005 * min(w, h)), 0.0, 1.0)
- alpha = (alpha * alpha * (3.0 - 2.0 * alpha))[..., None]
- rgb[y0:y1, :x1] = np.rint(target * (1.0 - alpha) + patch * alpha).astype(np.uint8)
- result = Image.fromarray(rgb)
- if 'A' in image.getbands():
- result.putalpha(image.getchannel('A'))
- return result
{
"visual_evidence": [
- "A yellow fire hydrant stands in the snow on the right side of the image.",
- "The hydrant has a left-facing nozzle and a dark contact shadow beneath its base.",
- "The snow immediately to its right provides nearby texture for the fill.",
- "The skateboard is on the pavement in the foreground, well outside the edit area."
- ],
- "target_object": "The yellow fire hydrant and its dark contact shadow",
- "target_region": "The upper-right snowbank, roughly 75–90% across the image and 29–56% down, just above the pavement.",
- "editing_intent": "Remove the hydrant and its contact shadow, replacing them with textured snow that blends into the surrounding bank.",
- "editing_plan": [
- "Trace the hydrant, including its nozzle and base shadow, with a close-fitting mask.",
- "Copy snow texture from the clean strip immediately to the right, sampling at similar heights.",
- "Match the copied snow's broad shading to the snow around the mask while retaining fine texture and grain.",
- "Feather the fill into the surrounding snow and leave all pixels outside the feather unchanged."
- ],
- "preservation_constraints": [
- "Keep the skateboard and its shadow unchanged.",
- "Preserve the pavement, sidewalk joints, and snow-pavement boundary.",
- "Leave the tree trunk, background, and snow outside the localized edit unchanged."
+ "A dark horse stands left of center in the snowy field.",
+ "Its head and body rise above the upper fence rail, while its legs are visible through the rail gaps.",
+ "The muzzle overlaps a short section of the upper wooden rail.",
+ "Nearby unobstructed areas contain snow, dry vegetation, and weathered fence texture."
+ ],
+ "target_object": "The horse",
+ "target_region": "The horse silhouette behind the left-center fence, including its head, muzzle, body, and visible legs.",
+ "editing_intent": "Remove the horse and reconstruct snow and sparse vegetation behind it, preserving the foreground fence and repairing the rail obscured by its muzzle.",
+ "editing_plan": [
+ "Mask the horse body and visible legs with source-relative contours and a small edge margin.",
+ "Separate the foreground fence rails from the removal mask, except where the muzzle obscures the upper rail.",
+ "Sample unobstructed snow and vegetation to the right of the horse.",
+ "Warp the sampled texture separately within each fence gap so that donor rails do not appear in the reconstructed background.",
+ "Repair the obscured rail using texture sampled from the same rail.",
+ "Use inpainting along the narrow mask boundary and feather the synthesized texture into it.",
+ "Return the edited image while retaining all pixels outside the removal region."
+ ],
+ "preservation_constraints": [
+ "Keep the sky, distant hills, water, shoreline, and utility pole unchanged.",
+ "Preserve the visible fence rails and posts outside the muzzle overlap.",
+ "Keep the right-side shrubs and all unobstructed snow and vegetation unchanged.",
+ "Do not add animals, buildings, or additional fence components."
]
}
def edit(image):
- import cv2
import numpy as np
+ import cv2
from PIL import Image
+ original = image.convert('RGB')
w, h = image.size
- scale = float(min(w, h))
- original = np.array(image.convert('RGB'))
- rgb = original.astype(np.float32)
+ src = np.asarray(original).copy()
+ scale = min(w, h)
- # Trace the cap, barrel, nozzle, and dark footing in normalized coordinates.
- outline = np.array([
- (.843, .286), (.858, .287), (.860, .298), (.875, .300),
- (.883, .312), (.889, .328), (.887, .399), (.884, .461),
- (.882, .529), (.892, .536), (.897, .547), (.894, .555),
- (.868, .558), (.827, .553), (.784, .547), (.779, .539),
- (.797, .529), (.799, .476), (.801, .445), (.798, .415),
- (.778, .415), (.774, .395), (.758, .391), (.755, .373),
- (.769, .365), (.773, .348), (.797, .346), (.807, .342),
- (.815, .318), (.826, .301), (.840, .296)
- ], dtype=np.float32)
- points = np.rint(outline * [w - 1, h - 1]).astype(np.int32)
- mask = np.zeros((h, w), np.uint8)
- cv2.fillPoly(mask, [points], 255)
-
- bx, by, bw, bh = cv2.boundingRect(mask)
- pad = max(8, int(np.ceil(.055 * scale)))
- x0, x1 = max(0, bx - pad), min(w, bx + bw + pad)
- y0, y1 = max(0, by - pad), min(h, by + bh + pad)
- local = rgb[y0:y1, x0:x1]
- outside = (mask[y0:y1, x0:x1] == 0).astype(np.uint8)
- dist = cv2.distanceTransform(outside, cv2.DIST_L2, cv2.DIST_MASK_PRECISE)
- guard = max(1., .0055 * scale)
- feather = max(1., .008 * scale)
- radius = guard + feather
- blend = np.clip((radius - dist) / feather, 0., 1.)
- blend = blend * blend * (3. - 2. * blend)
- active = blend > 0.
-
- # Sample an unoccluded strip to the right without copying the pavement.
- yy, xx = np.mgrid[y0:y1, x0:x1].astype(np.float32)
- nx = xx / max(w - 1, 1)
- ny = yy / max(h - 1, 1)
- sx = np.clip(.908 + .54 * (nx - .755) + .002 * np.sin(35. * (ny - .32)),
- .904, .989) * (w - 1)
- sy = yy + h * (.001 - .003 * np.sin(26. * (ny - .286)))
- donor = cv2.remap(rgb, sx.astype(np.float32), sy.astype(np.float32),
- cv2.INTER_CUBIC, borderMode=cv2.BORDER_REFLECT_101)
-
- def gaussian(arr, sigma):
- return cv2.GaussianBlur(arr, (0, 0), sigmaX=sigma, sigmaY=sigma,
- borderType=cv2.BORDER_REFLECT_101)
-
- # Estimate the color correction from clean surroundings only. Smooth the
- # correction, not the donor, so the snow's sampled detail stays intact.
- clean = (dist > guard).astype(np.float32)
- low_sigma = max(.8, .0075 * scale)
- lo_weight = gaussian(clean, low_sigma)
- scene_low = gaussian(local * clean[..., None], low_sigma)
- scene_low /= np.maximum(lo_weight[..., None], 1.e-5)
- donor_low = gaussian(donor, low_sigma)
- boundary = (~active).astype(np.float32)
- residual = (scene_low - donor_low) * boundary[..., None]
- warm_sigma = max(2., .035 * scale)
- correction = gaussian(residual, warm_sigma)
- correction /= np.maximum(gaussian(boundary, warm_sigma)[..., None], 1.e-5)
- correction[~active] = residual[~active]
- stencil = np.array([[0., .25, 0.], [.25, 0., .25], [0., .25, 0.]], np.float32)
- for _ in range(480):
- average = cv2.filter2D(correction, -1, stencil, borderType=cv2.BORDER_REFLECT_101)
- correction[active] = average[active]
- filled = donor + correction
-
- # Restore a small amount of fine luminance grain lost to resampling.
- chip = rgb[int(.30 * h):max(int(.30 * h) + 1, int(.53 * h)),
- int(.916 * w):max(int(.916 * w) + 1, int(.984 * w))]
- if chip.shape[0] >= 3 and chip.shape[1] >= 3:
- luminance = cv2.cvtColor(chip, cv2.COLOR_RGB2GRAY)
- high = luminance - gaussian(luminance, max(.65, .0017 * scale))
- mad = np.median(np.abs(high - np.median(high)))
- noise_sd = float(np.clip(.45 * 1.4826 * mad, .18, 1.4))
- grain = np.random.default_rng(37).normal(0., noise_sd, blend.shape).astype(np.float32)
- filled += grain[..., None]
-
- mixed = local + blend[..., None] * (filled - local)
- result = original.copy()
- result[y0:y1, x0:x1][active] = np.clip(np.rint(mixed[active]), 0, 255).astype(np.uint8)
- return Image.fromarray(result)
-
The visible pizza has been fully replaced with a rectangular frosted cake-like object, covering the full target area. The surrounding person, table, fruit, and other objects are essentially preserved. The result is visually coherent, though the cake surface is somewhat simple and flat.
The visible pizza has been fully replaced with a rectangular frosted cake-like object, covering the full target area. The surrounding person, table, fruit, and other objects are essentially preserved. The result is visually coherent, though the cake surface is somewhat simple and flat.
{
"visual_evidence": "A person is preparing food at a counter. The pizza occupies the lower-right foreground, with a browned perimeter and colorful toppings. The person's hands, utensils, fruit, clothing, and blue background are outside the intended edit.",
"target_object": "The pizza in the lower-right foreground",
"target_region": "Approximately x=0.43–0.96 and y=0.74–1.00, following the pizza's angled footprint",
@@ -2970,7 +3104,7 @@ y=7: ffffff*16 f9f9f9 c6c6c6 cbcbcb 949494 9a9a9a b9b9b9 c4c4c4 bababa bfbfbf e3
"executable_code": "def edit(image):\n import cv2\n import numpy as np\n from PIL import Image, ImageDraw, ImageFont\n \n # Convert to numpy for processing if needed, but we'll mostly use PIL Draw\n img = image.copy()\n draw = ImageDraw.Draw(img)\n \n w, h = img.size\n \n # Define colors\n maroon = (128, 0, 32) # Approximate dark maroon\n black = (0, 0, 0)\n white = (255, 255, 255)\n \n # Approximate regions based on 128x128 layout\n # Left group: 0-45, Centre group: 45-90, Right group: 90-128\n \n # --- EDIT 1: Application1 in SPIR-V Clients ---\n # The prompt says 'add a white rectangle... labelled Application1'.\n # Looking at the source, there is already a small box there. We will redraw it clearly.\n # Position: bottom right area\n app_x1, app_y1 = int(w * 0.85), int(h * 0.75)\n app_x2, app_y2 = int(w * 0.98), int(h * 0.88)\n \n # Draw white rect with black border\n draw.rectangle([app_x1, app_y1, app_x2, app_y2], fill=white, outline=black, width=1)\n \n # Label 'Application1'\n # Font size needs to be tiny for 128px width\n try:\n font_small = ImageFont.truetype(\"arial.ttf\", 6)\n font_tiny = ImageFont.truetype(\"arial.ttf\", 5)\n except:\n font_small = ImageFont.load_default()\n font_tiny = ImageFont.load_default()\n \n # Center text in box\n text = \"Application1\"\n bbox = draw.textbbox((0,0), text, font=font_tiny)\n tw, th = bbox[2]-bbox[0], bbox[3]-bbox[1]\n tx = app_x1 + (app_x2-app_x1 - tw)//2\n ty = app_y1 + (app_y1-app_y1 - th)//2\n draw.text((tx, ty), text, fill=black, font=font_tiny)\n \n # Connector from centre-left edge to 'SPIR-V Generated Library' (centre group)\n # Start: left edge of app box\n start_x, start_y = app_x1, (app_y1 + app_y2) // 2\n # End: right edge of centre group (approx x=90, y=80)\n end_x, end_y = int(w * 0.70), int(h * 0.65) \n draw.line([start_x, start_y, end_x, end_y], fill=black, width=1)\n # Add arrowhead (simple triangle)\n # Vector: end - start\n dx = end_x - start_x\n dy = end_y - start_y\n length = (dx**2 + dy**2)**0.5\n if length > 0:\n ux, uy = dx/length, dy/length\n # Arrow points\n p1 = (end_x - 4*ux + 2*uy, end_y - 4*uy - 2*ux)\n p2 = (end_x - 4*ux - 2*uy, end_y - 4*uy + 2*ux)\n draw.polygon([(end_x, end_y), p1, p2], fill=black)\n\n # --- EDIT 2: SPIR-V Library Helper in Centre Panel ---\n # Position: top-middle of centre group\n lib_x1, lib_y1 = int(w * 0.50), int(h * 0.25)\n lib_x2, lib_y2 = int(w * 0.68), int(h * 0.40)\n \n # Draw maroon rect\n draw.rectangle([lib_x1, lib_y1, lib_x2, lib_y2], fill=maroon, outline=black, width=1)\n \n # Label 'SPIR-V Library Helper' (two lines)\n text1 = \"SPIR-V Library\"\n text2 = \"Helper\"\n # Center text\n bbox1 = draw.textbbox((0,0), text1, font=font_tiny)\n bbox2 = draw.textbbox((0,0), text2, font=font_tiny)\n w1, h1 = bbox1[2]-bbox1[0], bbox1[3]-bbox1[1]\n w2, h2 = bbox2[2]-bbox2[0], bbox2[3]-bbox2[1]\n \n cx = (lib_x1 + lib_x2) // 2\n cy = (lib_y1 + lib_y2) // 2\n \n # Adjust for two lines\n total_h = h1 + h2 + 2\n start_y_text = cy - total_h // 2\n \n draw.text((cx - w1//2, start_y_text), text1, fill=white, font=font_tiny)\n draw.text((cx - w2//2, start_y_text + h1 + 2), text2, fill=white, font=font_tiny)\n \n # Arrow from bottom centre to 'SPIR-V Generated Library' (existing box below)\n # Start: bottom centre of new box\n start_x, start_y = cx, lib_y2\n # End: top of existing box (approx y=60, x=60)\n end_x, end_y = int(w * 0.58), int(h * 0.55) \n draw.line([start_x, start_y, end_x, end_y], fill=black, width=1)\n # Arrowhead\n dx = end_x - start_x\n dy = end_y - start_y\n length = (dx**2 + dy**2)**0.5\n if length > 0:\n ux, uy = dx/length, dy/length\n p1 = (end_x - 4*ux + 2*uy, end_y - 4*uy - 2*ux)\n p2 = (end_x - 4*ux - 2*uy, end_y - 4*uy + 2*ux)\n draw.polygon([(end_x, end_y), p1, p2], fill=black)\n\n # --- EDIT 3: SPIR-V Utility in SPIR-V Clients (Top) ---\n # Dashed container at top right\n cont_x1, cont_y1 = int(w * 0.78), int(h * 0.05)\n cont_x2, cont_y2 = int(w * 0.98), int(h * 0.30)\n \n # Draw dashed rectangle manually\n def draw_dashed_rect(draw, box, fill=None, outline=black, width=1, dash_length=3):\n x1, y1, x2, y2 = box\n # Top\n x = x1\n while x < x2:\n draw.line([(x, y1), (min(x+dash_length, x2), y1)], fill=outline, width=width)\n x += dash_length * 2\n # Bottom\n x = x1\n while x < x2:\n draw.line([(x, y2), (min(x+dash_length, x2), y2)], fill=outline, width=width)\n x += dash_length * 2\n # Left\n y = y1\n while y < y2:\n draw.line([(x1, y), (x1, min(y+dash_length, y2))], fill=outline, width=width)\n y += dash_length * 2\n # Right\n y = y1\n while y < y2:\n draw.line([(x2, y), (x2, min(y+dash_length, y2))], fill=outline, width=width)\n y += dash_length * 2\n\n draw_dashed_rect(draw, [cont_x1, cont_y1, cont_x2, cont_y2])\n \n # Inner maroon rectangle\n util_x1, util_y1 = cont_x1 + 2, cont_y1 + 2\n util_x2, util_y2 = cont_x2 - 2, cont_y2 - 2\n draw.rectangle([util_x1, util_y1, util_x2, util_y2], fill=maroon, outline=black, width=1)\n \n # Label 'SPIR-V Utility (ASM/DISASM)'\n text3 = \"SPIR-V Utility\"\n text4 = \"(ASM/DISASM)\"\n bbox3 = draw.textbbox((0,0), text3, font=font_tiny)\n bbox4 = draw.textbbox((0,0), text4, font=font_tiny)\n w3, h3 = bbox3[2]-bbox3[0], bbox3[3]-bbox3[1]\n w4, h4 = bbox4[2]-bbox4[0], bbox4[3]-bbox4[1]\n \n cx = (util_x1 + util_x2) // 2\n cy = (util_y1 + util_y2) // 2\n total_h = h3 + h4 + 2\n start_y_text = cy - total_h // 2\n \n draw.text((cx - w3//2, start_y_text), text3, fill=white, font=font_tiny)\n draw.text((cx - w4//2, start_y_text + h3 + 2), text4, fill=white, font=font_tiny)\n \n # Connector from mid-left edge to container's left border\n start_x, start_y = util_x1, (util_y1 + util_y2) // 2\n end_x, end_y = cont_x1, (util_y1 + util_y2) // 2 - 5 # Slightly slanted\n draw.line([start_x, start_y, end_x, end_y], fill=black, width=1)\n # Arrowhead pointing left\n dx = end_x - start_x\n dy = end_y - start_y\n length = (dx**2 + dy**2)**0.5\n if length > 0:\n ux, uy = dx/length, dy/length\n p1 = (end_x - 4*ux + 2*uy, end_y - 4*uy - 2*ux)\n p2 = (end_x - 4*ux - 2*uy, end_y - 4*uy + 2*ux)\n draw.polygon([(end_x, end_y), p1, p2], fill=black)\n\n return img",
"requires_inpaint": false
}
-```
VL + 图像:图像判分依据
The SPIR-V Library Helper box and downward arrow were added in roughly the correct place, and the top-right SPIR-V Utility container/box is partially present. However, the Utility label appears cramped/clipped, and the connector integration is rough. The requested Application1 white rectangle with black border is not properly created; it appears mostly as loose text with an arrow/connector rather than a clear bordered box. Unrelated diagram content is mostly preserved, but the added elements are visually messy and incomplete.
The SPIR-V Library Helper box and downward arrow were added in roughly the correct place, and the top-right SPIR-V Utility container/box is partially present. However, the Utility label appears cramped/clipped, and the connector integration is rough. The requested Application1 white rectangle with black border is not properly created; it appears mostly as loose text with an arrow/connector rather than a clear bordered box. Unrelated diagram content is mostly preserved, but the added elements are visually messy and incomplete.