ACCC1380's picture
download
raw
3.53 kB
import hashlib
import json
from pathlib import Path
import zipfile
import numpy as np
from PIL import Image
root=Path('/marimo-moss'); folder=root/'recreate-moss'
report=json.loads((folder/'manifest.json').read_text());report['runs']={}
for name in ['text2image','reference','text2image-hires']:
h=json.loads((folder/(name+'_history.json')).read_text())
assert h['status']['completed'] and h['status']['status_str']=='success'
item=h['outputs']['9']['images'][0]
path=root/'comfyui-output'/item['subfolder']/item['filename']
im=Image.open(path)
expected=(832,1280) if name=='text2image' else (1248,1920)
assert im.size==expected
assert np.asarray(im).std()>1
assert 'workflow' in im.info and 'prompt' in im.info
embedded=json.loads(im.info['prompt'])
for node in embedded.values(): node.pop('is_changed',None)
assert embedded==json.loads((folder/(name+'_api.json')).read_text())
w=json.loads(im.info['workflow']);nodes={n['id']:n for n in w['nodes']}
for link in w['links']:
assert link[0] in nodes[link[1]]['outputs'][link[2]]['links']
assert nodes[link[3]]['inputs'][link[4]]['link']==link[0]
report['runs'][name]={'status':'success','image':str(path),'width':im.width,'height':im.height,'sha256':hashlib.sha256(path.read_bytes()).hexdigest(),'embedded_workflow':True}
report['visual_review_zh']='参考重绘版保留原图的姿势、人物位置、异瞳、木牌文字与泰迪熊;面部、衣服细节和纹理有变化。独立文生图版主要元素吻合,但木牌角度、头发、姿势与光线不同。'
(folder/'manifest.json').write_text(json.dumps(report,ensure_ascii=False,indent=2))
text='''ComfyUI 复刻交付
启动:cd /marimo-moss && bash comfyui.sh
端口:8189(沿用现有登录配置)
工作流列表:MOSS-Recreate
reference.json:参考图低降噪重绘,1248×1920;最接近参考图。
text2image-hires.json:独立文生图后二次采样放大,1248×1920;不读取参考图。
text2image.json:独立文生图首采,832×1280。
对应 *_api.json 可用于 ComfyUI API。
生成的 PNG 都嵌入了对应工作流,可直接拖入 ComfyUI。
reference 工作流需要把 input/122838ea-ff31-43ca-9388-82d083b0dbb2.png 放入 ComfyUI/input。
本机已放好参考图,并已安装全部所需模型和节点。没有新增自定义节点或下载模型。
模型:MOSS Image SFT BF16、Qwen3.5 9B BF16 文本编码器、Flux2 small VAE。未使用 LoRA。
原图没有嵌入原始工作流、提示词或种子。本次为视觉分析后重建,不是原始参数恢复。
reference 是使用原图重绘的结果,不能当作独立文生图复现。
种子固定为 122838;文生图高分辨率二采种子 122839。
完整参数、来源和执行结果见 manifest.json 与各工作流。
'''
(folder/'使用说明.txt').write_text(text)
with zipfile.ZipFile(folder/'moss-recreation.zip','w',compression=zipfile.ZIP_DEFLATED) as z:
for name in ['text2image','reference','text2image-hires']:
for suffix in ['.json','_api.json']:
z.write(folder/(name+suffix),'workflows/'+name+suffix)
p=Path(report['runs'][name]['image']);z.write(p,'output/'+p.name)
z.write('/122838ea-ff31-43ca-9388-82d083b0dbb2.png','input/122838ea-ff31-43ca-9388-82d083b0dbb2.png')
for name in ['manifest.json','使用说明.txt']:z.write(folder/name,name)
print(json.dumps(report['runs'],ensure_ascii=False,indent=2))
print('Package:',folder/'moss-recreation.zip')

Xet Storage Details

Size:
3.53 kB
·
Xet hash:
3ceb828a78577d6d7a192b55f7143497aa57279865d5f46a696bc4671e30d116

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.