从oss加载mask(使用服务获取ak信息)
Stored your masks as image channels? This pulls them back as a real MASK
- MASK
This is the niche-est node in the nxt5656/image2oss pack, and I mean that as a compliment. Most people store masks as separate files, or tuck them into the alpha channel and let a loader turn that into a mask. This one assumes you did something different: you packed a mask into the red, green, or blue channel of an image, saved it to an Alibaba OSS bucket, and now need it back as a real MASK tensor on the canvas.
When does anyone do that? When a pipeline writes masks programmatically - say, a segmentation script that colors regions and dumps the result to storage. One image file, three reusable channels. It also keeps mask and source together in the bucket instead of as a loose file pair. If that's your world, this node is the cleanest way to read the channel you care about.
How it works
Same credential flow as the pack's other STS nodes: it GETs your sts_service_url, expects {"success": true, "data": {"accessKeyId", "accessKeySecret", "securityToken"}}, and uses those temporary credentials with the oss2 SDK to fetch the object. The image is converted to RGBA, and the channel you picked is pulled out, normalized to a 0–1 float tensor, and returned as MASK.
One semantic detail worth knowing: alpha is inverted (1 - alpha), matching ComfyUI's convention where the mask marks the region to fill. Red, green, and blue come through as-is - white (1.0) is "masked". So if you baked a mask into the red channel, what you see is what you get.
The inputs
Four are the same as every node in this pack: filename (full object key in the bucket), sts_service_url (your credentials endpoint), bucket_name, and endpoint (the 44-region dropdown - hand-typed endpoints get rejected by validation).
Then there's the one that makes this node interesting:
channel-alpha,red,green, orblue. Pick which stored channel becomes the mask. This is the field you'll actually fiddle with, and it's the whole reason the node exists.
The single output is MASK, which feeds anything that wants a mask - Set Latent Noise Mask, inpainting conditioning, mask compositing, a detailer's mask input.
Install
ComfyUI Manager (search "image2oss"), comfy node registry-install image2oss, or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/nxt5656/image2oss
Restart, and oss2 gets pulled in via the pack's requirements. No models, no weights - nothing to download beyond the plugin.
Where people get burned
- It only exists on the STS path. There's no direct-AK version of this loader. If you'd rather not run a credentials service, you're pairing this with the pack's STS setup or you're out of luck.
- Channel confusion. Forgetting that alpha comes back inverted while RGB doesn't will give you an inverted mask once - check which convention your mask was stored under before wiring it into an inpaint pass.
- Missing key =
NoSuchKey. The usual: a typo in the object key or a bucket in the wrong region surfaces as a missing-object error, so double the full path before blaming the node.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| filename | STRING | tmp-comfyui/filename.jpeg | — |
| sts_service_url | STRING | https://demo.cn/sts_service | — |
| bucket_name | STRING | bucket_name | — |
| endpoint | COMBO | oss-cn-hangzhou.aliyuncs.com | 44 options: oss-cn-hangzhou.aliyuncs.com, oss-cn-shanghai.aliyuncs.com, oss-cn-qingdao.aliyuncs.com, oss-cn-beijing.aliyuncs.com, oss-cn-shenzhen.aliyuncs.com, oss-cn-heyuan.aliyuncs.com, +38 |
| channel | COMBO | 4 options: alpha, red, green, blue |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |