diff --git "a/editing-progress.html" "b/editing-progress.html" --- "a/editing-progress.html" +++ "b/editing-progress.html" @@ -1,28 +1,27 @@ Qwen Pixel-Edit 当前训练进度

Qwen Pixel-Edit:当前训练进度

2026-11-27 15:06:30 北京时间 · 完整实验看板

数据构造:严格合格进度

严格合格监督(相同内容去重)

34,696 / 20,000

独立编辑任务

13,219 / 10,000

最近一小时首次严格通过:111 条;新版流水线完成候选 318。切换后的第一个小时属于不完整观测窗口,暂不据此自动推算完成日期。

所有来源统一要求:指令遵循、区域保留、画质、完整编辑范围均至少4/5,且完整目标判定为真;程序执行、复跑、依赖与英文检查通过。历史库存另列,新严格库存尚未完成全量人工审核。

存储状态:活跃数据已迁至新盘,CPU/API 数据构造已恢复;GPU 任务保持暂停。

迁移快照:SFT素材与构造文件约 69.6 GB;约59 GB的API传输归档已删除,后续不长期保存请求与回复副本。

来源严格 RFT严格 TI合计
anyedit721205926
magicbrush7924261,218
maskedit_en2,2014,1376,338
maskedit_scene1,6952,6484,343
sciforma14,1125,85219,964
ultraedit1,2606471,907

生产线心跳和实际产出

对标Qwen-Image-Edit:fine-grained数据

已从现有官方train索引 3071 个候选任务(尚未全数通过teacher)。重点:文字/数字、局部组件属性、材质、光照与几何辅助线。

2511公开卖点包含一致性、工业材质、光照和几何推理;2509还强调文字样式与多图编辑。当前主线仍是单图source-only程序,多图和新视角是待补齐能力。官方GPU基线尚未重新运行。

官方2511能力说明 · WeEdit文字编辑 · FineEdit区域编辑

单次回答的配对 prompt 测试

同一批24个训练任务,比较原版与执行约束版;相同RGB检查与图像judge。进度 384/384。排队/API错误单列,小样本结果用于选择下一轮实验。

生产线状态心跳近一小时首次严格通过错误重试预算耗尽
rft_and_rescuerunning2026-11-27T15:06:27.309339+08:00170
gpt62running2026-11-27T15:06:52.351458+08:0020
ti_balanced_en_v1running2026-11-27T15:06:48.920231+08:00811
ti_night_sol_v2waiting_for_off_peak2026-11-27T15:06:40.495619+08:0000
sol61_extra_v3waiting_for_new_tasks2026-11-27T15:06:43.164551+08:0000
teacher56_extra_v3waiting_for_new_tasks2026-11-27T15:06:50.498092+08:0000
sol62_extra_v3running2026-11-27T15:06:48.826248+08:0034
finegrained_extra_v1waiting_for_new_tasks2026-11-27T15:06:42.097762+08:0080
Teacher / prompt已完成严格合格通过率基础设施待处理
deepseek/baseline24520.8%0
deepseek/contract_v324520.8%0
gpt55/baseline24625.0%0
gpt55/contract_v324520.8%0
gpt56sol/baseline24729.2%0
gpt56sol/contract_v3241041.7%0
gpt61/baseline24937.5%0
gpt61/contract_v3241145.8%0
gpt62/baseline241145.8%0
gpt62/contract_v3241250.0%0
luna/baseline24833.3%0
luna/contract_v324625.0%0
seed21pro/baseline24312.5%0
seed21pro/contract_v32428.3%0
terra/baseline24729.2%0
terra/contract_v324937.5%0

新任务导入状态:reservoir_full;图片预算 未知 GiB,当前约 0.00 GiB。

路由优先局部像素操作和图形编辑;复杂物体合成占每条生产线滚动24小时尝试预算至多约15%。RFT至多2个teacher、独立TI至多2个Sol、语义失败补救至多1次;排队中的请求持续等待,API错误达到重试预算后保留待处理记录。原始数据与旧实验保留。

历史导出库存与已完成实验

模型输入原图和英文编辑指令,一次输出计划与 Python,程序从原图计算修改后的 RGB。下表保留旧导出口径;新的严格合格库存见上方进度。

20,859 行历史英文导出

RFT 14,417 + TI 6,442 · 独立任务 14,256。这里包含不同 teacher、增强版本及已停用来源的存档,不能作为新版严格训练集规模。新的训练快照对所有来源执行同一质量门槛。

来源RFTTI合计
anyedit1,1044081,512
instructpix2pix1,0143461,360
magicbrush5,2383,6158,853
maskedit_en6856201,305
maskedit_scene6906231,313
sciforma1,8911472,038
ultraedit3,7956834,478

最新 RL smoke:同一批 64 个 MagicBrush dev 任务

SFT 起点

3/64

代码执行 44/64

RL 后

11/64

代码执行 46/64

3 次真实参数更新,初始 SFT reference 权重不变。10 个任务由失败变成功,2 个由成功变失败。

这是自建图像 judge 的语义评估,不是官方像素指标。目前只有一个训练 seed,旧 greedy 推理存在数值重复性问题。正在用固定数值设置重复评测;不能直接归因为稳定 RL 收益。

正在推进:同 teacher、同任务的 RFT/TI 配比实验

每个配置覆盖相同的 256 个真实���练任务,TI 替换 RFT 答案。0%、25%、50% 是样本行数比例,三组总回答 token 预算均为 100 万;实际 TI token 比例另行统计。

ti00 · 157 步 · 1,001,372 / 1,000,000 回答 tokens · loss 0.46102285385131836

固定 dev64:图像 judge 11/64,代码执行 36/64。

实际TI回答token占比 0.0% · 平均每行出现 1.23 次

ti25 · 153 步 · 1,001,002 / 1,000,000 回答 tokens · loss 0.6757060885429382

固定 dev64:图像 judge 8/64,代码执行 34/64。

实际TI回答token占比 28.6% · 平均每行出现 1.20 次

ti50 · 150 步 · 1,003,372 / 1,000,000 回答 tokens · loss 0.7614325284957886

固定 dev64:图像 judge 7/64,代码执行 30/64。

实际TI回答token占比 53.7% · 平均每行出现 1.17 次

此实验限于 RFT 和 TI 都成功的任务,测试监督形式;TI 救回难任务的覆盖收益需要另一组对照。官方 benchmark、独立人工审核、跨数据集与多 seed 结果仍待补齐。

当前重复验证

固定数值设置和6k输出预算,重新测同一批dev64;第二个RL seed采用相同设置。推理完成后展示全量结果。

流程已评任务执行成功图像judge通过
SFT起点64/644311
已有RL模型64/644610
Qwen3.8零样本64/64474

InstructPix2Pix 已停用

按用户要求,不再采集或构造该来源的RFT/TI。已经生成的原始记录、图片与旧实验保留;历史库存数字包含这些存档,新训练快照排除该来源。

持续构造 SFT 数据

任务池 42,569 个 · 本次合格轨迹 8,822 条 · 对应 8,822 个任务

生产心跳:2026-11-27T15:05:34.127463+08:00 · 白天并发配置。任务池会自动读取新数据,不在 128 条或 10k 行时停止。

Teacher / 方式运行或等待 API / 并发上限待处理已完成合格轨迹待重试
GPT-5.5 · RFT0 / 808,0301,78449
GPT-6.1-Sol · RFT8 / 814,67113,0225,1702218
GPT-5.6-Terra · RFT0 / 401,06224734
GPT-5.6-Luna · RFT0 / 401,03821923
GPT-6.1-Sol · TI0 / 803,965339581
GPT-6.2-Sol · RFT4 / 412,2232,0161,06321

自动扩库:任务池已足够,随生成进度继续补充。已接入任务:{"anyedit": 14559, "maskedit_scene": 4804, "maskedit_en": 2266, "maskedit_cn": 523, "ultraedit": 11528, "instructpix2pix": 2902, "sciforma": 7362, "magicbrush": 2491}。

已导出 4,728 条新 SFT 轨迹。原有 8,601 / 12,006 条对照训练集保持冻结,新增数据单独保存,用于后续规模实验。

合格要求:一次 teacher 输出、程序过滤、执行、完整目标区域的图像 judge 和重用执行检查通过。API 或 judge 错误会重试,不计为成功样本。任务按原图内容分组,排除官方 MagicBrush dev 与现有验证图片的内容重叠。TI 在 source-only 失败后补救,学生输入只包含原图和指令。

英文 TI:独立补充训练样本

RFT成功的任务也构造TI,保留两种方法的合格轨迹。新数据只保留英文任务和监督文本;旧实验保留用于复现,中文子集不进入新训练快照。北京时间工作日18:00–09:00、周末全天提高Sol并发。1:1为训练配比对照目标,当前通过率不被人为调整。

独立TI合格样本 2,158 · 生产心跳 2026-11-27T15:06:04.703835+08:00

TI teacher运行/并发上限待处理已完成合格待重试
GPT-6.1-Sol7/816,92410,8163,3592238
GPT-6.2-Sol4/416,2106,3482,197175

非工作时间补充:61/62-Sol TI

状态 waiting_for_off_peak · 心跳 2026-11-27T15:05:49.805556+08:00。仅北京时间工作日18:00–09:00或周末发起新请求;白天保留排队中的调用。优先科研图、文字布局、区域编辑和MagicBrush。

Teacher运行或等待 / 上限待构造合格轨迹
GPT-6.1-Sol0/019,5532,961
GPT-6.2-Sol0/016,5681,924

每个teacher增加至多16个夜间请求槽;额外候选使用独立ID,不改写旧轨迹。并发上限包含可能仍在API队列中的请求,不代表完成速度。

当前英文SFT库存:按样本行数统计,可相加

数据来源RFT行数TI行数合计
anyedit1,1044081,512
instructpix2pix1,0143461,360
magicbrush5,2383,6158,853
maskedit_en6856201,305
maskedit_scene6906231,313
sciforma1,8911472,038
ultraedit3,7956834,478

英文SFT行数 20,859 = RFT 14,417 + TI 6,442;独立任务覆盖 14,256。行数包含不同teacher轨迹和增强版本,后续冻结训练快照另做完全相同监督内容的去重。

展示样本的质量门槛

下方是历史候选的图像展示:自建图像judge通过、画质与保留评分至少4/5。页面顶部的新版严格库存还要求指令遵循、完整编辑范围至少4/5和完整目标判定。InstructPix2Pix已停用,旧记录存档保留,新库存排除。

质量筛选后的候选:Add a single toasted bagel resting on top of the four-slot toaster on the countertop, aligned naturally with the appliance and matching the scene perspective and lighting. Keep the toaster, countertop, microwaves, walls, posters, trash bin, window area, and all other objects, text, colors, layout, lighting, and camera perspective unchanged.

maskedit_scene · GPT-6.1-Sol · RFT · 自建图像judge通过 · 画质4/5 · 保留5/5

原图
单次 teacher 代码执行
数据集目标
完整 teacher 计划与代码
{
+.rgb-images{grid-template-columns:repeat(5,1fr)}a{color:var(--accent)}@media(max-width:700px){.rgb-images{grid-template-columns:1fr 1fr}} .gain64-images{grid-template-columns:repeat(4,1fr)}@media(max-width:700px){.gain64-images{grid-template-columns:1fr 1fr}}

Qwen Pixel-Edit:当前训练进度

2026-11-27 15:09:36 北京时间 · 完整实验看板

数据构造:严格合格进度

严格合格监督(相同内容去重)

34,702 / 20,000

独立编辑任务

13,220 / 10,000

最近一小时首次严格通过:114 条;新版流水线完成候选 321。切换后的第一个小时属于不完整观测窗口,暂不据此自动推算完成日期。

所有来源统一要求:指令遵循、区域保留、画质、完整编辑范围均至少4/5,且完整目标判定为真;程序执行、复跑、依赖与英文检查通过。历史库存另列,新严格库存尚未完成全量人工审核。

存储状态:活跃数据已迁至新盘,CPU/API 数据构造已恢复;GPU 任务保持暂停。

迁移快照:SFT素材与构造文件约 69.6 GB;约59 GB的API传输归档已删除,后续不长期保存请求与回复副本。

来源严格 RFT严格 TI合计
anyedit721205926
magicbrush7924261,218
maskedit_en2,2014,1376,338
maskedit_scene1,6952,6484,343
sciforma14,1125,85719,969
ultraedit1,2616471,908

生产线心跳和实际产出

对标Qwen-Image-Edit:fine-grained数据

已从现有官方train索引 3071 个候选任务(尚未全数通过teacher)。重点:文字/数字、局部组件属性、材质、光照与几何辅助线。

2511公开卖点包含一致性、工业材质、光照和几何推理;2509还强调文字样式与多图编辑。当前主线仍是单图source-only程序,多图和新视角是待补齐能力。官方GPU基线尚未重新运行。

官方2511能力说明 · WeEdit文字编辑 · FineEdit区域编辑

单次回答的配对 prompt 测试

同一批24个训练任务,比较原版与执行约束版;相同RGB检查与图像judge。进度 384/384。排队/API错误单列,小样本结果用于选择下一轮实验。

生产线状态���跳近一小时首次严格通过错误重试预算耗尽
rft_and_rescuerunning2026-11-27T15:09:26.851348+08:00190
gpt62running2026-11-27T15:09:44.633999+08:0000
ti_balanced_en_v1running2026-11-27T15:09:55.984058+08:00841
ti_night_sol_v2waiting_for_off_peak2026-11-27T15:09:31.325620+08:0000
sol61_extra_v3waiting_for_new_tasks2026-11-27T15:09:54.188044+08:0000
teacher56_extra_v3waiting_for_new_tasks2026-11-27T15:09:44.387341+08:0000
sol62_extra_v3running2026-11-27T15:09:38.853761+08:0034
finegrained_extra_v1waiting_for_new_tasks2026-11-27T15:09:54.342998+08:0080
Teacher / prompt已完成严格合格通过率基础设施待处理
deepseek/baseline24520.8%0
deepseek/contract_v324520.8%0
gpt55/baseline24625.0%0
gpt55/contract_v324520.8%0
gpt56sol/baseline24729.2%0
gpt56sol/contract_v3241041.7%0
gpt61/baseline24937.5%0
gpt61/contract_v3241145.8%0
gpt62/baseline241145.8%0
gpt62/contract_v3241250.0%0
luna/baseline24833.3%0
luna/contract_v324625.0%0
seed21pro/baseline24312.5%0
seed21pro/contract_v32428.3%0
terra/baseline24729.2%0
terra/contract_v324937.5%0

新任务导入状态:reservoir_full;图片预算 未知 GiB,当前约 0.00 GiB。

路由优先局部像素操作和图形编辑;复杂物体合成占每条生产线滚动24小时尝试预算至多约15%。RFT至多2个teacher、独立TI至多2个Sol、语义失败补救至多1次;排队中的请求持续等待,API错误达到重试预算后保留待处理记录。原始数据与旧实验保留。

历史导出库存与已完成实验

模型输入原图和英文编辑指令,一次输出计划与 Python,程序从原图计算修改后的 RGB。下表保留旧导出口径;新的严格合格库存见上方进度。

20,859 行历史英文导出

RFT 14,417 + TI 6,442 · 独立任务 14,256。这里包含不同 teacher、增强版本及已停用来源的存档,不能作为新版严格训练集规模。新的训练快照对所有来源执行同一质量门槛。

来源RFTTI合计
anyedit1,1044081,512
instructpix2pix1,0143461,360
magicbrush5,2383,6158,853
maskedit_en6856201,305
maskedit_scene6906231,313
sciforma1,8911472,038
ultraedit3,7956834,478

最新 RL smoke:同一批 64 个 MagicBrush dev 任务

SFT 起点

3/64

代码执行 44/64

RL 后

11/64

代码执行 46/64

3 次真实参数更新,初始 SFT reference 权重不变。10 个任务由失败变成功,2 个由成功变失败。

这是自建图像 judge 的语义评估,不是官方像素指标。目前只有一个训练 seed,旧 greedy 推理存在数值重复性问题。正在用固定数值设置重复评测;不能直接归因为稳定 RL 收益。

正在推进:同 teacher、同任务的 RFT/TI 配比实验

每个配置覆盖相同的 256 个真实训练任务,TI 替换 RFT 答案。0%、25%、50% 是样本行数比例,三组总回答 token 预算均为 100 万;实际 TI token 比例另行统计。

ti00 · 157 步 · 1,001,372 / 1,000,000 回答 tokens · loss 0.46102285385131836

固定 dev64:图像 judge 11/64,代码执行 36/64。

实际TI回答token占比 0.0% · 平均每行出现 1.23 次

ti25 · 153 步 · 1,001,002 / 1,000,000 回答 tokens · loss 0.6757060885429382

固定 dev64:图像 judge 8/64,代码执行 34/64。

实际TI回答token占比 28.6% · 平均每行出现 1.20 次

ti50 · 150 步 · 1,003,372 / 1,000,000 回答 tokens · loss 0.7614325284957886

固定 dev64:图像 judge 7/64,代码执行 30/64。

实际TI回答token占比 53.7% · 平均每行出现 1.17 次

此实验限于 RFT 和 TI 都成功的任务,测试监督形式;TI 救回难任务的覆盖收益需要另一组对照。官方 benchmark、独立人工审核、跨数据集与多 seed 结果仍待补齐。

当前重复验证

固定数值设置和6k输出预算,重新测同一批dev64;第二个RL seed采用相同设置。推理完成后展示全量结果。

流程已评任务执行成功图像judge通过
SFT起点64/644311
已有RL模型64/644610
Qwen3.8零样本64/64474

InstructPix2Pix 已停用

按用户要求,不再采集或构造该来源的RFT/TI。已经生成的原始记录、图片与旧实验保留;历史库存数字包含这些存档,新训练快照排除该来源。

持续构造 SFT 数据

任务池 42,569 个 · 本次合格轨迹 8,825 条 · 对应 8,825 个任务

生产心跳:2026-11-27T15:08:48.588637+08:00 · 白天并发配置。任务池会自动读取新数据,不在 128 条或 10k 行时停止。

Teacher / 方式运行或等待 API / 并发上限待处理已完成合格轨迹待重试
GPT-5.5 · RFT0 / 808,0301,78449
GPT-6.1-Sol · RFT7 / 814,66313,0315,1732218
GPT-5.6-Terra · RFT0 / 401,06224734
GPT-5.6-Luna · RFT0 / 401,03821923
GPT-6.1-Sol · TI0 / 803,965339581
GPT-6.2-Sol · RFT3 / 412,2282,0161,06323

自动扩库:任务池已足够,随生成进度继续补充。已接入任务:{"anyedit": 14559, "maskedit_scene": 4804, "maskedit_en": 2266, "maskedit_cn": 523, "ultraedit": 11528, "instructpix2pix": 2902, "sciforma": 7362, "magicbrush": 2491}。

已导出 4,728 条新 SFT 轨迹。原有 8,601 / 12,006 条对照训练集保持冻结,新增数据单独保存,用于后续规模实验。

合格要求:一次 teacher 输出、程序过滤、执行、完整目标区域的图像 judge 和重用执行检查通过。API 或 judge 错误会重试,不计为成功样本。任务按原图内容分组,排除官方 MagicBrush dev 与现有验证图片的内容重叠。TI 在 source-only 失败后补救,学生输入只包含原图和指令。

英文 TI:独立补充训练样本

RFT成功的任务也构造TI,保留两种方���的合格轨迹。新数据只保留英文任务和监督文本;旧实验保留用于复现,中文子集不进入新训练快照。北京时间工作日18:00–09:00、周末全天提高Sol并发。1:1为训练配比对照目标,当前通过率不被人为调整。

独立TI合格样本 2,158 · 生产心跳 2026-11-27T15:09:14.321648+08:00

TI teacher运行/并发上限待处理已完成合格待重试
GPT-6.1-Sol7/816,91610,8243,3632236
GPT-6.2-Sol4/416,2146,3482,197175

非工作时间补充:61/62-Sol TI

状态 waiting_for_off_peak · 心跳 2026-11-27T15:09:07.360791+08:00。仅北京时间工作日18:00–09:00或周末发起新请求;白天保留排队中的调用。优先科研图、文字布局、区域编辑和MagicBrush。

Teacher运行或等待 / 上限待构造合格轨迹
GPT-6.1-Sol0/019,5532,961
GPT-6.2-Sol0/016,5681,924

每个teacher增加至多16个夜间请求槽;额外候选使用独立ID,不改写旧轨迹。并发上限包含可能仍在API队列中的请求,不代表完成速度。

当前英文SFT库存:按样本行数统计,可相加

数据来源RFT行数TI行数合计
anyedit1,1044081,512
instructpix2pix1,0143461,360
magicbrush5,2383,6158,853
maskedit_en6856201,305
maskedit_scene6906231,313
sciforma1,8911472,038
ultraedit3,7956834,478

英文SFT行数 20,859 = RFT 14,417 + TI 6,442;独立任务覆盖 14,256。行数包含不同teacher轨迹和增强版本,后续冻结训练快照另做完全相同监督内容的去重。

展示样本的质量门槛

下方是历史候选的图像展示:自建图像judge通过、画质与保留评分至少4/5。页面顶部的新版严格库存还要求指令遵循、完整编辑范围至少4/5和完整目标判定。InstructPix2Pix已停用,旧记录存档保留,新库存排除。

质量筛选后的候选:make it a snowy winter wonderland

ultraedit · GPT-6.1-Sol · RFT · 自建图像judge通过 · 画质4/5 · 保留4/5

原图
单次 teacher 代码执行
数据集目标
完整 teacher 计划与代码
{
   "visual_evidence": [
-    "A silver four-slot toaster sits on a brown mat to the left of two stacked white microwaves.",
-    "The toaster's exposed top is viewed obliquely from above.",
-    "The scene has warm indoor lighting, with additional light from the window on the right."
+    "Several wooden benches recede diagonally into the distance.",
+    "The benches have dark wooden seats and backrests with pale curved supports.",
+    "Textured pavement surrounds the benches.",
+    "The scene is already subdued and nearly monochrome."
   ],
-  "target_object": "The exposed top of the four-slot toaster",
-  "target_region": "The silver slotted surface on the left side of the countertop, immediately beside the stacked microwaves",
-  "editing_intent": "Add one toasted bagel lying flat on the toaster, with a visible central hole, realistic crust texture, perspective, and a localized contact shadow.",
+  "target_object": "The pavement, bench seating surfaces, upper bench edges, and surrounding atmosphere",
+  "target_region": "The full scene, with localized snow accumulation on the ground and exposed bench surfaces",
+  "editing_intent": "Create a snowy winter scene with textured ground coverage, accumulated snow on the benches, cool lighting, and gentle falling snow.",
   "editing_plan": [
-    "Locate the toaster top using relative image coordinates.",
-    "Construct an irregular three-dimensional bagel and project it onto the toaster's top plane.",
-    "Render golden toasted crust, darker mottling, fine pores, and directional shading.",
-    "Add a soft contact shadow confined to the toaster top.",
-    "Antialias and composite the bagel while preserving all pixels outside the addition and its shadow."
+    "Apply a restrained cool winter color grade while retaining the original structural detail.",
+    "Mask the visible pavement around the bench silhouettes and synthesize softly shaded, granular snow.",
+    "Add perspective-aligned snow layers to the wooden seats, preserving the gaps between planks.",
+    "Build irregular snow caps along the backrest edges and curved support tops, with feathered boundaries and subtle contact shadows.",
+    "Add varied, softly rendered falling snowflakes without obscuring the benches."
   ],
   "preservation_constraints": [
-    "Do not move, reshape, or recolor the toaster.",
-    "Keep both microwaves and their controls unchanged.",
-    "Preserve the countertop, brown mat, cabinets, walls, posters, and all visible text.",
-    "Keep the trash bin and window area unchanged.",
-    "Preserve the original framing, camera perspective, and scene lighting.",
-    "Add only one bagel."
+    "Keep the number, arrangement, and perspective of the benches unchanged.",
+    "Preserve the curved supports, wooden backrest faces, and gaps between seat planks.",
+    "Retain visible structural edges and underlying surface shading.",
+    "Do not add people, buildings, trees, or other objects."
   ]
 }
 
@@ -31,680 +30,640 @@ def edit(image):
     import cv2
     from PIL import Image
 
+    src = np.asarray(image.convert('RGB'), dtype=np.float32)
     w, h = image.size
-    s = float(min(w, h))
-    original = np.asarray(image.convert('RGB')).astype(np.float32)
-    rng = np.random.default_rng(2184)
-
-    # The bagel lies on the toaster's tilted top plane.
-    cx, cy = 0.370 * w, 0.454 * h
-    x0 = max(0, int(np.floor(cx - 0.080 * s)))
-    x1 = min(w, int(np.ceil(cx + 0.080 * s)))
-    y0 = max(0, int(np.floor(cy - 0.055 * s)))
-    y1 = min(h, int(np.ceil(cy + 0.055 * s)))
-    pw, ph = x1 - x0, y1 - y0
-    ss = 4
-    rw, rh = pw * ss, ph * ss
-    gx = x0 + (np.arange(rw, dtype=np.float32) + 0.5) / ss
-    gy = y0 + (np.arange(rh, dtype=np.float32) + 0.5) / ss
-    X, Y = np.meshgrid((gx - cx) / s, (gy - cy) / s)
-
-    # Horizontal plane coordinates project diagonally across the toaster.
-    P = np.array([[1.0, -0.42], [0.18, 0.53]], dtype=np.float32)
-    inv = np.linalg.inv(P)
-    radius = 0.0330
-    tube = 0.0155
-    half_height = 0.0087
-    zmax = 0.0200
-    steps = 190
-    dz = zmax / steps
-    hit = np.zeros((rh, rw), dtype=bool)
-    surface_z = np.zeros((rh, rw), dtype=np.float32)
-    previous = np.full((rh, rw), 100.0, dtype=np.float32)
-
-    # Ray intersection with an organically irregular flattened torus.
-    for z in np.linspace(zmax, 0.0, steps + 1):
-        U = inv[0, 0] * X + inv[0, 1] * (Y + z)
-        V = inv[1, 0] * X + inv[1, 1] * (Y + z)
-        theta = np.arctan2(V, U)
-        radial = np.sqrt(U * U + V * V)
-        R = radius * (1.0 + 0.018 * np.sin(3.0 * theta + 0.7) + 0.009 * np.sin(7.0 * theta))
-        r = tube * (1.0 + 0.035 * np.sin(5.0 * theta + 1.1) + 0.016 * np.sin(9.0 * theta))
-        k = half_height * (1.0 + 0.045 * np.sin(4.0 * theta + 0.5))
-        F = ((radial - R) / r) ** 2 + ((z - k) / k) ** 2 - 1.0
-        entering = (F <= 0.0) & (~hit)
-        fraction = np.clip(F / (F - previous + 1e-12), 0.0, 1.0)
-        surface_z[entering] = z + dz * fraction[entering]
-        hit |= entering
-        previous = F
-
-    U = inv[0, 0] * X + inv[0, 1] * (Y + surface_z)
-    V = inv[1, 0] * X + inv[1, 1] * (Y + surface_z)
-    theta = np.arctan2(V, U)
-    radial = np.sqrt(U * U + V * V)
-    R = radius * (1.0 + 0.018 * np.sin(3.0 * theta + 0.7) + 0.009 * np.sin(7.0 * theta))
-    r = tube * (1.0 + 0.035 * np.sin(5.0 * theta + 1.1) + 0.016 * np.sin(9.0 * theta))
-    k = half_height * (1.0 + 0.045 * np.sin(4.0 * theta + 0.5))
-    radial_part = np.clip((radial - R) / r, -1.0, 1.0)
-    vertical_part = np.clip((surface_z - k) / k, -1.0, 1.0)
-    phi = np.arctan2(vertical_part, radial_part)
-
-    # Periodic multiscale crust texture, synthesized without external assets.
-    texsize = 256
-    def noise_field(sigma):
-        a = rng.standard_normal((texsize, texsize)).astype(np.float32)
-        pad = int(np.ceil(4.0 * sigma)) + 2
-        padded = np.pad(a, ((pad, pad), (pad, pad)), mode='wrap')
-        b = cv2.GaussianBlur(padded, (0, 0), sigmaX=sigma, sigmaY=sigma)
-        b = b[pad:pad + texsize, pad:pad + texsize]
-        return (b - b.mean()) / (b.std() + 1e-6)
-
-    mapx = ((theta % (2.0 * np.pi)) * texsize / (2.0 * np.pi)).astype(np.float32)
-    mapy = ((phi % (2.0 * np.pi)) * texsize / (2.0 * np.pi)).astype(np.float32)
-    def sample(field):
-        return cv2.remap(field, mapx, mapy, cv2.INTER_LINEAR, borderMode=cv2.BORDER_WRAP)
-
-    broad = sample(noise_field(12.0))
-    mottled = sample(noise_field(3.0))
-    fine = sample(noise_field(0.60))
-    pores = sample(noise_field(0.32))
-
-    toast = np.clip(0.35 + 0.16 * broad + 0.095 * mottled + 0.14 * np.maximum(vertical_part, 0.0), 0.02, 0.92)
-    golden = np.array([225.0, 165.0, 94.0], dtype=np.float32)
-    browned = np.array([155.0, 87.0, 39.0], dtype=np.float32)
-    color = golden[None, None, :] * (1.0 - toast[..., None]) + browned[None, None, :] * toast[..., None]
-
-    # A subdued, uneven paler band on the outer side gives baked-bread structure.
-    seam_phi = 0.04 + 0.055 * np.sin(6.0 * theta) + 0.025 * np.sin(13.0 * theta)
-    seam = np.exp(-((phi - seam_phi) / 0.24) ** 2)
-    seam *= np.clip(radial_part, 0.0, 1.0) * 0.46
-    seam_color = np.array([225.0, 176.0, 115.0], dtype=np.float32)
-    color = color * (1.0 - seam[..., None]) + seam_color * seam[..., None]
-
-    # Surface normals and warm, diffuse illumination.
-    nx = np.cos(theta) * radial_part / r
-    ny = np.sin(theta) * radial_part / r
-    nz = vertical_part / k
-    nx += 1.6 * mottled + 0.8 * fine
-    ny += 1.2 * fine
-    norm = np.sqrt(nx * nx + ny * ny + nz * nz) + 1e-8
-    nx, ny, nz = nx / norm, ny / norm, nz / norm
-    light = np.array([-0.48, -0.40, 0.90], dtype=np.float32)
-    light /= np.linalg.norm(light)
-    diffuse = np.maximum(nx * light[0] + ny * light[1] + nz * light[2], 0.0)
-    illumination = 0.72 + 0.32 * diffuse
-    inner_darkening = 1.0 - 0.13 * np.maximum(-radial_part, 0.0)
-    bottom_darkening = 0.86 + 0.14 * np.clip(surface_z / (half_height * 0.85), 0.0, 1.0)
-    texture_factor = 1.0 + 0.026 * fine + 0.017 * mottled
-    tiny_pores = np.clip((-pores - 1.15) * 0.055, 0.0, 0.13)
-    color *= (illumination * inner_darkening * bottom_darkening * texture_factor * (1.0 - tiny_pores))[..., None]
-    highlight = 5.0 * diffuse ** 16
-    color += highlight[..., None] * np.array([1.0, 0.84, 0.57], dtype=np.float32)
-    color += rng.normal(0.0, 0.60, color.shape).astype(np.float32)
-    color = np.clip(color, 0.0, 255.0)
-
-    # Localized shadow projected onto the toaster surface, not the countertop.
-    shadow_x = X - 0.0022
-    shadow_y = Y - 0.0030
-    ground_u = inv[0, 0] * shadow_x + inv[0, 1] * shadow_y
-    ground_v = inv[1, 0] * shadow_x + inv[1, 1] * shadow_y
-    ground_r = np.sqrt(ground_u ** 2 + ground_v ** 2)
-    outer = radius + tube
-    inner = radius - tube
-    disk = (ground_r <= outer).astype(np.float32)
-    annulus = ((ground_r <= outer) & (ground_r >= inner)).astype(np.float32)
-    soft_sigma = max(0.5, 0.0021 * s * ss)
-    contact_sigma = max(0.4, 0.00085 * s * ss)
-    soft = cv2.GaussianBlur(disk, (0, 0), soft_sigma)
-    contact = cv2.GaussianBlur(annulus, (0, 0), contact_sigma)
-    shadow = np.clip(0.13 * soft + 0.20 * contact, 0.0, 0.34)
-
-    top_mask = np.zeros((rh, rw), dtype=np.uint8)
-    top_points = np.array([
-        [0.292 * w, 0.474 * h],
-        [0.344 * w, 0.419 * h],
-        [0.449 * w, 0.438 * h],
-        [0.419 * w, 0.495 * h]
-    ], dtype=np.float32)
-    top_points[:, 0] = (top_points[:, 0] - x0) * ss
-    top_points[:, 1] = (top_points[:, 1] - y0) * ss
-    cv2.fillConvexPoly(top_mask, np.rint(top_points).astype(np.int32), 255)
-    shadow *= top_mask.astype(np.float32) / 255.0
-
-    # Area downsampling supplies feathered subpixel edges without blurring the scene.
-    coverage_hi = hit.astype(np.float32)
-    coverage = cv2.resize(coverage_hi, (pw, ph), interpolation=cv2.INTER_AREA)
-    premultiplied = cv2.resize(color * coverage_hi[..., None], (pw, ph), interpolation=cv2.INTER_AREA)
-    shadow_low = cv2.resize(shadow, (pw, ph), interpolation=cv2.INTER_AREA)
-    patch = original[y0:y1, x0:x1].copy()
-    shaded = patch * (1.0 - shadow_low[..., None])
-    edited_patch = shaded * (1.0 - coverage[..., None]) + premultiplied
-    active = (coverage > 0.0) | (shadow_low > 0.0005)
-    output = original.copy()
-    destination = output[y0:y1, x0:x1]
-    destination[active] = edited_patch[active]
-    return Image.fromarray(np.clip(np.rint(output), 0, 255).astype(np.uint8), 'RGB')

质量筛选后的候选:Remove only the elephant figure from the right-center inside the sign, seamlessly filling its area with the existing yellow and red background texture. Keep the rest of the sign, including the car icon, motorcycle rider icon, diagonal red slash, black metal frame, and all background elements completely unchanged.

maskedit_scene · GPT-6.1-Sol · RFT · 自建图像judge通过 · 画质5/5 · 保留5/5

原图
单次 teacher 代码执行
数据集目标
完整 teacher 计划与代码
{
+    scale = min(w, h) / 512.0
+    rng = np.random.default_rng(7319)
+    lum = src[..., 0] * 0.299 + src[..., 1] * 0.587 + src[..., 2] * 0.114
+    yy, xx = np.mgrid[0:h, 0:w].astype(np.float32)
+    yn = yy / max(h - 1, 1)
+
+    def blur(a, sigma):
+        return cv2.GaussianBlur(a.astype(np.float32), (0, 0), max(0.15, sigma))
+
+    def polygon(points):
+        mask = np.zeros((h, w), np.float32)
+        pts = np.array([[round(x * (w - 1)), round(y * (h - 1))] for x, y in points], np.int32)
+        cv2.fillPoly(mask, [pts], 1.0)
+        return mask
+
+    def noise_grid(nx, ny):
+        field = rng.normal(0, 1, (ny, nx)).astype(np.float32)
+        field = cv2.resize(field, (w, h), interpolation=cv2.INTER_CUBIC)
+        return field / max(float(field.std()), 0.001)
+
+    broad = noise_grid(13, 15)
+    medium = noise_grid(55, 57)
+    fine = rng.normal(0, 1, (h, w)).astype(np.float32)
+    detail = lum - blur(lum, max(1.0, 2.0 * scale))
+    # Cool the scene without flattening the dark wood or pale supports.
+    winter = src * 0.92 + np.array([5.0, 8.0, 13.0], np.float32)
+    highlights = np.clip((lum - 150.0) / 85.0, 0, 1)[..., None]
+    winter += highlights * np.array([7.0, 8.0, 9.0], np.float32)
+    out = np.clip(winter, 0, 255)
+
+    # Pavement masks follow the visible outside contours of the bench row.
+    left_ground = polygon([
+        (0, 0), (.176, 0), (.172, .035), (.158, .13), (.158, .19),
+        (.145, .236), (.131, .319), (.119, .355), (.138, .426),
+        (.122, .461), (.12, .538), (.104, .563), (.102, .663),
+        (.096, .716), (.11, .792), (.092, .854), (.096, .935),
+        (.083, 1), (0, 1)
+    ])
+    upper_ground = polygon([
+        (.315, 0), (1, 0), (1, .443), (.945, .42), (.888, .423),
+        (.816, .468), (.726, .4), (.723, .338), (.703, .285),
+        (.65, .258), (.585, .274), (.533, .302), (.478, .263),
+        (.48, .238), (.514, .209), (.528, .157), (.498, .13),
+        (.46, .115), (.43, .111), (.406, .128), (.38, .098),
+        (.395, .079), (.381, .05), (.348, .036), (.316, .019)
+    ])
+    right_ground = polygon([
+        (1, .645), (.97, .657), (.93, .702), (.902, .78),
+        (.854, .9), (.827, 1), (1, 1)
+    ])
+    center_ground = polygon([
+        (.402, .591), (.462, .552), (.516, .578), (.625, .689),
+        (.643, .719), (.604, .804), (.572, .835), (.53, .848),
+        (.494, .79), (.455, .709)
+    ])
+    ground = np.maximum.reduce([left_ground, upper_ground, right_ground, center_ground])
+    ground = np.clip(blur(ground, 0.75 * scale), 0, 1)
+    # Preserve the pavement's grain and broad light variation underneath the snow.
+    snow_value = 211.0 + 0.24 * (lum - 105.0) + 3.5 * broad + 1.8 * medium
+    snow_value += 0.31 * detail + 1.25 * fine - 6.0 * yn
+    ground_rgb = np.stack([snow_value - 5.0, snow_value + 0.5, snow_value + 7.0], axis=-1)
+    ground_rgb = np.clip(ground_rgb, 0, 250)
+    a = (ground * 0.97)[..., None]
+    out = out * (1 - a) + ground_rgb * a
+
+    # Individual horizontal plank surfaces; gaps remain unpainted.
+    seat_polygons = [
+        [(.142, .549), (.258, .566), (.332, .987), (.104, .941)],
+        [(.275, .572), (.386, .576), (.532, 1), (.348, 1)],
+        [(.156, .253), (.222, .27), (.239, .367), (.146, .354)],
+        [(.23, .276), (.287, .288), (.32, .389), (.241, .368)],
+        [(.17, .108), (.228, .119), (.229, .185), (.159, .17)],
+        [(.235, .121), (.253, .126), (.274, .188), (.235, .186)],
+        [(.177, .045), (.208, .049), (.215, .065), (.172, .062)],
+        [(.174, .073), (.218, .079), (.222, .096), (.168, .092)]
+    ]
+    seats = np.zeros((h, w), np.float32)
+    for pts in seat_polygons:
+        seats = np.maximum(seats, polygon(pts))
+    irregular = np.clip(0.94 + 0.10 * broad + 0.055 * medium, 0.68, 1.0)
+    seat_alpha = blur(seats * irregular, 0.8 * scale)
+    seat_value = 230.0 + 4.0 * broad + 2.3 * medium + 1.5 * fine
+    seat_value += np.clip((lum - 100.0) * 0.14, -13, 14) + detail * 0.16
+    seat_rgb = np.clip(np.stack([seat_value - 3, seat_value, seat_value + 5], axis=-1), 0, 253)
+    a = np.clip(seat_alpha, 0, 1)[..., None]
+    out = out * (1 - a) + seat_rgb * a
+
+    # Irregular ridges grow upward from the sloping top edges, not across the whole backrest.
+    def ridge(points, thickness):
+        pts = np.array([[x * (w - 1), y * (h - 1)] for x, y in points], np.float32)
+        lower, upper = [], []
+        for k in range(len(pts) - 1):
+            start, end = pts[k], pts[k + 1]
+            d = end - start
+            length = float(np.linalg.norm(d))
+            if length < 0.001:
+                continue
+            n = np.array([d[1], -d[0]], np.float32) / length
+            if n[1] > 0:
+                n = -n
+            count = max(6, int(length / max(2.0 * scale, 0.5)))
+            for t in np.linspace(0, 1, count, endpoint=(k == len(pts) - 2)):
+                p = start + t * d
+                taper = 0.72 + 0.28 * np.sin(np.pi * t)
+                depth = thickness * h * taper * rng.uniform(0.78, 1.2)
+                lower.append(p - n * 0.6 * scale)
+                upper.append(p + n * depth)
+        mask = np.zeros((h, w), np.float32)
+        if lower:
+            shape = np.array(lower + upper[::-1], np.int32)
+            cv2.fillPoly(mask, [shape], 1.0)
+        return mask
+
+    caps = np.zeros((h, w), np.float32)
+    ridge_specs = [
+        ([(.542, .293), (.854, .532)], .012),
+        ([(.5, .390), (.789, .712)], .011),
+        ([(.385, .149), (.436, .199)], .008),
+        ([(.362, .195), (.423, .250)], .007),
+        ([(.262, .006), (.325, .075)], .0055),
+        ([(.255, .032), (.314, .098)], .005),
+        ([(.594, .284), (.621, .270), (.655, .270), (.685, .286)], .006),
+        ([(.821, .471), (.851, .447), (.889, .431), (.926, .429), (.958, .438), (.984, .452)], .009),
+        ([(.414, .134), (.434, .122), (.459, .121), (.482, .134)], .0055),
+        ([(.347, .071), (.365, .058), (.383, .066)], .004)
+    ]
+    for points, thick in ridge_specs:
+        caps = np.maximum(caps, ridge(points, thick))
+    caps = np.clip(blur(caps, max(0.45, 0.6 * scale)), 0, 1)
+    # Soft contact shadow immediately below the raised snow cap.
+    shift = max(1, round(2.0 * scale))
+    displaced = cv2.warpAffine(caps, np.array([[1, 0, 0], [0, 1, shift]], np.float32), (w, h))
+    shadow = np.clip(blur(displaced, 1.0 * scale) - caps, 0, 1) * 0.18
+    out *= 1 - shadow[..., None]
+    cap_value = 239.0 + 2.5 * broad + 1.8 * medium + 1.1 * fine
+    cap_rgb = np.clip(np.stack([cap_value - 3, cap_value, cap_value + 4], axis=-1), 0, 254)
+    a = (caps * 0.97)[..., None]
+    out = out * (1 - a) + cap_rgb * a
+
+    # Restrained atmospheric lift retains the recognizable dark backrest faces.
+    haze = 0.035 * (1 - yn)
+    out = out * (1 - haze[..., None]) + np.array([215, 225, 236], np.float32) * haze[..., None]
+
+    # A mixture of crisp distant flakes and softer near-camera flakes.
+    flakes = np.zeros((h, w), np.float32)
+    for _ in range(190):
+        x = float(rng.uniform(0, w - 1))
+        y = float(rng.uniform(0, h - 1))
+        radius = float(rng.uniform(0.35, 1.05) * scale)
+        opacity = float(rng.uniform(0.24, 0.73))
+        r = max(2, int(np.ceil(radius * 3.0)))
+        x0, x1 = max(0, int(x) - r), min(w, int(x) + r + 1)
+        y0, y1 = max(0, int(y) - r), min(h, int(y) + r + 1)
+        if x1 <= x0 or y1 <= y0:
+            continue
+        gy, gx = np.mgrid[y0:y1, x0:x1]
+        flake = opacity * np.exp(-((gx - x) ** 2 + ((gy - y) / 1.3) ** 2) / (2 * max(radius, 0.28) ** 2))
+        flakes[y0:y1, x0:x1] = np.maximum(flakes[y0:y1, x0:x1], flake)
+    for _ in range(16):
+        x, y = float(rng.uniform(0, w - 1)), float(rng.uniform(0, h - 1))
+        radius = float(rng.uniform(1.3, 2.5) * scale)
+        r = max(3, int(np.ceil(radius * 3)))
+        x0, x1 = max(0, int(x) - r), min(w, int(x) + r + 1)
+        y0, y1 = max(0, int(y) - r), min(h, int(y) + r + 1)
+        if x1 <= x0 or y1 <= y0:
+            continue
+        gy, gx = np.mgrid[y0:y1, x0:x1]
+        flake = rng.uniform(0.2, 0.45) * np.exp(-((gx - x) ** 2 + (gy - y) ** 2) / (2 * max(radius, 0.4) ** 2))
+        flakes[y0:y1, x0:x1] = np.maximum(flakes[y0:y1, x0:x1], flake)
+    a = np.clip(flakes, 0, 0.85)[..., None]
+    out = out * (1 - a) + np.array([249, 251, 255], np.float32) * a
+    return Image.fromarray(np.clip(out, 0, 255).astype(np.uint8), 'RGB')

质量筛选后的候选:Replace the blank white laptop screen with a colorful video editing software interface showing multiple timeline tracks and preview windows. Keep the laptop body, keyboard, surrounding couch fabric, headphones, melodica keyboard, microphone, cables, all other text, lighting, camera perspective, and overall scene unchanged.

maskedit_scene · GPT-6.1-Sol · RFT · 自建图像judge通过 · 画质4/5 · 保留5/5

原图
单次 teacher 代码执行
数据集目标
完整 teacher 计划与代码
{
   "visual_evidence": [
-    "A black elephant figure occupies the right-center of the circular sign.",
-    "The elephant overlaps both the yellow interior and the diagonal red slash.",
-    "The sign has a textured surface, a car icon above, and a motorcycle rider icon below-left.",
-    "A black metal frame surrounds the sign, with trees and pavement behind it."
+    "A silver Dell laptop sits diagonally on patterned couch fabric.",
+    "The laptop display is almost entirely blank white, with thin blue edges.",
+    "The keyboard, palm rest, screen bezel, and Dell logo are visible.",
+    "Headphones, a melodica, a desktop microphone, and cables surround the laptop."
   ],
-  "target_object": "The black elephant figure only",
-  "target_region": "Approximately 59–69% of the image width and 45–67% of the image height, inside the sign",
-  "editing_intent": "Remove the elephant and reconstruct the textured yellow field and the interrupted red slash beneath it.",
+  "target_object": "The blank interior of the laptop screen",
+  "target_region": "The tilted quadrilateral inside the screen bezel, excluding the existing blue display edges",
+  "editing_intent": "Replace the blank display with a detailed, colorful video-editing interface containing two preview windows, media thumbnails, playback controls, and six timeline tracks.",
   "editing_plan": [
-    "Identify the elephant's dark silhouette inside a tightly bounded search region and include its interior markings and antialiased edges.",
-    "Estimate the two edges of the diagonal red slash from its unobstructed section to the left.",
-    "Synthesize yellow pixels using clean yellow texture from the same sign and a fitted local shading model.",
-    "Copy red-slash texture along the slash direction, aligning both edges and correcting gradual color differences.",
-    "Feather the replacement only around the elephant mask and retain all other original pixels."
+    "Define a perspective-aligned mask confined to the white display interior.",
+    "Generate textured scenic preview imagery using gradients, layered terrain, reflections, and noise.",
+    "Construct a detailed editing interface with menus, a media bin, two preview panels, colored video clips, audio waveforms, and level meters.",
+    "Project the interface into the original screen perspective.",
+    "Match screen illumination with subtle glare, shading, and fine noise, then feather the replacement inward at its boundary.",
+    "Return the edited image with every pixel outside the display mask preserved."
   ],
   "preservation_constraints": [
-    "Keep the car icon unchanged.",
-    "Keep the motorcycle rider icon unchanged.",
-    "Preserve the diagonal red slash, restoring only the portion hidden by the elephant.",
-    "Keep the circular sign border and black metal frame unchanged.",
-    "Keep all trees, lighting, pavement, and other background elements unchanged."
+    "Preserve the laptop bezel, Dell logo, keyboard, palm rest, stickers, and indicator lights.",
+    "Preserve the surrounding couch fabric and its patterns.",
+    "Preserve the headphones, melodica, microphone, cables, and all text outside the replaced screen interior.",
+    "Do not change the camera perspective, image dimensions, or surrounding lighting."
   ]
 }
 
 def edit(image):
-    import cv2
     import numpy as np
-    from PIL import Image
+    import cv2
+    from PIL import Image, ImageDraw, ImageFont
 
     w, h = image.size
-    src = np.asarray(image.convert('RGB')).copy()
-    f = src.astype(np.float32)
-    scale = min(w / 1451.0, h / 1084.0)
-
-    # Restrict segmentation to the elephant, excluding the car above it.
-    x0, x1 = int(0.586*w), int(0.693*w)
-    y0, y1 = int(0.454*h), int(0.677*h)
-    roi = src[y0:y1, x0:x1]
-    dark = ((roi[:,:,0] < 112) & (roi[:,:,1] < 108) &
-            (roi[:,:,2] < 108)).astype(np.uint8) * 255
-    contours, _ = cv2.findContours(dark, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
-    mask = np.zeros((h, w), np.uint8)
-    local = np.zeros(dark.shape, np.uint8)
-    if contours:
-        largest = max(contours, key=cv2.contourArea)
-        cv2.drawContours(local, [largest], -1, 255, cv2.FILLED)
-    else:
-        # A conservative silhouette fallback, still confined to the elephant.
-        pts = np.array([[.590,.462],[.604,.455],[.624,.470],[.636,.466],
-                        [.648,.474],[.677,.463],[.687,.466],[.688,.491],
-                        [.681,.516],[.661,.537],[.657,.562],[.662,.591],
-                        [.659,.637],[.651,.658],[.639,.663],[.631,.651],
-                        [.629,.599],[.623,.599],[.624,.645],[.620,.665],
-                        [.610,.669],[.603,.652],[.604,.614],[.600,.585],
-                        [.603,.558],[.598,.536],[.599,.519],[.593,.500]])
-        pts = np.round(pts * np.array([w,h])).astype(np.int32)
-        cv2.fillPoly(mask, [pts], 255)
-    mask[y0:y1, x0:x1] = np.maximum(mask[y0:y1, x0:x1], local)
-    rad = max(1, int(round(3.0*scale)))
-    kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2*rad+1, 2*rad+1))
-    outer = cv2.dilate(mask, kernel)
-
-    # Locate unobstructed red-slash edges to the left of the elephant.
-    r, g, b = f[:,:,0], f[:,:,1], f[:,:,2]
-    red_class = (r > 115) & (r > 1.8*g) & (r > 1.8*b)
-    xs, tops, bottoms = [], [], []
-    for x in range(int(.470*w), int(.585*w), max(1, int(round(scale)))):
-        ya, yb = int(.425*h), int(.697*h)
-        col = red_class[ya:yb, x].astype(np.uint8)
-        changes = np.diff(np.r_[0, col, 0].astype(np.int16))
-        starts = np.flatnonzero(changes == 1)
-        ends = np.flatnonzero(changes == -1)
-        if len(starts) == 0:
-            continue
-        expected = .615*(x/w)*w + .080*h
-        candidates = [(s,e) for s,e in zip(starts,ends)
-                      if .045*h < e-s < .125*h and abs(ya+s-expected) < .035*h]
-        if not candidates:
-            continue
-        s,e = min(candidates, key=lambda q: abs(ya+q[0]-expected))
-        xs.append(x)
-        tops.append(ya+s-.5)
-        bottoms.append(ya+e-.5)
-    if len(xs) >= 8:
-        top_line = np.polyfit(xs, tops, 1)
-        bottom_line = np.polyfit(xs, bottoms, 1)
-        # Reject isolated segmentation irregularities before the final fit.
-        xx = np.asarray(xs)
-        tt, bb = np.asarray(tops), np.asarray(bottoms)
-        good = (np.abs(tt-np.polyval(top_line,xx)) < 2.5*scale) & (np.abs(bb-np.polyval(bottom_line,xx)) < 2.5*scale)
-        if np.count_nonzero(good) >= 6:
-            top_line = np.polyfit(xx[good],tt[good],1)
-            bottom_line = np.polyfit(xx[good],bb[good],1)
-    else:
-        top_line = np.array([.614*h/w*1451/1084, .079*h])
-        bottom_line = np.array([.616*h/w*1451/1084, .162*h])
-
-    # Fit smooth material shading to visible pixels of the sign.
-    yellow_class = (r > 155) & (g > 85) & (b < 110) & (r > 1.12*g) & (g > 1.5*b)
-    yy, xx = np.mgrid[0:h,0:w]
-    training = ((xx > .255*w) & (xx < .737*w) &
-                (yy > .310*h) & (yy < .785*h) & (outer == 0))
-    stride = max(2, int(round(3*scale)))
-    sampled = np.zeros((h,w), bool)
-    sampled[::stride,::stride] = True
-    def design(x,y):
-        u = np.asarray(x, dtype=np.float32)/w - .60
-        v = np.asarray(y, dtype=np.float32)/h - .56
-        return np.stack([np.ones_like(u),u,v,u*u,u*v,v*v],axis=-1)
-    def fit_material(selection):
-        cy,cx = np.nonzero(training & sampled & selection)
-        A = design(cx,cy)
-        values = f[cy,cx]
-        coef = np.linalg.lstsq(A,values,rcond=None)[0]
-        for _ in range(3):
-            errors = np.linalg.norm(values-A@coef,axis=1)
-            keep = errors < max(9.0,float(np.percentile(errors,88)))
-            coef = np.linalg.lstsq(A[keep],values[keep],rcond=None)[0]
-        return coef
-    yellow_model = fit_material(yellow_class)
-    red_model = fit_material(red_class)
-
-    # A clean yellow patch supplies actual fine crackle and grain.
-    px0,px1 = int(.249*w),int(.361*w)
-    py0,py1 = int(.475*h),int(.589*h)
-    patch = f[py0:py1,px0:px1]
-    smooth = cv2.GaussianBlur(patch,(0,0),max(.8,3.0*scale))
-    grain = patch-smooth
-    grain -= grain.mean(axis=(0,1),keepdims=True)
-
-    ys,xs = np.nonzero(outer)
-    bx0,bx1 = max(0,xs.min()-2),min(w,xs.max()+3)
-    by0,by1 = max(0,ys.min()-2),min(h,ys.max()+3)
-    Y,X = np.mgrid[by0:by1,bx0:bx1].astype(np.float32)
-    target_basis = design(X,Y)
-    yellow_base = target_basis@yellow_model
-    ph,pw = grain.shape[:2]
-    def reflect_coordinates(values,length):
-        period = max(2,2*(length-1))
-        q = np.mod(values,period)
-        return np.where(q <= length-1,q,period-q).astype(np.float32)
-    gx = reflect_coordinates(X-bx0+17*scale,pw)
-    gy = reflect_coordinates(Y-by0+23*scale,ph)
-    yellow_texture = cv2.remap(grain,gx,gy,cv2.INTER_LINEAR,borderMode=cv2.BORDER_REFLECT_101)
-    yellow_fill = yellow_base+yellow_texture
-
-    # Transfer an unobstructed portion of the same slash along its direction.
-    donor_x = X-.138*w
-    top_t = top_line[0]*X+top_line[1]
-    bot_t = bottom_line[0]*X+bottom_line[1]
-    top_s = top_line[0]*donor_x+top_line[1]
-    bot_s = bottom_line[0]*donor_x+bottom_line[1]
-    donor_y = top_s+(Y-top_t)*(bot_s-top_s)/np.maximum(bot_t-top_t,1.0)
-    donor = cv2.remap(f,donor_x.astype(np.float32),donor_y.astype(np.float32),
-                      cv2.INTER_LINEAR,borderMode=cv2.BORDER_REFLECT_101)
-    donor_basis = design(donor_x,donor_y)
-    red_weight = np.clip((.56-donor[:,:,1]/np.maximum(donor[:,:,0],1.0))/.34,0,1)
-    yellow_correction = yellow_base-donor_basis@yellow_model
-    red_correction = target_basis@red_model-donor_basis@red_model
-    corrected_donor = donor+red_weight[:,:,None]*red_correction+(1-red_weight[:,:,None])*yellow_correction
-    # Keep the copied physical boundary, transitioning to synthesized yellow
-    # only well outside the slash, where both sources are yellow.
-    outside = np.maximum(np.maximum(top_t-Y,Y-bot_t),0)
-    use_donor = np.clip((14.0*scale-outside)/max(1.0,8.0*scale),0,1)
-    replacement = use_donor[:,:,None]*corrected_donor+(1-use_donor[:,:,None])*yellow_fill
-
-    # Every original pixel outside the small silhouette footprint stays exact.
-    distance = cv2.distanceTransform(outer,cv2.DIST_L2,5)
-    alpha = np.clip(distance/max(1.0,2.0*scale),0,1)[by0:by1,bx0:bx1,None]
-    original = f[by0:by1,bx0:bx1]
-    blended = np.clip(np.rint(original*(1-alpha)+replacement*alpha),0,255).astype(np.uint8)
-    out = src.copy()
-    active = outer[by0:by1,bx0:bx1] > 0
-    destination = out[by0:by1,bx0:bx1]
-    destination[active] = blended[active]
-    return Image.fromarray(out, 'RGB')

质量筛选后的候选:alter the dogs to cats

anyedit · GPT-6.1-Sol · RFT · 自建图像judge通过 · 画质4/5 · 保留4/5

原图
单次 teacher 代码执行
数据集目标
完整 teacher 计划与代码
{
+    original = np.array(image.convert('RGB'))
+    rng = np.random.default_rng(731)
+    U = max(800, int(round(w * 0.90)))
+    V = int(round(U * 0.625))
+    canvas = Image.new('RGB', (U, V), (43, 48, 58))
+    d = ImageDraw.Draw(canvas)
+
+    def box(x0, y0, x1, y1, fill, outline=None):
+        d.rectangle((int(x0*U), int(y0*V), int(x1*U), int(y1*V)), fill=fill, outline=outline)
+
+    def line(points, fill, width=1):
+        d.line([(int(x*U), int(y*V)) for x, y in points], fill=fill, width=max(1, int(width*U/1200)))
+
+    def text(x, y, value, color=(204, 212, 222), size=0.017):
+        fs = max(8, int(V*size))
+        try:
+            font = ImageFont.load_default(size=fs)
+        except TypeError:
+            font = ImageFont.load_default()
+        d.text((int(x*U), int(y*V)), value, fill=color, font=font)
+
+    def landscape(pw, ph, shift=0.0):
+        yy, xx = np.mgrid[0:ph, 0:pw].astype(np.float32)
+        xx /= max(1, pw-1)
+        yy /= max(1, ph-1)
+        top = np.array([64, 106, 163], np.float32)
+        bottom = np.array([238, 171, 118], np.float32)
+        f = np.clip(yy/0.72, 0, 1)[..., None]
+        a = top[None, None, :]*(1-f) + bottom[None, None, :]*f
+        glow = np.exp(-(((xx-0.68)/0.25)**2 + ((yy-0.37)/0.31)**2))
+        a += glow[..., None]*np.array([26, 18, 4], np.float32)
+        sun = np.exp(-(((xx-0.68)/0.019)**2 + ((yy-0.35)/0.034)**2)*2.5)
+        a = a*(1-sun[..., None]*0.78) + np.array([255, 237, 190])*sun[..., None]*0.78
+        fine = rng.normal(0, 1.8, (ph, pw)).astype(np.float32)
+        cloud = cv2.GaussianBlur(rng.normal(0, 1, (ph, pw)).astype(np.float32), (0, 0), max(1, pw*0.018))
+        a += fine[..., None] + cloud[..., None]*34
+        coords = np.linspace(0, 1, pw)
+        for level, col, amp, seedcount in [(0.48, (111, 111, 137), 0.11, 19), (0.56, (69, 86, 115), 0.105, 27), (0.63, (41, 63, 84), 0.095, 31)]:
+            controls = rng.uniform(-1, 1, seedcount)
+            ridge = level + amp*np.interp(coords, np.linspace(0, 1, seedcount), controls)
+            ridge = cv2.GaussianBlur(ridge.astype(np.float32).reshape(1, -1), (0, 0), max(1, pw*0.006)).ravel()
+            mask = (yy > ridge[None, :]) & (yy < 0.69)
+            terrain = np.asarray(col, np.float32)[None, None, :] + (yy-level)[..., None]*19 + fine[..., None]*1.6
+            a[mask] = terrain[mask]
+        water = yy >= 0.69
+        depth = np.clip((yy-0.69)/0.31, 0, 1)
+        lake = np.array([81, 111, 134])[None, None, :]*(1-depth[..., None]) + np.array([32, 67, 87])[None, None, :]*depth[..., None]
+        reflected = np.exp(-((xx-0.68)/(0.026+depth*0.13))**2)*(1-depth*0.55)
+        ripple = np.sin(yy*ph*1.35 + np.sin(xx*27)*2.2)*0.5 + np.sin(yy*ph*0.42 + xx*18)*0.5
+        lake += reflected[..., None]*np.array([110, 68, 24])*(0.64+0.36*ripple[..., None])
+        lake += ripple[..., None]*4 + fine[..., None]*1.1
+        a[water] = lake[water]
+        bank = yy > (0.955 - 0.045*np.sin(xx*5.8+0.8) + 0.012*np.sin(xx*38))
+        foreground = np.array([22, 40, 42])[None, None, :] + fine[..., None]*2 + yy[..., None]*5
+        a[bank] = foreground[bank]
+        a += np.array([shift, shift*0.25, -shift*0.35])
+        return Image.fromarray(np.clip(a, 0, 255).astype(np.uint8))
+
+    # Application chrome and upper panels.
+    box(0, 0, 1, 0.041, (62, 69, 82))
+    box(0, 0.041, 1, 0.093, (47, 53, 65))
+    text(0.014, 0.007, 'Studio Edit  |  Couch session - Creative cut', size=0.018)
+    text(0.014, 0.056, 'File   Edit   Clip   Sequence   Markers   View   Window   Help', size=0.017)
+    text(0.807, 0.057, 'EDIT   COLOR   AUDIO', (129, 194, 219), 0.015)
+    for i, col in enumerate([(217, 172, 78), (102, 160, 196), (116, 187, 154)]):
+        d.ellipse((int((0.940+i*0.019)*U), int(0.013*V), int((0.948+i*0.019)*U), int(0.025*V)), fill=col)
+    box(0.009, 0.103, 0.226, 0.564, (35, 41, 51), (78, 85, 99))
+    box(0.234, 0.103, 0.588, 0.564, (31, 37, 47), (77, 86, 101))
+    box(0.597, 0.103, 0.964, 0.564, (31, 37, 47), (77, 86, 101))
+    box(0.01, 0.104, 0.226, 0.143, (54, 62, 74))
+    box(0.235, 0.104, 0.588, 0.143, (54, 62, 74))
+    box(0.598, 0.104, 0.964, 0.143, (54, 62, 74))
+    text(0.02, 0.112, 'PROJECT / MEDIA', size=0.016)
+    text(0.246, 0.112, 'SOURCE: Lake_01.mov', size=0.016)
+    text(0.609, 0.112, 'PROGRAM: Creative cut', size=0.016)
+    line([(0.245, 0.143), (0.337, 0.143)], (84, 188, 224), 2)
+    line([(0.608, 0.143), (0.721, 0.143)], (84, 188, 224), 2)
+    box(0.021, 0.157, 0.214, 0.185, (50, 56, 67), (76, 84, 96))
+    text(0.028, 0.161, 'Search media...', (137, 151, 166), 0.015)
+    scene1 = landscape(max(1, int(U*0.335)), max(1, int(V*0.305)), -3)
+    scene2 = landscape(max(1, int(U*0.347)), max(1, int(V*0.305)), 7)
+    canvas.paste(scene1, (int(0.244*U), int(0.155*V)))
+    canvas.paste(scene2, (int(0.607*U), int(0.155*V)))
+    d = ImageDraw.Draw(canvas)
+    for i in range(4):
+        tx = 0.021 + (i % 2)*0.101
+        ty = 0.203 + (i // 2)*0.118
+        thumb = (scene1 if i % 2 == 0 else scene2).resize((max(1, int(0.091*U)), max(1, int(0.078*V))), Image.Resampling.LANCZOS)
+        canvas.paste(thumb, (int(tx*U), int(ty*V)))
+        d = ImageDraw.Draw(canvas)
+        text(tx, ty+0.081, ['Lake_01.mov', 'Sunset_02.mov', 'Wide_03.mov', 'Final_04.mov'][i], size=0.012)
+    line([(0.02, 0.444), (0.215, 0.444)], (75, 84, 96))
+    text(0.021, 0.453, '> Footage     4 clips', size=0.015)
+    text(0.021, 0.485, '> Music       2 files', (140, 204, 165), 0.015)
+    text(0.021, 0.516, '> Sequences   1 item', size=0.015)
+    for x0, x1, tc in [(0.244, 0.577, '00:00:08:12'), (0.607, 0.953, '00:00:18:07')]:
+        text(x0+0.004, 0.473, tc, (130, 208, 231), 0.019)
+        text(x1-0.071, 0.478, 'Fit  100%', (144, 155, 170), 0.014)
+        line([(x0+0.01, 0.508), (x1-0.01, 0.508)], (102, 117, 137))
+        cx = (x0+x1)*0.5
+        for k in [-2, -1, 1, 2]:
+            px = cx+k*0.027
+            line([(px, 0.529), (px, 0.545)], (187, 201, 217), 2)
+            line([(px-0.004, 0.537), (px+0.004, 0.537)], (187, 201, 217), 1)
+        d.polygon([(int((cx-0.005)*U), int(0.527*V)), (int((cx-0.005)*U), int(0.548*V)), (int((cx+0.008)*U), int(0.5375*V))], fill=(196, 214, 228))
+        line([(cx+0.09, 0.527), (cx+0.09, 0.547)], (95, 196, 221), 2)
+    # Timeline panel, ruler, track labels, and individual media segments.
+    box(0.009, 0.580, 0.957, 0.955, (32, 38, 47), (83, 94, 109))
+    box(0.010, 0.581, 0.956, 0.624, (55, 64, 78))
+    text(0.021, 0.591, 'TIMELINE: Creative cut', size=0.018)
+    text(0.297, 0.593, 'Selection  |  Snap ON', (161, 185, 206), 0.014)
+    text(0.748, 0.590, '1080p   24 fps', (140, 198, 218), 0.016)
+    box(0.018, 0.630, 0.155, 0.945, (45, 52, 63))
+    box(0.161, 0.630, 0.945, 0.672, (46, 54, 66))
+    for i in range(33):
+        px = 0.167+i*(0.769/32)
+        line([(px, 0.660 if i % 4 else 0.645), (px, 0.671)], (119, 131, 146))
+        if i % 4 == 0:
+            text(px+0.002, 0.634, '00:%02d' % (i*2), (167, 179, 195), 0.013)
+        line([(px, 0.673), (px, 0.943)], (48, 56, 68))
+    rows = [0.678, 0.723, 0.768, 0.813, 0.858, 0.903]
+    names = ['V3  Titles', 'V2  Overlay', 'V1  Video', 'A1  Dialogue', 'A2  Music', 'A3  Ambience']
+    for i, y in enumerate(rows):
+        box(0.019, y, 0.154, y+0.040, (50, 57, 70) if i < 3 else (43, 62, 61))
+        text(0.025, y+0.009, names[i], (198, 207, 218), 0.014)
+        text(0.127, y+0.010, 'S M', (140, 155, 173), 0.010)
+        line([(0.161, y+0.041), (0.945, y+0.041)], (72, 82, 96))
+
+    def clip(x0, x1, row, col, label, audio=False, thumbnails=False):
+        y0 = rows[row]+0.002
+        y1 = rows[row]+0.039
+        xa, xb = int(x0*U), int(x1*U)
+        ya, yb = int(y0*V), int(y1*V)
+        cw, ch = max(1, xb-xa), max(1, yb-ya)
+        grad = np.linspace(1.08, 0.80, ch, dtype=np.float32)[:, None, None]
+        patch = np.ones((ch, cw, 3), np.float32)*np.array(col, np.float32)*grad
+        patch += rng.normal(0, 0.85, (ch, cw, 1))
+        canvas.paste(Image.fromarray(np.clip(patch, 0, 255).astype(np.uint8)), (xa, ya))
+        nonlocal d
+        d = ImageDraw.Draw(canvas)
+        line([(x0, y0), (x1, y0)], tuple(min(255, int(c*1.35)) for c in col))
+        line([(x0, y0), (x0, y1)], (37, 44, 53))
+        line([(x1, y0), (x1, y1)], (29, 35, 45))
+        if audio:
+            center = int((y0+0.026)*V)
+            available = max(2, int(V*0.010))
+            count = max(8, cw//3)
+            energy = rng.uniform(0.2, 1.0, count)
+            for j in range(count):
+                xp = xa+int(j*cw/count)
+                envelope = 0.28+0.72*abs(np.sin(j*0.22)+0.2*np.cos(j*0.61))/1.2
+                amplitude = max(1, int(available*energy[j]*envelope))
+                d.line((xp, center-amplitude, xp, center+amplitude), fill=(185, 229, 203), width=1)
+        elif thumbnails:
+            tw = max(12, int(U*0.034))
+            th = max(3, int(V*0.014))
+            mini = scene2.resize((tw, th), Image.Resampling.LANCZOS)
+            for xp in range(xa+3, xb-tw, tw+4):
+                canvas.paste(mini, (xp, int((y0+0.021)*V)))
+            d = ImageDraw.Draw(canvas)
+        if cw > U*0.062:
+            text(x0+0.005, y0+0.002, label, (233, 238, 245), 0.011)
+
+    clip(0.214, 0.405, 0, (145, 92, 173), 'Opening title')
+    clip(0.648, 0.844, 0, (167, 97, 166), 'Closing title')
+    clip(0.302, 0.525, 1, (65, 151, 178), 'Color overlay')
+    clip(0.572, 0.786, 1, (60, 148, 180), 'Transition / B-roll')
+    for a, b, label in [(0.165, 0.305, 'Lake_01'), (0.309, 0.492, 'Sunset_02'), (0.496, 0.640, 'Wide_03'), (0.644, 0.809, 'Lake_01'), (0.813, 0.944, 'Final_04')]:
+        clip(a, b, 2, (70, 119, 187), label, thumbnails=True)
+    clip(0.165, 0.456, 3, (53, 138, 121), 'Voice.wav', audio=True)
+    clip(0.465, 0.735, 3, (54, 143, 120), 'Voice take 02', audio=True)
+    clip(0.755, 0.944, 3, (53, 138, 121), 'Voice.wav', audio=True)
+    clip(0.165, 0.944, 4, (84, 148, 98), 'Music - warm sunset.wav', audio=True)
+    clip(0.224, 0.566, 5, (123, 143, 73), 'Lake ambience.wav', audio=True)
+    clip(0.575, 0.944, 5, (126, 142, 74), 'Room tone.wav', audio=True)
+    playx = 0.472
+    line([(playx, 0.665), (playx, 0.946)], (250, 116, 89), 2)
+    d.polygon([(int((playx-0.007)*U), int(0.637*V)), (int((playx+0.007)*U), int(0.637*V)), (int(playx*U), int(0.654*V))], fill=(251, 121, 91))
+    box(0.963, 0.580, 0.994, 0.955, (35, 43, 51), (74, 84, 96))
+    text(0.968, 0.593, 'dB', size=0.012)
+    for k in range(22):
+        yp = 0.914-k*0.012
+        col = (100, 198, 117) if k < 15 else ((220, 192, 83) if k < 19 else (220, 102, 88))
+        for channel in range(2):
+            xx = 0.968+channel*0.010
+            box(xx, yp, xx+0.006, yp+0.008, col if k < 19-channel*2 else (63, 74, 75))
+    box(0, 0.966, 1, 1, (50, 57, 68))
+    text(0.015, 0.974, 'Ready   |   6 tracks   |   Sequence 01', (162, 179, 194), 0.013)
+    text(0.764, 0.974, 'Render: Preview   00:01:04:00', (154, 186, 199), 0.013)
+
+    # Screen-specific optical treatment: slight glare, edge shading, and sensor grain.
+    panel = np.array(canvas).astype(np.float32)
+    gy, gx = np.mgrid[0:V, 0:U].astype(np.float32)
+    gx /= max(1, U-1)
+    gy /= max(1, V-1)
+    glare = 0.032 + 0.047*np.exp(-(((gx-0.18)/0.76)**2+((gy-0.12)/0.90)**2))
+    panel = panel*(1-glare[..., None]) + np.array([218, 227, 242])*glare[..., None]
+    edge = np.minimum.reduce([gx, 1-gx, gy, 1-gy])
+    panel *= (0.95+0.05*np.clip(edge/0.023, 0, 1))[..., None]
+    panel += rng.normal(0, 0.65, panel.shape)
+    panel = cv2.GaussianBlur(np.clip(panel, 0, 255), (0, 0), 0.32)
+
+    # Measured relative coordinates lie inside the existing blue display border.
+    quad = np.float32([[0.0887*w, 0.2276*h], [0.3945*w, 0.0796*h], [0.4502*w, 0.3254*h], [0.1750*w, 0.5125*h]])
+    flat = np.float32([[0, 0], [U-1, 0], [U-1, V-1], [0, V-1]])
+    matrix = cv2.getPerspectiveTransform(flat, quad)
+    warped = cv2.warpPerspective(panel, matrix, (w, h), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REPLICATE)
+    coverage = cv2.warpPerspective(np.ones((V, U), np.float32), matrix, (w, h), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT, borderValue=0)
+    hard = np.zeros((h, w), np.uint8)
+    cv2.fillConvexPoly(hard, np.round(quad).astype(np.int32), 255)
+    distance = cv2.distanceTransform(hard, cv2.DIST_L2, 5)
+    feather = max(0.85, w*0.00075)
+    alpha = np.clip(distance/feather, 0, 1)*np.clip(coverage, 0, 1)
+    alpha[hard == 0] = 0
+    # Transfer only weak low-frequency illumination; retain the interface's contrast.
+    source_luma = cv2.cvtColor(original, cv2.COLOR_RGB2GRAY).astype(np.float32)
+    soft_luma = cv2.GaussianBlur(source_luma, (0, 0), max(1, w*0.008))
+    valid = alpha > 0.99
+    if np.any(valid):
+        center_luma = np.median(soft_luma[valid])
+        illumination = np.clip((soft_luma-center_luma)*0.035, -3, 3)
+        warped += illumination[..., None]
+    result = original.astype(np.float32)*(1-alpha[..., None]) + np.clip(warped, 0, 255)*alpha[..., None]
+    out = np.clip(np.rint(result), 0, 255).astype(np.uint8)
+    out[alpha == 0] = original[alpha == 0]
+    if image.mode == 'RGBA':
+        return Image.fromarray(np.dstack([out, np.array(image.getchannel('A'))]), 'RGBA')
+    return Image.fromarray(out, 'RGB')

质量筛选后的候选:Remove the yellow paddle held by the surfer on the right, seamlessly filling the area with the surrounding ocean wave, water foam, and surfer details where needed. Keep both surfers, surfboards, ocean, waves, lighting, colors, perspective, and all other elements unchanged.

maskedit_scene · GPT-6.1-Sol · RFT · 自建图像judge通过 · 画质4/5 · 保留5/5

原图
单次 teacher 代码执行
数据集目标
完整 teacher 计划与代码
{
   "visual_evidence": [
-    "Two seated dogs appear on a white portrait canvas.",
-    "The left dog has orange-brown fur, a white chest, and white front legs.",
-    "The right dog has a predominantly black coat with tan markings.",
-    "The canvas rests on a white shelf beside a clear glass and a potted green plant."
+    "Two surfers in dark wetsuits are riding separate boards on a breaking ocean wave.",
+    "The surfer on the right holds a dark paddle shaft across his hands and torso.",
+    "The paddle has a bright yellow blade extending leftward over the green wave.",
+    "Blue water, green wave faces, and white foam surround the paddle."
   ],
-  "target_object": "Both dogs depicted on the canvas",
-  "target_region": "The two animal silhouettes inside the white canvas, including their heads, bodies, legs, paws, and printed ground shadows",
-  "editing_intent": "Replace the dogs with two seated, realistically shaded cats: an orange-and-white tabby on the left and a dark tortoiseshell cat on the right.",
+  "target_object": "The entire paddle held by the right surfer, including its yellow blade, dark shaft, and end grip.",
+  "target_region": "The diagonal paddle running from the yellow blade near the image center to the grip beside the right surfer's upper body.",
+  "editing_intent": "Remove the paddle and reconstruct the exposed wave, foam, and small obscured wetsuit areas while preserving both surfers and everything else.",
   "editing_plan": [
-    "Mask both original dog silhouettes and their immediate printed shadows.",
-    "Reconstruct the exposed canvas using its surrounding white shading and sampled fine texture.",
-    "Build seated feline silhouettes with tapered legs, rounded paws, curved tails, broad cheeks, and pointed ears.",
-    "Render orange-and-white and dark tortoiseshell coats with directional fur, irregular markings, and dimensional shading.",
-    "Add almond-shaped eyes, slit pupils, small noses, feline muzzles, whiskers, and restrained paw details.",
-    "Add soft contact shadows and feather the synthesized boundaries to match the printed portrait.",
-    "Preserve the canvas edges, shelf, glass, plant, pot, wall, and all pixels outside the editing region."
+    "Create separate, closely fitted masks for the yellow blade, diagonal shaft, and end grip using relative coordinates.",
+    "Protect the visible hands and the adjacent left surfer from the removal mask.",
+    "Inpaint the narrow shaft and grip using surrounding water, foam, and wetsuit pixels.",
+    "Find a clean ocean patch in the source image whose boundary colors and texture match the blade region.",
+    "Use the selected ocean texture to replace the blade, blending it with Poisson cloning.",
+    "Restore fine local texture along the removed shaft and feather the edit strictly inside the removal mask."
   ],
   "preservation_constraints": [
-    "Do not change the canvas position, perspective, or outer edges.",
-    "Do not change the glass, plant, pot, shelf, wall, or partially visible surrounding objects.",
-    "Keep both replacement cats seated side by side within the original portrait.",
-    "Match the original image's warm lighting, photographic texture, and soft printed shadows."
+    "Keep both surfers, their visible hands, faces, clothing, and poses unchanged.",
+    "Keep both surfboards and their visible details unchanged.",
+    "Preserve the ocean, foam, wave shapes, and lighting outside the paddle mask.",
+    "Preserve the original image dimensions, perspective, and overall colors.",
+    "Do not introduce any new objects."
   ]
 }
 
 def edit(image):
     import numpy as np
     import cv2
-    from PIL import Image, ImageDraw
+    from PIL import Image
 
     w, h = image.size
-    scale = 2
-    W, H = w * scale, h * scale
-    rng = np.random.default_rng(27)
-    original = np.asarray(image.convert('RGB'))
-    source = cv2.resize(original, (W, H), interpolation=cv2.INTER_CUBIC).astype(np.float32)
-    yy, xx = np.mgrid[0:H, 0:W].astype(np.float32)
-    X, Y = xx / W, yy / H
+    original = np.asarray(image.convert('RGB')).copy()
+    scale = max(0.5, min(w, h) * 0.001)
 
-    def polygon(points):
-        out = np.zeros((H, W), np.uint8)
-        pts = np.rint(np.array(points) * [W, H]).astype(np.int32)
-        cv2.fillPoly(out, [pts], 255)
+    def points(coords):
+        return np.array([(int(round(x * w)), int(round(y * h))) for x, y in coords], dtype=np.int32)
+
+    def polygon(coords):
+        out = np.zeros((h, w), dtype=np.uint8)
+        cv2.fillPoly(out, [points(coords)], 255)
         return out
 
-    def ellipse(box):
-        out = Image.new('L', (W, H), 0)
-        ImageDraw.Draw(out).ellipse(tuple(np.array(box) * [W, H, W, H]), fill=255)
-        return np.asarray(out).copy()
-
-    def path_points(commands, dx=0.0, dy=0.0):
-        pts = []
-        current = None
-        first = None
-        for cmd in commands:
-            if cmd[0] == 'M':
-                current = np.array([cmd[1] + dx, cmd[2] + dy], float)
-                first = current.copy()
-                pts.append(current.copy())
-            elif cmd[0] == 'L':
-                current = np.array([cmd[1] + dx, cmd[2] + dy], float)
-                pts.append(current.copy())
-            elif cmd[0] == 'C':
-                a = current.copy()
-                b = np.array([cmd[1] + dx, cmd[2] + dy])
-                c = np.array([cmd[3] + dx, cmd[4] + dy])
-                d = np.array([cmd[5] + dx, cmd[6] + dy])
-                for t in np.linspace(0, 1, 33)[1:]:
-                    pts.append((1-t)**3*a + 3*(1-t)**2*t*b + 3*(1-t)*t*t*c + t**3*d)
-                current = d
-            elif cmd[0] == 'Z':
-                pts.append(first.copy())
-                current = first.copy()
-        return np.array(pts)
-
-    def path(commands, dx=0.0, dy=0.0):
-        return polygon(path_points(commands, dx, dy))
-
-    canvas = polygon([(0.260,0.198),(0.749,0.216),(0.798,0.824),(0.287,0.874)])
-    canvas = cv2.erode(canvas, np.ones((3,3), np.uint8)) / 255.0
-    left_outline = [(0.278,0.391),(0.285,0.366),(0.314,0.340),(0.355,0.322),(0.398,0.319),(0.443,0.324),(0.477,0.343),(0.512,0.371),(0.516,0.394),(0.496,0.429),(0.511,0.465),(0.523,0.512),(0.525,0.575),(0.536,0.639),(0.534,0.737),(0.538,0.792),(0.526,0.814),(0.519,0.849),(0.504,0.860),(0.457,0.859),(0.446,0.846),(0.389,0.846),(0.378,0.864),(0.317,0.870),(0.307,0.850),(0.311,0.787),(0.314,0.730),(0.305,0.669),(0.312,0.599),(0.304,0.555),(0.304,0.516),(0.312,0.484),(0.298,0.457),(0.285,0.435)]
-    right_outline = [(0.532,0.342),(0.552,0.319),(0.578,0.307),(0.598,0.289),(0.610,0.280),(0.619,0.294),(0.652,0.295),(0.678,0.294),(0.684,0.282),(0.701,0.301),(0.727,0.311),(0.748,0.340),(0.755,0.365),(0.747,0.388),(0.733,0.401),(0.730,0.440),(0.731,0.471),(0.749,0.521),(0.748,0.572),(0.746,0.621),(0.734,0.672),(0.729,0.723),(0.731,0.783),(0.746,0.812),(0.744,0.828),(0.685,0.837),(0.673,0.822),(0.666,0.804),(0.619,0.794),(0.611,0.826),(0.602,0.842),(0.556,0.845),(0.552,0.823),(0.536,0.804),(0.535,0.750),(0.529,0.709),(0.532,0.661),(0.526,0.596),(0.531,0.551),(0.546,0.507),(0.555,0.464),(0.561,0.422),(0.551,0.400),(0.534,0.380)]
-    removal = np.maximum(polygon(left_outline), polygon(right_outline))
-    removal = np.maximum(removal, ellipse((0.308,0.821,0.532,0.871)))
-    removal = np.maximum(removal, ellipse((0.538,0.794,0.751,0.850)))
-    radius = max(1, int(round(0.004 * W)))
-    removal = cv2.dilate(removal, cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2*radius+1,2*radius+1)))
-    removal = np.uint8(removal * canvas)
-
-    # Estimate the actual canvas illumination, excluding both original animals.
-    excluded = cv2.dilate(removal, np.ones((2*radius+5,2*radius+5), np.uint8))
-    samples = (canvas > 0.99) & (excluded == 0) & (source.mean(axis=2) > 190)
-    stride = max(1, min(W,H)//240)
-    grid = np.zeros((H,W), bool)
-    grid[::stride,::stride] = True
-    sy, sx = np.where(samples & grid)
-    px, py = sx/W, sy/H
-    design = np.stack([np.ones_like(px),px,py,px*py,px*px,py*py],axis=1)
-    values = source[sy,sx]
-    keep = np.ones(len(sx), bool)
-    coefficients = np.zeros((6,3))
-    for _ in range(4):
-        coefficients = np.linalg.lstsq(design[keep], values[keep], rcond=None)[0]
-        errors = np.mean(np.abs(design @ coefficients - values),axis=1)
-        keep = errors < max(3.0, float(np.percentile(errors,85)))
-    basis = [np.ones_like(X),X,Y,X*Y,X*X,Y*Y]
-    clean_canvas = sum(b[...,None]*c for b,c in zip(basis,coefficients))
-    clean_canvas = np.clip(clean_canvas,190,255)
-    # Reuse fine texture from an unobstructed strip of the same canvas.
-    residual = source - cv2.GaussianBlur(source,(0,0),1.25*scale)
-    patch = residual[int(.231*H):int(.275*H),int(.335*W):int(.702*W)]
-    if patch.size == 0:
-        patch = np.zeros((max(1,H//30),max(1,W//4),3),np.float32)
-    texture = np.tile(patch,(int(np.ceil(H/patch.shape[0])),int(np.ceil(W/patch.shape[1])),1))[:H,:W]
-    clean_canvas += texture + rng.normal(0,0.35,(H,W,1)).astype(np.float32)
-    repair_alpha = cv2.GaussianBlur(removal.astype(np.float32)/255,(0,0),0.55*scale) * canvas
-    result = source*(1-repair_alpha[...,None]) + clean_canvas*repair_alpha[...,None]
-
-    def put(mask, color, opacity=1.0, softness=0.35):
-        nonlocal result
-        a = mask.astype(np.float32)/255
-        if softness > 0:
-            a = cv2.GaussianBlur(a,(0,0),softness*scale)
-        a = np.clip(a*opacity*canvas,0,1)
-        result = result*(1-a[...,None]) + np.asarray(color,np.float32)*a[...,None]
-
-    def line(commands, color, width=0.0012, opacity=1.0, dx=0.0, dy=0.0, softness=0.18):
-        points = path_points(commands,dx,dy)
-        mask = Image.new('L',(W,H),0)
-        coords = [tuple(p*[W,H]) for p in points]
-        ImageDraw.Draw(mask).line(coords,fill=255,width=max(1,int(round(width*min(W,H)))),joint='curve')
-        put(np.asarray(mask),color,opacity,softness)
-
-    def painted(mask, cat, dx, dy, mode='body', fur=True):
-        nonlocal result
-        indices = np.argwhere(mask > 0)
-        if not len(indices):
-            return
-        y0,x0 = np.maximum(indices.min(axis=0)-4,0)
-        y1,x1 = np.minimum(indices.max(axis=0)+5,[H,W])
-        local_mask = mask[y0:y1,x0:x1].astype(np.float32)/255
-        qx = X[y0:y1,x0:x1]-dx
-        qy = Y[y0:y1,x0:x1]-dy
-        sh = local_mask.shape
-        raw = rng.normal(0,1,sh).astype(np.float32)
-        fine = cv2.GaussianBlur(raw,(0,0),0.38*scale)
-        fibers = cv2.GaussianBlur(raw,(0,0),0.40*scale,sigmaY=2.1*scale)
-        fibers /= max(float(fibers.std()),0.001)
-        broad = cv2.GaussianBlur(raw,(0,0),max(1,0.009*W))
-        broad /= max(float(broad.std()),0.001)
-        variation = np.clip(broad,-2,2)
-        white = np.array([235,229,216],np.float32)
-        orange = np.array([195,123,63],np.float32)
-        dark = np.array([41,36,31],np.float32)
-        if mode == 'inner_ear':
-            base = np.array([160,107,98] if cat == 0 else [103,70,64],np.float32)
-            colors = np.broadcast_to(base,sh+(3,)).copy()
-        elif mode == 'white':
-            colors = np.broadcast_to(white,sh+(3,)).copy()
-        elif mode == 'muzzle':
-            if cat == 0:
-                colors = np.broadcast_to(white,sh+(3,)).copy()
-            else:
-                t = np.clip((.397-qx)*25+.3+variation*.14,0,1)
-                colors = np.array([64,53,43])[None,None,:]*(1-t[...,None])+np.array([170,139,97])[None,None,:]*t[...,None]
-        elif cat == 0:
-            colors = np.broadcast_to(orange,sh+(3,)).copy()
-            if mode == 'head':
-                whiten = np.exp(-((qx-.394)/.044)**4-((qy-.450)/.028)**4)
-                blaze = np.exp(-((qx-.394)/.011)**4)*np.clip((qy-.382)/.049,0,1)
-                whiten = np.maximum(whiten,blaze*.90)
-                stripes = np.zeros(sh,np.float32)
-                for center,tilt in [(.362,-.18),(.394,.04),(.426,.18)]:
-                    stripe_center = center+tilt*(qy-.350)
-                    stripes += np.exp(-((qx-stripe_center)/.0045)**2)*np.exp(-((qy-.354)/.029)**4)
-                side = np.clip((np.abs(qx-.394)-.037)/.025,0,1)
-                stripes += side*np.maximum(0,np.cos((qy-.39)*190+(qx-.394)*25))**6*np.exp(-((qy-.414)/.047)**4)
-            else:
-                flank = np.clip((np.abs(qx-.404)-.043+variation*.003)/.018,0,1)
-                shoulder = np.clip((.546-qy)/.035,0,1)
-                white_chest = np.exp(-((qx-.400)/.045)**4)
-                orange_fraction = np.maximum(flank,shoulder*(1-white_chest*.86))
-                whiten = 1-orange_fraction
-                stripes = np.maximum(0,np.cos(qy*174+qx*48+variation*.35))**7*orange_fraction*.64
-            stripes = np.clip(stripes,0,1)
-            colors *= (1-.39*stripes[...,None])
-            colors = colors*(1-whiten[...,None])+white*whiten[...,None]
+    def kernel(radius):
+        r = max(1, int(round(radius)))
+        return cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2 * r + 1, 2 * r + 1))
+
+    blade = polygon([
+        (0.4248, 0.3770), (0.4293, 0.3672), (0.4384, 0.3613),
+        (0.4515, 0.3574), (0.4678, 0.3584), (0.4814, 0.3623),
+        (0.4906, 0.3662), (0.4958, 0.3701), (0.4938, 0.3770),
+        (0.4860, 0.3887), (0.4762, 0.4023), (0.4645, 0.4131),
+        (0.4541, 0.4180), (0.4423, 0.4199), (0.4326, 0.4170),
+        (0.4280, 0.4102), (0.4254, 0.4004), (0.4241, 0.3887)
+    ])
+    blade = cv2.dilate(blade, kernel(2.0 * scale))
+
+    shaft = np.zeros((h, w), dtype=np.uint8)
+    cv2.line(shaft, tuple(points([(0.4910, 0.3710)])[0]),
+             tuple(points([(0.7244, 0.3018)])[0]), 255,
+             max(3, int(round(0.0073 * w))), cv2.LINE_8)
+    cv2.ellipse(shaft, tuple(points([(0.7244, 0.3018)])[0]),
+                (max(2, int(round(0.0043 * w))), max(3, int(round(0.0118 * h)))),
+                -12, 0, 360, 255, -1)
+
+    left_person = polygon([
+        (0.349, 0.233), (0.360, 0.208), (0.385, 0.205),
+        (0.394, 0.227), (0.393, 0.263), (0.407, 0.285),
+        (0.415, 0.321), (0.4173, 0.366), (0.4230, 0.391),
+        (0.4226, 0.418), (0.414, 0.472), (0.405, 0.489),
+        (0.414, 0.518), (0.437, 0.562), (0.450, 0.601),
+        (0.412, 0.608), (0.409, 0.576), (0.383, 0.531),
+        (0.373, 0.502), (0.374, 0.463), (0.374, 0.436),
+        (0.363, 0.461), (0.350, 0.468), (0.344, 0.455),
+        (0.349, 0.440), (0.359, 0.411), (0.363, 0.363),
+        (0.362, 0.315), (0.363, 0.293), (0.351, 0.277)
+    ])
+
+    hand_regions = polygon([
+        (0.571, 0.341), (0.575, 0.328), (0.585, 0.324),
+        (0.594, 0.334), (0.596, 0.345), (0.591, 0.358),
+        (0.580, 0.357), (0.573, 0.349)
+    ])
+    hand_regions |= polygon([
+        (0.683, 0.303), (0.687, 0.298), (0.695, 0.296),
+        (0.704, 0.303), (0.708, 0.316), (0.704, 0.325),
+        (0.694, 0.326), (0.686, 0.319)
+    ])
+    colors = original.astype(np.float32)
+    r, g, b = colors[:, :, 0], colors[:, :, 1], colors[:, :, 2]
+    skin = ((r > g + 4) & (r > b + 9) & (g > b + 2) & (r > 32))
+    hands = ((hand_regions > 0) & skin).astype(np.uint8) * 255
+    hands = cv2.morphologyEx(hands, cv2.MORPH_CLOSE, kernel(scale))
+    hands = cv2.dilate(hands, kernel(scale))
+    hands[hand_regions == 0] = 0
+
+    blade[left_person > 0] = 0
+    mask = cv2.bitwise_or(blade, shaft)
+    mask[(hands > 0) | (left_person > 0)] = 0
+    blade[mask == 0] = 0
+
+    # Narrow holes are filled from their immediate water and clothing boundaries.
+    result = cv2.inpaint(original, mask, max(2.0, 4.0 * scale), cv2.INPAINT_TELEA)
+
+    # Exclude all people, boards, and the paddle from ocean texture donors.
+    forbidden = cv2.dilate(cv2.bitwise_or(mask, left_person), kernel(5.0 * scale))
+    right_person = polygon([
+        (0.572, 0.173), (0.731, 0.173),
+        (0.731, 0.591), (0.572, 0.591)
+    ])
+    boards = polygon([
+        (0.310, 0.532), (0.776, 0.532),
+        (0.776, 0.670), (0.310, 0.670)
+    ])
+    forbidden |= right_person
+    forbidden |= boards
+    integral = cv2.integral((forbidden > 0).astype(np.uint8))
+
+    ys, xs = np.nonzero(blade)
+    if len(xs):
+        padding = max(4, int(round(8.0 * scale)))
+        x0, x1 = max(0, int(xs.min()) - padding), min(w, int(xs.max()) + padding + 1)
+        y0, y1 = max(0, int(ys.min()) - padding), min(h, int(ys.max()) + padding + 1)
+        bw, bh = x1 - x0, y1 - y0
+        patch_mask = blade[y0:y1, x0:x1].copy()
+
+        outer = cv2.dilate(blade, kernel(7.0 * scale))
+        exclusion = cv2.dilate(mask, kernel(1.0 * scale))
+        ring = (outer > 0) & (blade == 0) & (exclusion == 0)
+        ring &= (left_person == 0) & (right_person == 0)
+        ring = ring[y0:y1, x0:x1]
+        if np.count_nonzero(ring) < 8:
+            ring = (cv2.dilate(patch_mask, kernel(3.0 * scale)) > 0) & (patch_mask == 0)
+
+        smooth = cv2.GaussianBlur(colors, (0, 0), max(0.6, 2.5 * scale))
+        texture_energy = np.mean(np.abs(colors - smooth), axis=2)
+        target_values = smooth[y0:y1, x0:x1][ring]
+        target_energy = float(np.mean(texture_energy[y0:y1, x0:x1][ring]))
+
+        def donor_score(dx, dy):
+            if dx < 0 or dy < 0 or dx + bw > w or dy + bh > h:
+                return None
+            count = (integral[dy + bh, dx + bw] - integral[dy, dx + bw]
+                     - integral[dy + bh, dx] + integral[dy, dx])
+            if count:
+                return None
+            donor_values = smooth[dy:dy + bh, dx:dx + bw][ring]
+            difference = target_values - donor_values
+            offset = np.clip(np.mean(difference, axis=0), -25.0, 25.0)
+            error = float(np.mean((difference - offset) ** 2))
+            error += 0.12 * float(np.mean(offset ** 2))
+            energy = float(np.mean(texture_energy[dy:dy + bh, dx:dx + bw][ring]))
+            error += 0.35 * (energy - target_energy) ** 2
+            return error, offset
+
+        step_x = max(2, int(round(0.005 * w)))
+        step_y = max(2, int(round(0.004 * h)))
+        best = None
+        for dy in range(int(0.342 * h), min(int(0.490 * h), h - bh) + 1, step_y):
+            for dx in range(int(0.180 * w), min(int(0.560 * w), w - bw) + 1, step_x):
+                score = donor_score(dx, dy)
+                if score is not None and (best is None or score[0] < best[0]):
+                    best = (score[0], dx, dy, score[1])
+
+        if best is not None:
+            _, coarse_x, coarse_y, _ = best
+            refinement = max(1, int(round(1.5 * scale)))
+            for dy in range(max(0, coarse_y - step_y), min(h - bh, coarse_y + step_y) + 1, refinement):
+                for dx in range(max(0, coarse_x - step_x), min(w - bw, coarse_x + step_x) + 1, refinement):
+                    score = donor_score(dx, dy)
+                    if score is not None and score[0] < best[0]:
+                        best = (score[0], dx, dy, score[1])
+            _, donor_x, donor_y, offset = best
         else:
-            colors = np.broadcast_to(dark,sh+(3,)).copy()
-            if mode == 'head':
-                spot = np.exp(-((qx-.429)/.029)**2-((qy-.420)/.040)**2)
-                spot += .7*np.exp(-((qx-.363)/.022)**2-((qy-.344)/.033)**2)
-                spot += .5*np.exp(-((qx-.386)/.014)**2-((qy-.456)/.018)**2)
-            else:
-                spot = .65*np.exp(-((qx-.347)/.030)**2-((qy-.615)/.074)**2)
-                spot += .8*np.exp(-((qx-.460)/.027)**2-((qy-.751)/.065)**2)
-                if mode == 'leg':
-                    spot += .75*np.exp(-((qx-.355)/.033)**2-((qy-.823)/.048)**2)
-            tortie = np.clip((spot+variation*.23-.25)*1.8,0,.92)
-            colors = colors*(1-tortie[...,None])+np.array([175,116,62],np.float32)*tortie[...,None]
-            if mode == 'body':
-                bib = np.exp(-((qx-.399)/.022)**4-((qy-.528)/.036)**4)*.77
-                colors = colors*(1-bib[...,None])+np.array([207,189,160])*bib[...,None]
-        nx = (qx-(x0+x1)/(2*W)+dx)/max((x1-x0)/(2*W),.005)
-        ny = (qy-(y0+y1)/(2*H)+dy)/max((y1-y0)/(2*H),.005)
-        bulge = np.sqrt(np.clip(1-.85*nx*nx-.15*ny*ny,0,1))
-        light = .70+.27*bulge-.10*nx-.035*ny
-        if mode == 'inner_ear':
-            light *= .82+.14*np.clip(-ny,0,1)
-        colors *= light[...,None]
-        colors += variation[...,None]*(3.0 if cat == 0 else 2.8)
-        colors += fibers[...,None]*(2.1 if cat == 0 else 1.5)+fine[...,None]*3.2
-        colors = np.clip(colors,0,255)
-        if fur:
-            fur_image = Image.fromarray(colors.astype(np.uint8),'RGB')
-            draw = ImageDraw.Draw(fur_image)
-            count = min(3500,max(100,int(np.count_nonzero(local_mask>.5)/(10*scale*scale))))
-            ry = rng.integers(0,sh[0],count)
-            rx = rng.integers(0,sh[1],count)
-            for iy,ix in zip(ry,rx):
-                if local_mask[iy,ix] < .6:
-                    continue
-                u,v = float(qx[iy,ix]),float(qy[iy,ix])
-                if mode in ('head','muzzle'):
-                    angle = np.arctan2(v-.433,u-.394)+rng.normal(0,.22)
-                elif mode == 'inner_ear':
-                    angle = -np.pi/2+rng.normal(0,.25)
-                else:
-                    angle = np.pi/2+(u-.402)*3+rng.normal(0,.18)
-                length = rng.uniform(.0017,.0053)*min(W,H)
-                delta = rng.uniform(-14,18) if cat == 0 else rng.uniform(-8,14)
-                color = tuple(np.clip(colors[iy,ix]+delta,0,255).astype(np.uint8))
-                draw.line([(int(ix),int(iy)),(int(ix+np.cos(angle)*length),int(iy+np.sin(angle)*length))],fill=color,width=1)
-            colors = np.asarray(fur_image).astype(np.float32)
-        alpha = cv2.GaussianBlur(local_mask,(0,0),.38*scale)*canvas[y0:y1,x0:x1]
-        result[y0:y1,x0:x1] = result[y0:y1,x0:x1]*(1-alpha[...,None])+colors*alpha[...,None]
-
-    torso = [('M',.363,.467),('C',.338,.479,.324,.523,.324,.577),('C',.318,.631,.321,.690,.313,.748),('C',.304,.796,.326,.835,.364,.845),('C',.401,.857,.467,.850,.497,.828),('C',.518,.797,.512,.735,.501,.680),('C',.494,.610,.488,.536,.461,.487),('C',.435,.465,.389,.456,.363,.467),('Z',)]
-    head = [('M',.315,.382),('C',.305,.354,.311,.309,.315,.282),('C',.340,.290,.360,.319,.373,.331),('C',.390,.326,.416,.327,.432,.334),('C',.448,.312,.464,.291,.480,.282),('C',.485,.318,.479,.359,.476,.383),('C',.490,.407,.476,.442,.448,.461),('C',.421,.480,.371,.478,.344,.459),('C',.320,.445,.303,.413,.315,.382),('Z',)]
-    tail = [('M',.351,.722),('C',.337,.714,.322,.712,.312,.726),('C',.293,.748,.302,.787,.318,.811),('C',.330,.831,.354,.842,.387,.830),('C',.398,.825,.395,.807,.382,.808),('C',.353,.818,.337,.806,.329,.788),('C',.318,.766,.321,.746,.336,.744),('C',.348,.744,.359,.739,.351,.722),('Z',)]
-    left_leg = [('M',.356,.583),('C',.346,.649,.350,.738,.344,.811),('C',.328,.824,.327,.846,.347,.853),('C',.365,.860,.389,.854,.389,.840),('C',.381,.781,.392,.682,.395,.603),('C',.390,.586,.372,.578,.356,.583),('Z',)]
-    right_leg = [('M',.432,.581),('C',.429,.658,.434,.748,.430,.815),('C',.416,.829,.420,.849,.442,.850),('C',.462,.852,.483,.844,.482,.830),('C',.471,.776,.472,.680,.469,.605),('C',.465,.588,.449,.577,.432,.581),('Z',)]
-    ear_left = [('M',.325,.302),('C',.335,.308,.350,.324,.358,.342),('C',.346,.343,.333,.354,.322,.363),('C',.319,.340,.322,.316,.325,.302),('Z',)]
-    ear_right = [('M',.469,.302),('C',.468,.324,.467,.346,.466,.362),('C',.453,.351,.443,.344,.441,.343),('C',.447,.327,.459,.311,.469,.302),('Z',)]
-
-    placements = [(0,0.0,0.0),(1,.250,-.025)]
-    # Very soft printed cast shadows and tighter ground-contact shadows.
-    for cat,dx,dy in placements:
-        silhouette = np.maximum(path(torso,dx,dy),path(head,dx,dy))
-        silhouette = np.maximum(silhouette,path(tail,dx,dy))
-        shifted = cv2.warpAffine(silhouette,np.float32([[1,0,.004*W],[0,1,.005*H]]),(W,H))
-        shadow = cv2.GaussianBlur(shifted,(0,0),.006*min(W,H))
-        put(shadow,[121,118,111],.085,0)
-        ground = ellipse((.313+dx,.835+dy,.501+dx,.865+dy))
-        ground = cv2.GaussianBlur(ground,(0,0),.006*H)
-        put(ground,[111,105,95],.15,0)
-        close = ellipse((.332+dx,.840+dy,.484+dx,.854+dy))
-        close = cv2.GaussianBlur(close,(0,0),.0025*H)
-        put(close,[89,83,76],.17,0)
-
-    def almond(cx,cy,rx,ry,tilt=0):
-        return path([('M',cx-rx,cy-tilt),('C',cx-rx*.50,cy-ry-tilt*.4,cx+rx*.36,cy-ry+tilt*.4,cx+rx,cy+tilt),('C',cx+rx*.47,cy+ry+tilt*.4,cx-rx*.44,cy+ry-tilt*.4,cx-rx,cy-tilt),('Z',)])
-
-    def eye(cx,cy,cat,tilt):
-        nonlocal result
-        outline = almond(cx,cy,.024,.0135,tilt)
-        put(outline,[43,32,23] if cat == 0 else [14,13,11],1,.20)
-        inside = almond(cx,cy+.0004,.0208,.0107,tilt)
-        ids = np.argwhere(inside>0)
-        y0,x0 = ids.min(axis=0)
-        y1,x1 = ids.max(axis=0)+1
-        ex = (X[y0:y1,x0:x1]-cx)/.0124
-        ey = (Y[y0:y1,x0:x1]-cy)/.0138
-        r = np.sqrt(ex*ex+ey*ey)
-        theta = np.arctan2(ey,ex)
-        iris = np.array([151,163,74] if cat == 0 else [195,151,60],np.float32)
-        illumination = .55+.46*np.exp(-((r-.57)/.34)**2)-.12*ey
-        streaks = np.sin(theta*43+np.sin(theta*17)*1.7+r*8)*.055
-        color = iris[None,None,:]*np.clip(illumination+streaks,.32,1.2)[...,None]
-        outside = np.clip((r-.90)/.25,0,1)
-        color = color*(1-outside[...,None])+np.array([62,57,29])[None,None,:]*outside[...,None]
-        a = cv2.GaussianBlur(inside[y0:y1,x0:x1].astype(np.float32)/255,(0,0),.22*scale)
-        result[y0:y1,x0:x1] = result[y0:y1,x0:x1]*(1-a[...,None])+np.clip(color,0,255)*a[...,None]
-        pupil = ellipse((cx-.0026,cy-.0105,cx+.0026,cy+.0107))
-        pupil = np.minimum(pupil,inside)
-        put(pupil,[8,10,8],1,.20)
-        put(ellipse((cx-.0064,cy-.0060,cx-.0022,cy-.0018)),[250,250,233],.93,.18)
-        put(ellipse((cx+.0031,cy+.0030,cx+.0048,cy+.0045)),[230,235,202],.5,.15)
-
-    for cat,dx,dy in placements:
-        painted(path(tail,dx,dy),cat,dx,dy,'body')
-        painted(path(torso,dx,dy),cat,dx,dy,'body')
-        painted(ellipse((.320+dx,.669+dy,.386+dx,.824+dy)),cat,dx,dy,'body')
-        painted(ellipse((.455+dx,.674+dy,.507+dx,.825+dy)),cat,dx,dy,'body')
-        painted(path(right_leg,dx,dy),cat,dx,dy,'white' if cat == 0 else 'leg')
-        painted(path(left_leg,dx,dy),cat,dx,dy,'white' if cat == 0 else 'leg')
-        painted(path(head,dx,dy),cat,dx,dy,'head')
-        painted(path(ear_left,dx,dy),cat,dx,dy,'inner_ear')
-        painted(path(ear_right,dx,dy),cat,dx,dy,'inner_ear')
-        # Small inward-pointing hairs keep the ear recesses from looking geometric.
-        for side in [0,1]:
-            for j in range(12):
-                if side == 0:
-                    ex = .324+j*.0023
-                    ey = .355-j*.00065
-                    endpoint = (ex+.007,ey-.016-rng.uniform(0,.009))
-                else:
-                    ex = .465-j*.0020
-                    ey = .356-j*.00055
-                    endpoint = (ex-.008,ey-.016-rng.uniform(0,.008))
-                line([('M',ex,ey),('C',ex,ey-.004,endpoint[0],endpoint[1]+.006,endpoint[0],endpoint[1])],[223,203,174] if cat == 0 else [147,132,109],.00065,.45,dx,dy)
-        muzzle = np.maximum(ellipse((.351+dx,.428+dy,.397+dx,.463+dy)),ellipse((.391+dx,.428+dy,.437+dx,.463+dy)))
-        painted(muzzle,cat,dx,dy,'muzzle')
-        painted(ellipse((.369+dx,.454+dy,.421+dx,.478+dy)),cat,dx,dy,'white' if cat == 0 else 'muzzle')
-        eye(.358+dx,.395+dy,cat,-.0014)
-        eye(.431+dx,.395+dy,cat,.0014)
-        nose_outline = [('M',.382,.432),('C',.386,.429,.402,.429,.406,.433),('C',.405,.438,.399,.443,.394,.444),('C',.389,.442,.382,.437,.382,.432),('Z',)]
-        put(path(nose_outline,dx,dy),[78,46,39] if cat == 0 else [48,34,29],1,.24)
-        nose_inside = [('M',.384,.432),('C',.390,.431,.399,.431,.403,.433),('C',.401,.437,.398,.440,.394,.441),('C',.390,.439,.386,.436,.384,.432),('Z',)]
-        put(path(nose_inside,dx,dy),[174,111,105] if cat == 0 else [115,76,65],1,.32)
-        line([('M',.386,.433),('C',.390,.432,.395,.432,.399,.433)],[228,167,153],.0010,.53,dx,dy)
-        mouth_color = [86,69,56] if cat == 0 else [35,29,25]
-        line([('M',.394,.443),('C',.394,.447,.394,.450,.394,.453)],mouth_color,.0011,.72,dx,dy)
-        line([('M',.373,.456),('C',.381,.460,.389,.459,.394,.453),('C',.399,.459,.409,.460,.416,.455)],mouth_color,.0010,.64,dx,dy)
-        for side in [-1,1]:
-            for j in range(4):
-                cx = .394+side*(.016+j%2*.007)+dx
-                cy = .447+(j//2)*.007+dy
-                put(ellipse((cx-.0009,cy-.0008,cx+.0009,cy+.0008)),[104,86,66] if cat == 0 else [47,39,32],.47,.20)
-            for j in range(5):
-                sx = .394+side*.022
-                sy = .447+j*.003
-                endx = .394+side*(.081+.006*(j%3))
-                endy = .423+j*.013
-                line([('M',sx,sy),('C',sx+side*.022,sy-.005+j*.0006,endx-side*.013,endy-.003,endx,endy)],[250,244,225] if cat == 0 else [225,216,193],.00065,.46 if cat == 0 else .61,dx,dy,.20)
-        # Tiny toe separations, not hard outlines.
-        for cx,cy in [(.350,.844),(.363,.846),(.442,.841),(.454,.841)]:
-            line([('M',cx,cy-.006),('C',cx-.001,cy-.003,cx-.001,cy,cx,cy+.002)],[143,132,113] if cat == 0 else [37,31,25],.0008,.38,dx,dy,.30)
-
-    result = np.clip(result,0,255).astype(np.uint8)
-    output = cv2.resize(result,(w,h),interpolation=cv2.INTER_AREA)
-    # The entire edit is confined to the portrait; surrounding pixels remain exact.
-    portrait_native = cv2.resize(canvas,(w,h),interpolation=cv2.INTER_AREA)
-    untouched = portrait_native < 0.001
-    output[untouched] = original[untouched]
-    return Image.fromarray(output,'RGB')
\ No newline at end of file + donor_x = min(max(0, int(0.260 * w)), w - bw) + donor_y = min(max(0, int(0.400 * h)), h - bh) + donor_values = smooth[donor_y:donor_y + bh, donor_x:donor_x + bw][ring] + offset = np.clip(np.mean(target_values - donor_values, axis=0), -25.0, 25.0) + + donor = original[donor_y:donor_y + bh, donor_x:donor_x + bw].astype(np.float32) + donor = np.clip(donor + offset[None, None, :], 0, 255).astype(np.uint8) + center = (x0 + bw // 2, y0 + bh // 2) + result = cv2.seamlessClone(donor, result, patch_mask, center, cv2.NORMAL_CLONE) + + # Retain authentic fine texture in the narrow reconstructed areas. + fine = colors - cv2.GaussianBlur(colors, (0, 0), max(0.5, 0.9 * scale)) + displacement = max(3, int(round(12.0 * scale))) + below_color = np.roll(smooth if len(xs) else colors, -displacement, axis=0) + above_color = np.roll(smooth if len(xs) else colors, displacement, axis=0) + current = result.astype(np.float32) + use_below = np.sum((below_color - current) ** 2, axis=2) < np.sum((above_color - current) ** 2, axis=2) + below_detail = np.roll(fine, -displacement, axis=0) + above_detail = np.roll(fine, displacement, axis=0) + detail = np.where(use_below[:, :, None], below_detail, above_detail) + narrow = (mask > 0) & (blade == 0) + textured = np.clip(current + 0.55 * np.clip(detail, -8.0, 8.0), 0, 255) + current[narrow] = textured[narrow] + + # No pixel outside the tightly bounded removal mask is changed. + distance = cv2.distanceTransform((mask > 0).astype(np.uint8), cv2.DIST_L2, 3) + alpha = np.clip(distance / max(1.0, 1.5 * scale), 0.0, 1.0)[:, :, None] + final = np.clip(colors * (1.0 - alpha) + current * alpha, 0, 255).astype(np.uint8) + final[mask == 0] = original[mask == 0] + return Image.fromarray(final, 'RGB')
\ No newline at end of file