save code
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"3": {
|
||||
"inputs": {
|
||||
"seed": 253399224428638,
|
||||
"steps": 20,
|
||||
"cfg": 8,
|
||||
"sampler_name": "euler",
|
||||
"scheduler": "normal",
|
||||
"denoise": 1,
|
||||
"model": [
|
||||
"4",
|
||||
0
|
||||
],
|
||||
"positive": [
|
||||
"6",
|
||||
0
|
||||
],
|
||||
"negative": [
|
||||
"7",
|
||||
0
|
||||
],
|
||||
"latent_image": [
|
||||
"5",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "KSampler",
|
||||
"_meta": {
|
||||
"title": "KSampler"
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"inputs": {
|
||||
"ckpt_name": "v1-5-pruned-emaonly-fp16.safetensors"
|
||||
},
|
||||
"class_type": "CheckpointLoaderSimple",
|
||||
"_meta": {
|
||||
"title": "Load Checkpoint"
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"inputs": {
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"batch_size": 1
|
||||
},
|
||||
"class_type": "EmptyLatentImage",
|
||||
"_meta": {
|
||||
"title": "Empty Latent Image"
|
||||
}
|
||||
},
|
||||
"6": {
|
||||
"inputs": {
|
||||
"text": "masterpiece best quality girl",
|
||||
"clip": [
|
||||
"4",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPTextEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Text Encode (Prompt)"
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"inputs": {
|
||||
"text": "bad hands",
|
||||
"clip": [
|
||||
"4",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPTextEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Text Encode (Prompt)"
|
||||
}
|
||||
},
|
||||
"8": {
|
||||
"inputs": {
|
||||
"samples": [
|
||||
"3",
|
||||
0
|
||||
],
|
||||
"vae": [
|
||||
"4",
|
||||
2
|
||||
]
|
||||
},
|
||||
"class_type": "VAEDecode",
|
||||
"_meta": {
|
||||
"title": "VAE Decode"
|
||||
}
|
||||
},
|
||||
"9": {
|
||||
"inputs": {
|
||||
"image": "cloth_short.jpg"
|
||||
},
|
||||
"class_type": "LoadImage",
|
||||
"_meta": {
|
||||
"title": "Load Image"
|
||||
}
|
||||
},
|
||||
"10": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"8",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"12": {
|
||||
"inputs": {
|
||||
"filename_prefix": "MySaveImg",
|
||||
"images": [
|
||||
"9",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "SaveImage",
|
||||
"_meta": {
|
||||
"title": "Save Image"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,786 @@
|
||||
{
|
||||
"3": {
|
||||
"inputs": {
|
||||
"seed": 191964061751443,
|
||||
"steps": 20,
|
||||
"cfg": 1,
|
||||
"sampler_name": "euler",
|
||||
"scheduler": "simple",
|
||||
"denoise": 1,
|
||||
"model": [
|
||||
"13",
|
||||
0
|
||||
],
|
||||
"positive": [
|
||||
"17",
|
||||
0
|
||||
],
|
||||
"negative": [
|
||||
"17",
|
||||
1
|
||||
],
|
||||
"latent_image": [
|
||||
"17",
|
||||
2
|
||||
]
|
||||
},
|
||||
"class_type": "KSampler",
|
||||
"_meta": {
|
||||
"title": "KSampler"
|
||||
}
|
||||
},
|
||||
"6": {
|
||||
"inputs": {
|
||||
"text": "",
|
||||
"clip": [
|
||||
"12",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPTextEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Text Encode (Prompt)"
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"inputs": {
|
||||
"text": "",
|
||||
"clip": [
|
||||
"12",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPTextEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Text Encode (Prompt)"
|
||||
}
|
||||
},
|
||||
"8": {
|
||||
"inputs": {
|
||||
"samples": [
|
||||
"3",
|
||||
0
|
||||
],
|
||||
"vae": [
|
||||
"16",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "VAEDecode",
|
||||
"_meta": {
|
||||
"title": "VAE Decode"
|
||||
}
|
||||
},
|
||||
"10": {
|
||||
"inputs": {
|
||||
"strength": 1,
|
||||
"strength_type": "multiply",
|
||||
"conditioning": [
|
||||
"11",
|
||||
0
|
||||
],
|
||||
"style_model": [
|
||||
"79",
|
||||
0
|
||||
],
|
||||
"clip_vision_output": [
|
||||
"20",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "StyleModelApply",
|
||||
"_meta": {
|
||||
"title": "Apply Style Model"
|
||||
}
|
||||
},
|
||||
"11": {
|
||||
"inputs": {
|
||||
"guidance": 30,
|
||||
"conditioning": [
|
||||
"6",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "FluxGuidance",
|
||||
"_meta": {
|
||||
"title": "FluxGuidance"
|
||||
}
|
||||
},
|
||||
"12": {
|
||||
"inputs": {
|
||||
"clip_name1": "flux/t5xxl_fp16.safetensors",
|
||||
"clip_name2": "clip_l.safetensors",
|
||||
"type": "flux",
|
||||
"device": "default"
|
||||
},
|
||||
"class_type": "DualCLIPLoader",
|
||||
"_meta": {
|
||||
"title": "DualCLIPLoader"
|
||||
}
|
||||
},
|
||||
"13": {
|
||||
"inputs": {
|
||||
"model": [
|
||||
"75",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "DifferentialDiffusion",
|
||||
"_meta": {
|
||||
"title": "Differential Diffusion"
|
||||
}
|
||||
},
|
||||
"16": {
|
||||
"inputs": {
|
||||
"vae_name": "ae.safetensors"
|
||||
},
|
||||
"class_type": "VAELoader",
|
||||
"_meta": {
|
||||
"title": "Load VAE"
|
||||
}
|
||||
},
|
||||
"17": {
|
||||
"inputs": {
|
||||
"noise_mask": false,
|
||||
"positive": [
|
||||
"10",
|
||||
0
|
||||
],
|
||||
"negative": [
|
||||
"7",
|
||||
0
|
||||
],
|
||||
"vae": [
|
||||
"16",
|
||||
0
|
||||
],
|
||||
"pixels": [
|
||||
"27",
|
||||
1
|
||||
],
|
||||
"mask": [
|
||||
"27",
|
||||
2
|
||||
]
|
||||
},
|
||||
"class_type": "InpaintModelConditioning",
|
||||
"_meta": {
|
||||
"title": "InpaintModelConditioning"
|
||||
}
|
||||
},
|
||||
"20": {
|
||||
"inputs": {
|
||||
"crop": "center",
|
||||
"clip_vision": [
|
||||
"21",
|
||||
0
|
||||
],
|
||||
"image": [
|
||||
"25",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPVisionEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Vision Encode"
|
||||
}
|
||||
},
|
||||
"21": {
|
||||
"inputs": {
|
||||
"clip_name": "sigclip_vision_patch14_384.safetensors"
|
||||
},
|
||||
"class_type": "CLIPVisionLoader",
|
||||
"_meta": {
|
||||
"title": "Load CLIP Vision"
|
||||
}
|
||||
},
|
||||
"22": {
|
||||
"inputs": {
|
||||
"image": "cloth_short.jpg"
|
||||
},
|
||||
"class_type": "LoadImage",
|
||||
"_meta": {
|
||||
"title": "Load Image"
|
||||
}
|
||||
},
|
||||
"25": {
|
||||
"inputs": {
|
||||
"width": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"height": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"interpolation": "nearest",
|
||||
"method": "keep proportion",
|
||||
"condition": "always",
|
||||
"multiple_of": 0,
|
||||
"image": [
|
||||
"22",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageResize+",
|
||||
"_meta": {
|
||||
"title": "🔧 Image Resize"
|
||||
}
|
||||
},
|
||||
"26": {
|
||||
"inputs": {
|
||||
"width": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"height": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"interpolation": "nearest",
|
||||
"method": "keep proportion",
|
||||
"condition": "always",
|
||||
"multiple_of": 0,
|
||||
"image": [
|
||||
"61",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageResize+",
|
||||
"_meta": {
|
||||
"title": "🔧 Image Resize"
|
||||
}
|
||||
},
|
||||
"27": {
|
||||
"inputs": {
|
||||
"context_expand_pixels": 20,
|
||||
"context_expand_factor": 1,
|
||||
"fill_mask_holes": true,
|
||||
"blur_mask_pixels": 10,
|
||||
"invert_mask": false,
|
||||
"blend_pixels": 16,
|
||||
"rescale_algorithm": "bicubic",
|
||||
"mode": "ranged size",
|
||||
"force_width": 1024,
|
||||
"force_height": 1024,
|
||||
"rescale_factor": 1,
|
||||
"min_width": 512,
|
||||
"min_height": 512,
|
||||
"max_width": 1800,
|
||||
"max_height": 1800,
|
||||
"padding": 32,
|
||||
"image": [
|
||||
"42",
|
||||
0
|
||||
],
|
||||
"mask": [
|
||||
"30",
|
||||
0
|
||||
],
|
||||
"optional_context_mask": [
|
||||
"40",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "InpaintCrop",
|
||||
"_meta": {
|
||||
"title": "(OLD 💀, use the new ✂️ Inpaint Crop node)"
|
||||
}
|
||||
},
|
||||
"28": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"96",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "MaskToImage",
|
||||
"_meta": {
|
||||
"title": "Convert Mask to Image"
|
||||
}
|
||||
},
|
||||
"29": {
|
||||
"inputs": {
|
||||
"width": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"height": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"interpolation": "nearest",
|
||||
"method": "keep proportion",
|
||||
"condition": "always",
|
||||
"multiple_of": 0,
|
||||
"image": [
|
||||
"28",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageResize+",
|
||||
"_meta": {
|
||||
"title": "🔧 Image Resize"
|
||||
}
|
||||
},
|
||||
"30": {
|
||||
"inputs": {
|
||||
"channel": "red",
|
||||
"image": [
|
||||
"43",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageToMask",
|
||||
"_meta": {
|
||||
"title": "Convert Image to Mask"
|
||||
}
|
||||
},
|
||||
"34": {
|
||||
"inputs": {
|
||||
"rescale_algorithm": "bislerp",
|
||||
"stitch": [
|
||||
"27",
|
||||
0
|
||||
],
|
||||
"inpainted_image": [
|
||||
"8",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "InpaintStitch",
|
||||
"_meta": {
|
||||
"title": "(OLD 💀, use the new ✂️ Inpaint Stitch node)"
|
||||
}
|
||||
},
|
||||
"37": {
|
||||
"inputs": {
|
||||
"direction": "right",
|
||||
"match_image_size": true,
|
||||
"image1": [
|
||||
"38",
|
||||
0
|
||||
],
|
||||
"image2": [
|
||||
"57",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageConcanate",
|
||||
"_meta": {
|
||||
"title": "Image Concatenate"
|
||||
}
|
||||
},
|
||||
"38": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"71:2",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "MaskToImage",
|
||||
"_meta": {
|
||||
"title": "Convert Mask to Image"
|
||||
}
|
||||
},
|
||||
"40": {
|
||||
"inputs": {
|
||||
"channel": "red",
|
||||
"image": [
|
||||
"37",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageToMask",
|
||||
"_meta": {
|
||||
"title": "Convert Image to Mask"
|
||||
}
|
||||
},
|
||||
"42": {
|
||||
"inputs": {
|
||||
"direction": "right",
|
||||
"match_image_size": true,
|
||||
"image1": [
|
||||
"25",
|
||||
0
|
||||
],
|
||||
"image2": [
|
||||
"26",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageConcanate",
|
||||
"_meta": {
|
||||
"title": "Image Concatenate"
|
||||
}
|
||||
},
|
||||
"43": {
|
||||
"inputs": {
|
||||
"direction": "right",
|
||||
"match_image_size": true,
|
||||
"image1": [
|
||||
"59",
|
||||
0
|
||||
],
|
||||
"image2": [
|
||||
"29",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageConcanate",
|
||||
"_meta": {
|
||||
"title": "Image Concatenate"
|
||||
}
|
||||
},
|
||||
"45": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"42",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"57": {
|
||||
"inputs": {
|
||||
"brightness": -1,
|
||||
"contrast": 0,
|
||||
"saturation": 0,
|
||||
"sharpness": 0,
|
||||
"blur": 0,
|
||||
"gaussian_blur": 0,
|
||||
"edge_enhance": 0,
|
||||
"detail_enhance": "false",
|
||||
"image": [
|
||||
"26",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "Image Filter Adjustments",
|
||||
"_meta": {
|
||||
"title": "Image Filter Adjustments"
|
||||
}
|
||||
},
|
||||
"59": {
|
||||
"inputs": {
|
||||
"brightness": -1,
|
||||
"contrast": 1,
|
||||
"saturation": 1,
|
||||
"sharpness": 1,
|
||||
"blur": 0,
|
||||
"gaussian_blur": 48.1,
|
||||
"edge_enhance": 0,
|
||||
"detail_enhance": "false",
|
||||
"image": [
|
||||
"25",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "Image Filter Adjustments",
|
||||
"_meta": {
|
||||
"title": "Image Filter Adjustments"
|
||||
}
|
||||
},
|
||||
"61": {
|
||||
"inputs": {
|
||||
"image": "girl_full.jpg"
|
||||
},
|
||||
"class_type": "LoadImage",
|
||||
"_meta": {
|
||||
"title": "Load Image"
|
||||
}
|
||||
},
|
||||
"75": {
|
||||
"inputs": {
|
||||
"model_path": "svdq-int4-flux.1-fill-dev",
|
||||
"cache_threshold": 0,
|
||||
"attention": "nunchaku-fp16",
|
||||
"cpu_offload": "auto",
|
||||
"device_id": 0,
|
||||
"data_type": "bfloat16",
|
||||
"i2f_mode": "enabled"
|
||||
},
|
||||
"class_type": "NunchakuFluxDiTLoader",
|
||||
"_meta": {
|
||||
"title": "Nunchaku FLUX DiT Loader"
|
||||
}
|
||||
},
|
||||
"79": {
|
||||
"inputs": {
|
||||
"style_model_name": "flux1-redux-dev.safetensors"
|
||||
},
|
||||
"class_type": "StyleModelLoader",
|
||||
"_meta": {
|
||||
"title": "Load Style Model"
|
||||
}
|
||||
},
|
||||
"83": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"29",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"84": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"43",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"85": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"30",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "MaskPreview",
|
||||
"_meta": {
|
||||
"title": "MaskPreview"
|
||||
}
|
||||
},
|
||||
"86": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"71:2",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "MaskPreview+",
|
||||
"_meta": {
|
||||
"title": "🔧 Mask Preview"
|
||||
}
|
||||
},
|
||||
"87": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"38",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"88": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"37",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"89": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"57",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"90": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"59",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"91": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"27",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
},
|
||||
"93": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"27",
|
||||
2
|
||||
]
|
||||
},
|
||||
"class_type": "MaskPreview",
|
||||
"_meta": {
|
||||
"title": "MaskPreview"
|
||||
}
|
||||
},
|
||||
"94": {
|
||||
"inputs": {
|
||||
"value": 1024
|
||||
},
|
||||
"class_type": "PrimitiveInt",
|
||||
"_meta": {
|
||||
"title": "Int"
|
||||
}
|
||||
},
|
||||
"95": {
|
||||
"inputs": {
|
||||
"detect_hand": "disable",
|
||||
"detect_body": "enable",
|
||||
"detect_face": "disable",
|
||||
"resolution": 512,
|
||||
"bbox_detector": "yolo_nas_m_fp16.onnx",
|
||||
"pose_estimator": "dw-ll_ucoco_384.onnx",
|
||||
"scale_stick_for_xinsr_cn": "disable",
|
||||
"image": [
|
||||
"61",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "DWPreprocessor",
|
||||
"_meta": {
|
||||
"title": "DWPose Estimator"
|
||||
}
|
||||
},
|
||||
"96": {
|
||||
"inputs": {
|
||||
"changdu": "yao",
|
||||
"kps": [
|
||||
"95",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "RenderPeopleKpsMask",
|
||||
"_meta": {
|
||||
"title": "My RenderPeopleKps Mask"
|
||||
}
|
||||
},
|
||||
"97": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"61",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "MaskPreview",
|
||||
"_meta": {
|
||||
"title": "MaskPreview"
|
||||
}
|
||||
},
|
||||
"98": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"96",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "MaskPreview",
|
||||
"_meta": {
|
||||
"title": "MaskPreview"
|
||||
}
|
||||
},
|
||||
"99": {
|
||||
"inputs": {
|
||||
"width": 600,
|
||||
"height": 1024,
|
||||
"x": 700,
|
||||
"y": 0,
|
||||
"image": [
|
||||
"34",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageCrop",
|
||||
"_meta": {
|
||||
"title": "Image Crop"
|
||||
}
|
||||
},
|
||||
"102": {
|
||||
"inputs": {
|
||||
"filename_prefix": "my_test_out",
|
||||
"images": [
|
||||
"99",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "SaveImage",
|
||||
"_meta": {
|
||||
"title": "Save Image"
|
||||
}
|
||||
},
|
||||
"71:0": {
|
||||
"inputs": {
|
||||
"model_name": "sam_vit_h (2.56GB)"
|
||||
},
|
||||
"class_type": "SAMModelLoader (segment anything)",
|
||||
"_meta": {
|
||||
"title": "SAMModelLoader (segment anything)"
|
||||
}
|
||||
},
|
||||
"71:1": {
|
||||
"inputs": {
|
||||
"model_name": "GroundingDINO_SwinT_OGC (694MB)"
|
||||
},
|
||||
"class_type": "GroundingDinoModelLoader (segment anything)",
|
||||
"_meta": {
|
||||
"title": "GroundingDinoModelLoader (segment anything)"
|
||||
}
|
||||
},
|
||||
"71:2": {
|
||||
"inputs": {
|
||||
"prompt": "shoes",
|
||||
"threshold": 0.3,
|
||||
"sam_model": [
|
||||
"71:0",
|
||||
0
|
||||
],
|
||||
"grounding_dino_model": [
|
||||
"71:1",
|
||||
0
|
||||
],
|
||||
"image": [
|
||||
"25",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "GroundingDinoSAMSegment (segment anything)",
|
||||
"_meta": {
|
||||
"title": "GroundingDinoSAMSegment (segment anything)"
|
||||
}
|
||||
},
|
||||
"71:3": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"71:2",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
}
|
||||
}
|
||||
+630
@@ -0,0 +1,630 @@
|
||||
{
|
||||
"3": {
|
||||
"inputs": {
|
||||
"seed": 351739583278114,
|
||||
"steps": 20,
|
||||
"cfg": 1,
|
||||
"sampler_name": "euler",
|
||||
"scheduler": "simple",
|
||||
"denoise": 1,
|
||||
"model": [
|
||||
"13",
|
||||
0
|
||||
],
|
||||
"positive": [
|
||||
"17",
|
||||
0
|
||||
],
|
||||
"negative": [
|
||||
"17",
|
||||
1
|
||||
],
|
||||
"latent_image": [
|
||||
"17",
|
||||
2
|
||||
]
|
||||
},
|
||||
"class_type": "KSampler",
|
||||
"_meta": {
|
||||
"title": "KSampler"
|
||||
}
|
||||
},
|
||||
"6": {
|
||||
"inputs": {
|
||||
"text": "",
|
||||
"clip": [
|
||||
"12",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPTextEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Text Encode (Prompt)"
|
||||
}
|
||||
},
|
||||
"7": {
|
||||
"inputs": {
|
||||
"text": "",
|
||||
"clip": [
|
||||
"12",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPTextEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Text Encode (Prompt)"
|
||||
}
|
||||
},
|
||||
"8": {
|
||||
"inputs": {
|
||||
"samples": [
|
||||
"3",
|
||||
0
|
||||
],
|
||||
"vae": [
|
||||
"16",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "VAEDecode",
|
||||
"_meta": {
|
||||
"title": "VAE Decode"
|
||||
}
|
||||
},
|
||||
"10": {
|
||||
"inputs": {
|
||||
"strength": 1,
|
||||
"strength_type": "multiply",
|
||||
"conditioning": [
|
||||
"11",
|
||||
0
|
||||
],
|
||||
"style_model": [
|
||||
"79",
|
||||
0
|
||||
],
|
||||
"clip_vision_output": [
|
||||
"20",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "StyleModelApply",
|
||||
"_meta": {
|
||||
"title": "Apply Style Model"
|
||||
}
|
||||
},
|
||||
"11": {
|
||||
"inputs": {
|
||||
"guidance": 30,
|
||||
"conditioning": [
|
||||
"6",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "FluxGuidance",
|
||||
"_meta": {
|
||||
"title": "FluxGuidance"
|
||||
}
|
||||
},
|
||||
"12": {
|
||||
"inputs": {
|
||||
"clip_name1": "flux/t5xxl_fp16.safetensors",
|
||||
"clip_name2": "clip_l.safetensors",
|
||||
"type": "flux",
|
||||
"device": "default"
|
||||
},
|
||||
"class_type": "DualCLIPLoader",
|
||||
"_meta": {
|
||||
"title": "DualCLIPLoader"
|
||||
}
|
||||
},
|
||||
"13": {
|
||||
"inputs": {
|
||||
"model": [
|
||||
"75",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "DifferentialDiffusion",
|
||||
"_meta": {
|
||||
"title": "Differential Diffusion"
|
||||
}
|
||||
},
|
||||
"16": {
|
||||
"inputs": {
|
||||
"vae_name": "ae.safetensors"
|
||||
},
|
||||
"class_type": "VAELoader",
|
||||
"_meta": {
|
||||
"title": "Load VAE"
|
||||
}
|
||||
},
|
||||
"17": {
|
||||
"inputs": {
|
||||
"noise_mask": false,
|
||||
"positive": [
|
||||
"10",
|
||||
0
|
||||
],
|
||||
"negative": [
|
||||
"7",
|
||||
0
|
||||
],
|
||||
"vae": [
|
||||
"16",
|
||||
0
|
||||
],
|
||||
"pixels": [
|
||||
"27",
|
||||
1
|
||||
],
|
||||
"mask": [
|
||||
"27",
|
||||
2
|
||||
]
|
||||
},
|
||||
"class_type": "InpaintModelConditioning",
|
||||
"_meta": {
|
||||
"title": "InpaintModelConditioning"
|
||||
}
|
||||
},
|
||||
"20": {
|
||||
"inputs": {
|
||||
"crop": "center",
|
||||
"clip_vision": [
|
||||
"21",
|
||||
0
|
||||
],
|
||||
"image": [
|
||||
"25",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "CLIPVisionEncode",
|
||||
"_meta": {
|
||||
"title": "CLIP Vision Encode"
|
||||
}
|
||||
},
|
||||
"21": {
|
||||
"inputs": {
|
||||
"clip_name": "sigclip_vision_patch14_384.safetensors"
|
||||
},
|
||||
"class_type": "CLIPVisionLoader",
|
||||
"_meta": {
|
||||
"title": "Load CLIP Vision"
|
||||
}
|
||||
},
|
||||
"22": {
|
||||
"inputs": {
|
||||
"image": "cloth_short.jpg"
|
||||
},
|
||||
"class_type": "LoadImage",
|
||||
"_meta": {
|
||||
"title": "Load Image"
|
||||
}
|
||||
},
|
||||
"25": {
|
||||
"inputs": {
|
||||
"width": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"height": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"interpolation": "nearest",
|
||||
"method": "keep proportion",
|
||||
"condition": "always",
|
||||
"multiple_of": 0,
|
||||
"image": [
|
||||
"22",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageResize+",
|
||||
"_meta": {
|
||||
"title": "🔧 Image Resize"
|
||||
}
|
||||
},
|
||||
"26": {
|
||||
"inputs": {
|
||||
"width": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"height": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"interpolation": "nearest",
|
||||
"method": "keep proportion",
|
||||
"condition": "always",
|
||||
"multiple_of": 0,
|
||||
"image": [
|
||||
"61",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageResize+",
|
||||
"_meta": {
|
||||
"title": "🔧 Image Resize"
|
||||
}
|
||||
},
|
||||
"27": {
|
||||
"inputs": {
|
||||
"context_expand_pixels": 20,
|
||||
"context_expand_factor": 1,
|
||||
"fill_mask_holes": true,
|
||||
"blur_mask_pixels": 10,
|
||||
"invert_mask": false,
|
||||
"blend_pixels": 16,
|
||||
"rescale_algorithm": "bicubic",
|
||||
"mode": "ranged size",
|
||||
"force_width": 1024,
|
||||
"force_height": 1024,
|
||||
"rescale_factor": 1,
|
||||
"min_width": 512,
|
||||
"min_height": 512,
|
||||
"max_width": 1800,
|
||||
"max_height": 1800,
|
||||
"padding": 32,
|
||||
"image": [
|
||||
"42",
|
||||
0
|
||||
],
|
||||
"mask": [
|
||||
"30",
|
||||
0
|
||||
],
|
||||
"optional_context_mask": [
|
||||
"40",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "InpaintCrop",
|
||||
"_meta": {
|
||||
"title": "(OLD 💀, use the new ✂️ Inpaint Crop node)"
|
||||
}
|
||||
},
|
||||
"28": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"96",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "MaskToImage",
|
||||
"_meta": {
|
||||
"title": "Convert Mask to Image"
|
||||
}
|
||||
},
|
||||
"29": {
|
||||
"inputs": {
|
||||
"width": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"height": [
|
||||
"94",
|
||||
0
|
||||
],
|
||||
"interpolation": "nearest",
|
||||
"method": "keep proportion",
|
||||
"condition": "always",
|
||||
"multiple_of": 0,
|
||||
"image": [
|
||||
"28",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageResize+",
|
||||
"_meta": {
|
||||
"title": "🔧 Image Resize"
|
||||
}
|
||||
},
|
||||
"30": {
|
||||
"inputs": {
|
||||
"channel": "red",
|
||||
"image": [
|
||||
"43",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageToMask",
|
||||
"_meta": {
|
||||
"title": "Convert Image to Mask"
|
||||
}
|
||||
},
|
||||
"34": {
|
||||
"inputs": {
|
||||
"rescale_algorithm": "bislerp",
|
||||
"stitch": [
|
||||
"27",
|
||||
0
|
||||
],
|
||||
"inpainted_image": [
|
||||
"8",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "InpaintStitch",
|
||||
"_meta": {
|
||||
"title": "(OLD 💀, use the new ✂️ Inpaint Stitch node)"
|
||||
}
|
||||
},
|
||||
"37": {
|
||||
"inputs": {
|
||||
"direction": "right",
|
||||
"match_image_size": true,
|
||||
"image1": [
|
||||
"38",
|
||||
0
|
||||
],
|
||||
"image2": [
|
||||
"57",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageConcanate",
|
||||
"_meta": {
|
||||
"title": "Image Concatenate"
|
||||
}
|
||||
},
|
||||
"38": {
|
||||
"inputs": {
|
||||
"mask": [
|
||||
"71:2",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "MaskToImage",
|
||||
"_meta": {
|
||||
"title": "Convert Mask to Image"
|
||||
}
|
||||
},
|
||||
"40": {
|
||||
"inputs": {
|
||||
"channel": "red",
|
||||
"image": [
|
||||
"37",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageToMask",
|
||||
"_meta": {
|
||||
"title": "Convert Image to Mask"
|
||||
}
|
||||
},
|
||||
"42": {
|
||||
"inputs": {
|
||||
"direction": "right",
|
||||
"match_image_size": true,
|
||||
"image1": [
|
||||
"25",
|
||||
0
|
||||
],
|
||||
"image2": [
|
||||
"26",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageConcanate",
|
||||
"_meta": {
|
||||
"title": "Image Concatenate"
|
||||
}
|
||||
},
|
||||
"43": {
|
||||
"inputs": {
|
||||
"direction": "right",
|
||||
"match_image_size": true,
|
||||
"image1": [
|
||||
"59",
|
||||
0
|
||||
],
|
||||
"image2": [
|
||||
"29",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageConcanate",
|
||||
"_meta": {
|
||||
"title": "Image Concatenate"
|
||||
}
|
||||
},
|
||||
"57": {
|
||||
"inputs": {
|
||||
"brightness": -1,
|
||||
"contrast": 0,
|
||||
"saturation": 0,
|
||||
"sharpness": 0,
|
||||
"blur": 0,
|
||||
"gaussian_blur": 0,
|
||||
"edge_enhance": 0,
|
||||
"detail_enhance": "false",
|
||||
"image": [
|
||||
"26",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "Image Filter Adjustments",
|
||||
"_meta": {
|
||||
"title": "Image Filter Adjustments"
|
||||
}
|
||||
},
|
||||
"59": {
|
||||
"inputs": {
|
||||
"brightness": -1,
|
||||
"contrast": 1,
|
||||
"saturation": 1,
|
||||
"sharpness": 1,
|
||||
"blur": 0,
|
||||
"gaussian_blur": 48.1,
|
||||
"edge_enhance": 0,
|
||||
"detail_enhance": "false",
|
||||
"image": [
|
||||
"25",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "Image Filter Adjustments",
|
||||
"_meta": {
|
||||
"title": "Image Filter Adjustments"
|
||||
}
|
||||
},
|
||||
"61": {
|
||||
"inputs": {
|
||||
"image": "girl_full_2.webp"
|
||||
},
|
||||
"class_type": "LoadImage",
|
||||
"_meta": {
|
||||
"title": "Load Image"
|
||||
}
|
||||
},
|
||||
"75": {
|
||||
"inputs": {
|
||||
"model_path": "svdq-int4-flux.1-fill-dev",
|
||||
"cache_threshold": 0,
|
||||
"attention": "nunchaku-fp16",
|
||||
"cpu_offload": "auto",
|
||||
"device_id": 0,
|
||||
"data_type": "bfloat16",
|
||||
"i2f_mode": "enabled"
|
||||
},
|
||||
"class_type": "NunchakuFluxDiTLoader",
|
||||
"_meta": {
|
||||
"title": "Nunchaku FLUX DiT Loader"
|
||||
}
|
||||
},
|
||||
"79": {
|
||||
"inputs": {
|
||||
"style_model_name": "flux1-redux-dev.safetensors"
|
||||
},
|
||||
"class_type": "StyleModelLoader",
|
||||
"_meta": {
|
||||
"title": "Load Style Model"
|
||||
}
|
||||
},
|
||||
"94": {
|
||||
"inputs": {
|
||||
"value": 1024
|
||||
},
|
||||
"class_type": "PrimitiveInt",
|
||||
"_meta": {
|
||||
"title": "Int"
|
||||
}
|
||||
},
|
||||
"95": {
|
||||
"inputs": {
|
||||
"detect_hand": "disable",
|
||||
"detect_body": "enable",
|
||||
"detect_face": "disable",
|
||||
"resolution": 512,
|
||||
"bbox_detector": "yolo_nas_m_fp16.onnx",
|
||||
"pose_estimator": "dw-ll_ucoco_384.onnx",
|
||||
"scale_stick_for_xinsr_cn": "disable",
|
||||
"image": [
|
||||
"61",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "DWPreprocessor",
|
||||
"_meta": {
|
||||
"title": "DWPose Estimator"
|
||||
}
|
||||
},
|
||||
"96": {
|
||||
"inputs": {
|
||||
"changdu": "yao",
|
||||
"kps": [
|
||||
"95",
|
||||
1
|
||||
]
|
||||
},
|
||||
"class_type": "RenderPeopleKpsMask",
|
||||
"_meta": {
|
||||
"title": "My RenderPeopleKps Mask"
|
||||
}
|
||||
},
|
||||
"99": {
|
||||
"inputs": {
|
||||
"width": 600,
|
||||
"height": 1024,
|
||||
"x": 700,
|
||||
"y": 0,
|
||||
"image": [
|
||||
"34",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "ImageCrop",
|
||||
"_meta": {
|
||||
"title": "Image Crop"
|
||||
}
|
||||
},
|
||||
"102": {
|
||||
"inputs": {
|
||||
"filename_prefix": "my_test_out",
|
||||
"images": [
|
||||
"99",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "SaveImage",
|
||||
"_meta": {
|
||||
"title": "Save Image"
|
||||
}
|
||||
},
|
||||
"71:0": {
|
||||
"inputs": {
|
||||
"model_name": "sam_vit_h (2.56GB)"
|
||||
},
|
||||
"class_type": "SAMModelLoader (segment anything)",
|
||||
"_meta": {
|
||||
"title": "SAMModelLoader (segment anything)"
|
||||
}
|
||||
},
|
||||
"71:1": {
|
||||
"inputs": {
|
||||
"model_name": "GroundingDINO_SwinT_OGC (694MB)"
|
||||
},
|
||||
"class_type": "GroundingDinoModelLoader (segment anything)",
|
||||
"_meta": {
|
||||
"title": "GroundingDinoModelLoader (segment anything)"
|
||||
}
|
||||
},
|
||||
"71:2": {
|
||||
"inputs": {
|
||||
"prompt": "shoes",
|
||||
"threshold": 0.3,
|
||||
"sam_model": [
|
||||
"71:0",
|
||||
0
|
||||
],
|
||||
"grounding_dino_model": [
|
||||
"71:1",
|
||||
0
|
||||
],
|
||||
"image": [
|
||||
"25",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "GroundingDinoSAMSegment (segment anything)",
|
||||
"_meta": {
|
||||
"title": "GroundingDinoSAMSegment (segment anything)"
|
||||
}
|
||||
},
|
||||
"71:3": {
|
||||
"inputs": {
|
||||
"images": [
|
||||
"71:2",
|
||||
0
|
||||
]
|
||||
},
|
||||
"class_type": "PreviewImage",
|
||||
"_meta": {
|
||||
"title": "Preview Image"
|
||||
}
|
||||
}
|
||||
}
|
||||
+168
-18
@@ -5,6 +5,13 @@ from flask import Flask, request, jsonify
|
||||
from urllib.parse import urlparse
|
||||
from volcenginesdkarkruntime import Ark
|
||||
import json
|
||||
import base64
|
||||
import time
|
||||
from PIL import Image
|
||||
from datetime import datetime
|
||||
|
||||
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||
STATIC_FOLDER = os.path.join(APP_ROOT, 'static')
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@@ -102,6 +109,48 @@ def save_image_from_url(image_url):
|
||||
print(f"Error saving image from URL: {e}")
|
||||
return None
|
||||
|
||||
def change(human_name, cloth_name, c_width, c_height):
|
||||
with open('/home/szlc/code/ComfyUI/change_cloth/change_new.json', 'r', encoding='utf-8') as file:
|
||||
prompt_text = file.read()
|
||||
|
||||
prompt = json.loads(prompt_text)
|
||||
|
||||
prompt["99"]["inputs"]["width"] = int((c_width/c_height) * 1024)
|
||||
|
||||
#input cloth img
|
||||
prompt["22"]["inputs"]["image"] = cloth_name
|
||||
|
||||
#input human img
|
||||
prompt["61"]["inputs"]["image"] = human_name
|
||||
|
||||
#out put name
|
||||
out_img_name = str(uuid.uuid4())[:8]
|
||||
prompt["102"]["inputs"]["filename_prefix"] = out_img_name
|
||||
|
||||
p = {"prompt": prompt}
|
||||
|
||||
data = json.dumps(p).encode('utf-8')
|
||||
|
||||
response = requests.post("http://localhost:8188/prompt", data=data)
|
||||
prompt_id = response.json()["prompt_id"]
|
||||
|
||||
|
||||
# 2. 轮询队列,直到任务完成
|
||||
while True:
|
||||
queue = requests.get("http://localhost:8188/queue").json()
|
||||
# print(queue)
|
||||
if not queue["queue_running"] and not queue["queue_pending"]:
|
||||
break # 队列为空,任务已完成
|
||||
time.sleep(0.5) # 避免频繁请求
|
||||
|
||||
# 3. 从历史记录中获取结果
|
||||
history = requests.get("http://localhost:8188/history").json()
|
||||
print("History:", history)
|
||||
outputs = history[prompt_id]["outputs"]
|
||||
for out in outputs:
|
||||
if out_img_name in out:
|
||||
return out
|
||||
|
||||
@app.route('/change_cloth', methods=['POST'])
|
||||
def change_cloth():
|
||||
"""从 URL 下载图片"""
|
||||
@@ -128,27 +177,128 @@ def change_cloth():
|
||||
|
||||
return jsonify({"filename": cloth_filename})
|
||||
|
||||
@app.route('/upload_image', methods=['POST'])
|
||||
def upload_image():
|
||||
"""直接上传图片(保留原始格式)"""
|
||||
if 'file' not in request.files:
|
||||
return jsonify({"error": "No file uploaded"}), 400
|
||||
def save_base64_image(base64_str, prefix):
|
||||
"""
|
||||
将base64字符串保存为图片文件
|
||||
:param base64_str: 带有类型标识的base64字符串
|
||||
:param prefix: 文件名前缀
|
||||
:return: 保存的文件路径
|
||||
"""
|
||||
try:
|
||||
# 分离base64头部和实际数据
|
||||
header, data = base64_str.split(',', 1)
|
||||
|
||||
file = request.files['file']
|
||||
if file.filename == '':
|
||||
return jsonify({"error": "Empty filename"}), 400
|
||||
# 从头部获取文件扩展名
|
||||
file_ext = ''
|
||||
if 'image/png' in header:
|
||||
file_ext = '.png'
|
||||
elif 'image/jpeg' in header:
|
||||
file_ext = '.jpg'
|
||||
elif 'image/jpg' in header:
|
||||
file_ext = '.jpg'
|
||||
elif 'image/gif' in header:
|
||||
file_ext = '.gif'
|
||||
else:
|
||||
file_ext = '.png' # 默认使用png
|
||||
|
||||
# 获取原始文件扩展名
|
||||
ext = os.path.splitext(file.filename)[1].lower()
|
||||
if not ext: # 如果无扩展名,默认 PNG
|
||||
ext = '.png'
|
||||
# 生成唯一文件名
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
unique_id = str(uuid.uuid4())[:8]
|
||||
filename = f"{prefix}_{timestamp}_{unique_id}{file_ext}"
|
||||
filepath = os.path.join('/home/szlc/code/ComfyUI/change_cloth/static', filename)
|
||||
|
||||
# 生成唯一文件名(保留原始格式)
|
||||
filename = f"{uuid.uuid4()}{ext}"
|
||||
save_path = os.path.join(COMFYUI_INPUT_DIR, filename)
|
||||
# 解码并保存图片
|
||||
with open(filepath, 'wb') as f:
|
||||
f.write(base64.b64decode(data))
|
||||
|
||||
file.save(save_path)
|
||||
return jsonify({"filename": filename})
|
||||
input_filepath = os.path.join('/home/szlc/code/ComfyUI/input', filename)
|
||||
# 解码并保存图片
|
||||
with open(input_filepath, 'wb') as f:
|
||||
f.write(base64.b64decode(data))
|
||||
|
||||
return filename
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error saving image: {str(e)}")
|
||||
return None
|
||||
|
||||
def get_image_dimensions(image_path):
|
||||
try:
|
||||
with Image.open(image_path) as img:
|
||||
width, height = img.size
|
||||
return width, height
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
return None
|
||||
|
||||
def image_to_base64(file_path, mime_type=None):
|
||||
if mime_type is None:
|
||||
extension = file_path.split('.')[-1].lower()
|
||||
mime_types = {
|
||||
'jpg': 'image/jpeg',
|
||||
'jpeg': 'image/jpeg',
|
||||
'png': 'image/png',
|
||||
'gif': 'image/gif',
|
||||
'webp': 'image/webp',
|
||||
'bmp': 'image/bmp'
|
||||
}
|
||||
mime_type = mime_types.get(extension, 'application/octet-stream')
|
||||
|
||||
# 读取文件内容并编码为Base64
|
||||
with open(file_path, 'rb') as image_file:
|
||||
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
|
||||
|
||||
# 组合成Data URI格式
|
||||
return f"data:{mime_type};base64,{encoded_string}"
|
||||
|
||||
@app.route('/change_cloth_base64', methods=['POST'])
|
||||
def change_cloth_base64():
|
||||
# 获取参数
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({"ret":-1,'msg': 'No JSON data provided'}), 400
|
||||
|
||||
human_img = data.get('human_img')
|
||||
cloth_img = data.get('cloth_img')
|
||||
output_format = data.get('output_format')
|
||||
|
||||
if not human_img or not cloth_img:
|
||||
return jsonify({"ret":-1, 'msg': 'Both human_img and cloth_img are required'}), 400
|
||||
|
||||
try:
|
||||
# 保存人像图片
|
||||
human_filename = save_base64_image(human_img, 'human')
|
||||
if not human_filename:
|
||||
return jsonify({"ret":-1, 'msg': 'Failed to save human image'}), 500
|
||||
|
||||
# 保存服装图片
|
||||
cloth_filename = save_base64_image(cloth_img, 'cloth')
|
||||
if not cloth_filename:
|
||||
return jsonify({"ret":-1, 'msg': 'Failed to save cloth image'}), 500
|
||||
|
||||
w,h = get_image_dimensions(f'/home/szlc/code/ComfyUI/input/{human_filename}')
|
||||
|
||||
out_put_name = change(human_filename, cloth_filename, w, h)
|
||||
image = Image.open(f'/home/szlc/code/ComfyUI/output/{out_put_name}')
|
||||
jpg_name = out_put_name.replace(".png", ".jpg")
|
||||
jpg_path_name = f'/home/szlc/code/ComfyUI/change_cloth/static/{jpg_name}'
|
||||
image.save(jpg_path_name, quality=95)
|
||||
|
||||
if 'base64' in output_format:
|
||||
return jsonify({
|
||||
"ret":0,
|
||||
"msg":"success",
|
||||
"data":image_to_base64(jpg_path_name)
|
||||
})
|
||||
else:
|
||||
return jsonify({
|
||||
"ret":0,
|
||||
"msg":"success",
|
||||
"url":f"http://112.126.94.241:18018/static/{jpg_name}"
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"ret":-1, 'error': str(e)}), 500
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
app.run(host="0.0.0.0", port=8018, debug=True)
|
||||
@@ -34,40 +34,3 @@ def RequestImgAndSave(image_url):
|
||||
# 1. 提交任务
|
||||
|
||||
#RequestImgAndSave("https://example.com/image.jpg")
|
||||
|
||||
with open('/home/szlc/code/ComfyUI/change_cloth/change_bak_api.json', 'r', encoding='utf-8') as file:
|
||||
prompt_text = file.read()
|
||||
|
||||
prompt = json.loads(prompt_text)
|
||||
#set the text prompt for our positive CLIPTextEncode
|
||||
# prompt["6"]["inputs"]["text"] = "one girl"
|
||||
|
||||
#set the seed for our KSampler node
|
||||
# prompt["3"]["inputs"]["seed"] = 5
|
||||
|
||||
# prompt["9"]["inputs"]["image"] = "cloth_long.png"
|
||||
|
||||
prompt["102"]["inputs"]["filename_prefix"] = "xiangsilian"
|
||||
|
||||
p = {"prompt": prompt}
|
||||
|
||||
data = json.dumps(p).encode('utf-8')
|
||||
|
||||
response = requests.post("http://localhost:8188/prompt", data=data)
|
||||
prompt_id = response.json()["prompt_id"]
|
||||
|
||||
|
||||
|
||||
# 2. 轮询队列,直到任务完成
|
||||
while True:
|
||||
queue = requests.get("http://localhost:8188/queue").json()
|
||||
print(queue)
|
||||
if not queue["queue_running"] and not queue["queue_pending"]:
|
||||
break # 队列为空,任务已完成
|
||||
time.sleep(0.5) # 避免频繁请求
|
||||
|
||||
# 3. 从历史记录中获取结果
|
||||
history = requests.get("http://localhost:8188/history").json()
|
||||
print("History:", history)
|
||||
outputs = history[prompt_id]["outputs"]
|
||||
print("Generated outputs:", outputs)
|
||||
@@ -0,0 +1,46 @@
|
||||
import threading
|
||||
import requests
|
||||
import json
|
||||
import base64
|
||||
import time
|
||||
import random
|
||||
|
||||
|
||||
def image_to_base64(file_path, mime_type=None):
|
||||
if mime_type is None:
|
||||
extension = file_path.split('.')[-1].lower()
|
||||
mime_types = {
|
||||
'jpg': 'image/jpeg',
|
||||
'jpeg': 'image/jpeg',
|
||||
'png': 'image/png',
|
||||
'gif': 'image/gif',
|
||||
'webp': 'image/webp',
|
||||
'bmp': 'image/bmp'
|
||||
}
|
||||
mime_type = mime_types.get(extension, 'application/octet-stream')
|
||||
|
||||
# 读取文件内容并编码为Base64
|
||||
with open(file_path, 'rb') as image_file:
|
||||
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
|
||||
|
||||
# 组合成Data URI格式
|
||||
return f"data:{mime_type};base64,{encoded_string}"
|
||||
|
||||
if __name__ == '__main__':
|
||||
url = 'http://112.126.94.241:18018/change_cloth_base64'
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
img64_human_str = image_to_base64("/home/szlc/code/ComfyUI/input/girl_full.jpg")
|
||||
data = {}
|
||||
data['human_img'] = img64_human_str
|
||||
|
||||
img64_cloth_str = image_to_base64("/home/szlc/code/ComfyUI/input/cloth_short.jpg")
|
||||
data['cloth_img'] = img64_cloth_str
|
||||
|
||||
data['output_format'] = "url"
|
||||
|
||||
|
||||
try:
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
print(response.text)
|
||||
except Exception as e:
|
||||
print("error")
|
||||
Reference in New Issue
Block a user