Mask Operations, Combining & Compositing
Interactive walkthrough of core image and mask nodes — create and refine masks, combine overlapping masks with different operations, and composite images…
تنزيل سير العملجرّبه في Cloud وثائق API
حول
Interactive walkthrough of core image and mask nodes — create and refine masks, combine overlapping masks with different operations, and composite images…
ما تقدّمه
- جارٍ قراءة سير العمل
يعمل في ComfyUI. لا يمكن تشغيل سير العمل هذا على هذه الصفحة. نزّله وافتحه في ComfyUI.
تنزيل سير العمللا توجد مخرجات نموذجية لسير العمل هذا بعد.
داخل سير العمل
معاينة للقراءة فقط لرسم العقد البياني. افتحه في Comfy Cloud أو نزّله لتعديل العقد.
Loading the graph
Open full-size workflow preview- Comfy Cloud
- نعم
- المؤلف
- المؤلف غير متاح
يتطلب عُقدًا مخصصة
- جارٍ قراءة سير العمل
استخدم سير العمل هذا من خلال التعليمات البرمجية
يتم إنشاؤه من مخطط سير العمل والمدخلات عندما يكون ذلك ممكنًا؛ وإلا فتُعرض الأمثلة المخزنة. راجع بيانات الاعتماد ونقاط النهاية قبل تشغيل التعليمات البرمجية، إذ قد تترتب عليها رسوم.
1 الحصول على مفتاح API ↗
What you need
- Runs on
- Comfy Cloud
- المفتاح
- COMFY_API_KEY
يتطلب خطة Cloud مدفوعة ورصيدًا.
تنزيل API JSONوثائق API ↗
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"1": {
"class_type": "EmptyImage",
"inputs": {
"batch_size": 1,
"color": 0,
"height": 1024,
"width": 1024
},
"_meta": {
"title": "Empty Image"
}
},
"2": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"1",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"3": {
"class_type": "MaskToImage",
"inputs": {
"mask": [
"5",
0
]
},
"_meta": {
"title": "Convert Mask to Image"
}
},
"4": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"5",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"5": {
"class_type": "ImageToMask",
"inputs": {
"channel": "red",
"image": [
"1",
0
]
},
"_meta": {
"title": "Convert Image to Mask"
}
},
"326": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"3",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"327": {
"class_type": "InvertMask",
"inputs": {
"mask": [
"5",
0
]
},
"_meta": {
"title": "Invert Mask"
}
},
"328": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"327",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"338": {
"class_type": "ThresholdMask",
"inputs": {
"mask": [
"5",
0
],
"value": 0.4099999999999999
},
"_meta": {
"title": "Threshold Mask"
}
},
"340": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"338",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"342": {
"class_type": "FeatherMask",
"inputs": {
"bottom": 0,
"left": 200,
"mask": [
"327",
0
],
"right": 0,
"top": 0
},
"_meta": {
"title": "Feather Mask"
}
},
"343": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"342",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"359": {
"class_type": "ImageCompositeMasked",
"inputs": {
"destination": [
"1",
0
],
"mask": [
"394",
0
],
"resize_source": False,
"source": [
"360",
0
],
"x": 0,
"y": 0
},
"_meta": {
"title": "Image Composite Masked"
}
},
"360": {
"class_type": "EmptyImage",
"inputs": {
"batch_size": 1,
"color": 16711680,
"height": 1024,
"width": 1024
},
"_meta": {
"title": "Empty Image"
}
},
"367": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"360",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"368": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"359",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"369": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"377",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"374": {
"class_type": "LoadImage",
"inputs": {
"image": "example.png"
},
"_meta": {
"title": "Load Image"
}
},
"376": {
"class_type": "MaskComposite",
"inputs": {
"destination": [
"383",
0
],
"operation": "multiply",
"source": [
"398",
0
],
"x": 256,
"y": 256
},
"_meta": {
"title": "Combine Masks"
}
},
"377": {
"class_type": "SolidMask",
"inputs": {
"height": 1024,
"value": 0.5,
"width": 1024
},
"_meta": {
"title": "Create Solid Mask"
}
},
"378": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"376",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"380": {
"class_type": "SolidMask",
"inputs": {
"height": 512,
"value": 1,
"width": 512
},
"_meta": {
"title": "Create Solid Mask"
}
},
"381": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"380",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"383": {
"class_type": "MaskComposite",
"inputs": {
"destination": [
"377",
0
],
"operation": "add",
"source": [
"380",
0
],
"x": 128,
"y": 128
},
"_meta": {
"title": "Combine Masks"
}
},
"384": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"383",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"387": {
"class_type": "MaskComposite",
"inputs": {
"destination": [
"383",
0
],
"operation": "and",
"source": [
"398",
0
],
"x": 256,
"y": 256
},
"_meta": {
"title": "Combine Masks"
}
},
"388": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"387",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"389": {
"class_type": "MaskComposite",
"inputs": {
"destination": [
"383",
0
],
"operation": "or",
"source": [
"398",
0
],
"x": 256,
"y": 256
},
"_meta": {
"title": "Combine Masks"
}
},
"390": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"389",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"391": {
"class_type": "MaskComposite",
"inputs": {
"destination": [
"383",
0
],
"operation": "xor",
"source": [
"398",
0
],
"x": 256,
"y": 256
},
"_meta": {
"title": "Combine Masks"
}
},
"392": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"391",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"394": {
"class_type": "FeatherMask",
"inputs": {
"bottom": 40,
"left": 40,
"mask": [
"383",
0
],
"right": 40,
"top": 40
},
"_meta": {
"title": "Feather Mask"
}
},
"398": {
"class_type": "MaskComposite",
"inputs": {
"destination": [
"377",
0
],
"operation": "add",
"source": [
"380",
0
],
"x": 512,
"y": 512
},
"_meta": {
"title": "Combine Masks"
}
},
"399": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"398",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"400": {
"class_type": "MaskComposite",
"inputs": {
"destination": [
"383",
0
],
"operation": "add",
"source": [
"398",
0
],
"x": 256,
"y": 256
},
"_meta": {
"title": "Combine Masks"
}
},
"401": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"400",
0
]
},
"_meta": {
"title": "Preview Mask"
}
},
"402": {
"class_type": "MaskPreview",
"inputs": {
"mask": [
"394",
0
]
},
"_meta": {
"title": "Preview Mask"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)