工作流 /
图像工具 /
去背景: BiRefNet

去背景: BiRefNet
Remove Background: BiRefNet
上传一张带有任意背景的图片。生成一个去除背景的版本以及一个精确的分割遮罩。
图像工具
5 个节点 1 个输入 111 次使用 ComfyUI ≥ 0.21.0 ComfyUI 13 KB
需要的权重
这个工作流引用了 1 个权重文件,其中 1 个能在本站模型库里找到。
birefnet.safetensors
在模型库查看
节点构成
LoadImage
× 1
PreviewImage
× 1
5b40ca21-ba1a-41d5-b403-4d2d7acdc195
× 1
MaskPreview
× 1
MarkdownNote
× 1
官方标注的模型
BiRefNet
工作流 JSON
和上面「下载工作流 JSON」是同一份文件。
1{
2 "id": "64f1123f-2d68-488d-a464-5151dea4c189",
3 "revision": 0,
4 "last_node_id": 21,
5 "last_link_id": 16,
6 "nodes": [
7 {
8 "id": 17,
9 "type": "LoadImage",
10 "pos": [
11 -6750.728970009313,
12 1940.0588244182456
13 ],
14 "size": [
15 290,
16 340
17 ],
18 "flags": [],
19 "order": 0,
20 "mode": 0,
21 "inputs": [],
22 "outputs": [
23 {
24 "name": "IMAGE",
25 "type": "IMAGE",
26 "links": [
27 15
28 ]
29 },
30 {
31 "name": "MASK",
32 "type": "MASK",
33 "links": null
34 }
35 ],
36 "properties": {
37 "Node name for S&R": "LoadImage",
38 "enableTabs": false,
39 "tabWidth": 65,
40 "tabXOffset": 10,
41 "hasSecondTab": false,
42 "secondTabText": "Send Back",
43 "secondTabOffset": 80,
44 "secondTabWidth": 65,
45 "cnr_id": "comfy-core",
46 "ver": "0.19.3"
47 },
48 "widgets_values": [
49 "the_lily_veil.png",
50 "image"
51 ]
52 },
53 {
54 "id": 18,
55 "type": "PreviewImage",
56 "pos": [
57 -6004.985527612185,
58 1940.1805319999396
59 ],
60 "size": [
61 225,
62 280
63 ],
64 "flags": [],
65 "order": 3,
66 "mode": 0,
67 "inputs": [
68 {
69 "name": "images",
70 "type": "IMAGE",
71 "link": 14
72 }
73 ],
74 "outputs": [],
75 "properties": {
76 "Node name for S&R": "PreviewImage"
77 },
78 "widgets_values": []
79 },
80 {
81 "id": 19,
82 "type": "5b40ca21-ba1a-41d5-b403-4d2d7acdc195",
83 "pos": [
84 -6411.330578108367,
85 1940.2638932730042
86 ],
87 "size": [
88 349.609375,
89 145.9375
90 ],
91 "flags": [],
92 "order": 2,
93 "mode": 0,
94 "inputs": [
95 {
96 "name": "image",
97 "type": "IMAGE",
98 "link": 15
99 }
100 ],
101 "outputs": [
102 {
103 "name": "IMAGE",
104 "type": "IMAGE",
105 "links": [
106 14
107 ]
108 },
109 {
110 "name": "mask",
111 "type": "MASK",
112 "links": [
113 16
114 ]
115 }
116 ],
117 "properties": {
118 "proxyWidgets": [
119 [
120 "14",
121 "bg_removal_name"
122 ]
123 ]
124 },
125 "widgets_values": []
126 },
127 {
128 "id": 20,
129 "type": "MaskPreview",
130 "pos": [
131 -5724.493992497488,
132 1941.0306597152894
133 ],
134 "size": [
135 225,
136 280
137 ],
138 "flags": [],
139 "order": 4,
140 "mode": 0,
141 "inputs": [
142 {
143 "name": "mask",
144 "type": "MASK",
145 "link": 16
146 }
147 ],
148 "outputs": [],
149 "properties": {
150 "Node name for S&R": "MaskPreview"
151 },
152 "widgets_values": []
153 },
154 {
155 "id": 21,
156 "type": "MarkdownNote",
157 "pos": [
158 -7286.205481862371,
159 1937.5776519327824
160 ],
161 "size": [
162 497.234375,
163 630.953125
164 ],
165 "flags": [],
166 "order": 1,
167 "mode": 0,
168 "inputs": [],
169 "outputs": [],
170 "title": "Model Link",
171 "properties": [],
172 "widgets_values": [
173 "## Model Link\n\n- [Hugging Face:Comfy-Org/BiRefNet](https://huggingface.co/Comfy-Org/BiRefNet)\n\n**ModelScope mirrors** (alternative repo location)\n\n- [ModelScope:Comfy-Org/BiRefNet](https://modelscope.cn/models/Comfy-Org/BiRefNet)\n\n**background_removal**\n\n- [birefnet.safetensors](https://huggingface.co/Comfy-Org/BiRefNet/resolve/main/background_removal/birefnet.safetensors) (423.9 MB)\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ └── 📂 background_removal/\n│ └── birefnet.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n"
174 ],
175 "color": "#222",
176 "bgcolor": "#000"
177 }
178 ],
179 "links": [
180 [
181 14,
182 19,
183 0,
184 18,
185 0,
186 "IMAGE"
187 ],
188 [
189 15,
190 17,
191 0,
192 19,
193 0,
194 "IMAGE"
195 ],
196 [
197 16,
198 19,
199 1,
200 20,
201 0,
202 "MASK"
203 ]
204 ],
205 "groups": [],
206 "definitions": {
207 "subgraphs": [
208 {
209 "id": "5b40ca21-ba1a-41d5-b403-4d2d7acdc195",
210 "version": 1,
211 "state": {
212 "lastGroupId": 0,
213 "lastNodeId": 21,
214 "lastLinkId": 16,
215 "lastRerouteId": 0
216 },
217 "revision": 0,
218 "config": [],
219 "name": "Remove Background (BiRefNet)",
220 "inputNode": {
221 "id": -10,
222 "bounding": [
223 -6728.534070722246,
224 1475.2619799128663,
225 150.9140625,
226 88
227 ]
228 },
229 "outputNode": {
230 "id": -20,
231 "bounding": [
232 -6169.049695722246,
233 1475.2619799128663,
234 128,
235 88
236 ]
237 },
238 "inputs": [
239 {
240 "id": "7bc321cd-df31-4c39-aaf7-7f0d01326189",
241 "name": "image",
242 "type": "IMAGE",
243 "linkIds": [
244 5,
245 7
246 ],
247 "localized_name": "image",
248 "pos": [
249 -6601.620008222246,
250 1499.2619799128663
251 ]
252 },
253 {
254 "id": "e89d2cd8-daa3-4e29-8a69-851db85072cb",
255 "name": "bg_removal_name",
256 "type": "COMBO",
257 "linkIds": [
258 12
259 ],
260 "pos": [
261 -6601.620008222246,
262 1519.2619799128663
263 ]
264 }
265 ],
266 "outputs": [
267 {
268 "id": "16e7863c-4c38-46c2-aa74-e82991fbfe8d",
269 "name": "IMAGE",
270 "type": "IMAGE",
271 "linkIds": [
272 8
273 ],
274 "localized_name": "IMAGE",
275 "pos": [
276 -6145.049695722246,
277 1499.2619799128663
278 ]
279 },
280 {
281 "id": "f7240c19-5b80-406e-a8e2-9b12440ee2d6",
282 "name": "mask",
283 "type": "MASK",
284 "linkIds": [
285 11
286 ],
287 "pos": [
288 -6145.049695722246,
289 1519.2619799128663
290 ]
291 }
292 ],
293 "widgets": [],
294 "nodes": [
295 {
296 "id": 13,
297 "type": "RemoveBackground",
298 "pos": [
299 -6536.764823982709,
300 1444.9963409012412
301 ],
302 "size": [
303 302.25,
304 72
305 ],
306 "flags": [],
307 "order": 0,
308 "mode": 0,
309 "inputs": [
310 {
311 "localized_name": "image",
312 "name": "image",
313 "type": "IMAGE",
314 "link": 5
315 },
316 {
317 "localized_name": "bg_removal_model",
318 "name": "bg_removal_model",
319 "type": "BACKGROUND_REMOVAL",
320 "link": 3
321 }
322 ],
323 "outputs": [
324 {
325 "localized_name": "mask",
326 "name": "mask",
327 "type": "MASK",
328 "links": [
329 4,
330 11
331 ]
332 }
333 ],
334 "properties": {
335 "Node name for S&R": "RemoveBackground"
336 },
337 "widgets_values": []
338 },
339 {
340 "id": 14,
341 "type": "LoadBackgroundRemovalModel",
342 "pos": [
343 -6540.534070722246,
344 1302.223464635445
345 ],
346 "size": [
347 311.484375,
348 85.515625
349 ],
350 "flags": [],
351 "order": 1,
352 "mode": 0,
353 "inputs": [
354 {
355 "localized_name": "bg_removal_name",
356 "name": "bg_removal_name",
357 "type": "COMBO",
358 "widget": {
359 "name": "bg_removal_name"
360 },
361 "link": 12
362 }
363 ],
364 "outputs": [
365 {
366 "localized_name": "bg_model",
367 "name": "bg_model",
368 "type": "BACKGROUND_REMOVAL",
369 "links": [
370 3
371 ]
372 }
373 ],
374 "properties": {
375 "Node name for S&R": "LoadBackgroundRemovalModel",
376 "models": [
377 {
378 "name": "birefnet.safetensors",
379 "url": "https://huggingface.co/Comfy-Org/BiRefNet/resolve/main/background_removal/birefnet.safetensors",
380 "directory": "background_removal"
381 }
382 ]
383 },
384 "widgets_values": [
385 "birefnet.safetensors"
386 ]
387 },
388 {
389 "id": 15,
390 "type": "InvertMask",
391 "pos": [
392 -6532.446160529669,
393 1571.1111286839914
394 ],
395 "size": [
396 285.984375,
397 48
398 ],
399 "flags": [],
400 "order": 2,
401 "mode": 0,
402 "inputs": [
403 {
404 "localized_name": "mask",
405 "name": "mask",
406 "type": "MASK",
407 "link": 4
408 }
409 ],
410 "outputs": [
411 {
412 "localized_name": "MASK",
413 "name": "MASK",
414 "type": "MASK",
415 "links": [
416 6
417 ]
418 }
419 ],
420 "properties": {
421 "Node name for S&R": "InvertMask"
422 },
423 "widgets_values": []
424 },
425 {
426 "id": 16,
427 "type": "JoinImageWithAlpha",
428 "pos": [
429 -6527.4370171636665,
430 1674.3004951902876
431 ],
432 "size": [
433 284.96875,
434 72
435 ],
436 "flags": [],
437 "order": 3,
438 "mode": 0,
439 "inputs": [
440 {
441 "localized_name": "image",
442 "name": "image",
443 "type": "IMAGE",
444 "link": 7
445 },
446 {
447 "localized_name": "alpha",
448 "name": "alpha",
449 "type": "MASK",
450 "link": 6
451 }
452 ],
453 "outputs": [
454 {
455 "localized_name": "IMAGE",
456 "name": "IMAGE",
457 "type": "IMAGE",
458 "links": [
459 8
460 ]
461 }
462 ],
463 "properties": {
464 "Node name for S&R": "JoinImageWithAlpha"
465 },
466 "widgets_values": []
467 }
468 ],
469 "groups": [],
470 "links": [
471 {
472 "id": 3,
473 "origin_id": 14,
474 "origin_slot": 0,
475 "target_id": 13,
476 "target_slot": 1,
477 "type": "BACKGROUND_REMOVAL"
478 },
479 {
480 "id": 4,
481 "origin_id": 13,
482 "origin_slot": 0,
483 "target_id": 15,
484 "target_slot": 0,
485 "type": "MASK"
486 },
487 {
488 "id": 6,
489 "origin_id": 15,
490 "origin_slot": 0,
491 "target_id": 16,
492 "target_slot": 1,
493 "type": "MASK"
494 },
495 {
496 "id": 5,
497 "origin_id": -10,
498 "origin_slot": 0,
499 "target_id": 13,
500 "target_slot": 0,
501 "type": "IMAGE"
502 },
503 {
504 "id": 7,
505 "origin_id": -10,
506 "origin_slot": 0,
507 "target_id": 16,
508 "target_slot": 0,
509 "type": "IMAGE"
510 },
511 {
512 "id": 8,
513 "origin_id": 16,
514 "origin_slot": 0,
515 "target_id": -20,
516 "target_slot": 0,
517 "type": "IMAGE"
518 },
519 {
520 "id": 11,
521 "origin_id": 13,
522 "origin_slot": 0,
523 "target_id": -20,
524 "target_slot": 1,
525 "type": "MASK"
526 },
527 {
528 "id": 12,
529 "origin_id": -10,
530 "origin_slot": 1,
531 "target_id": 14,
532 "target_slot": 0,
533 "type": "COMBO"
534 }
535 ],
536 "extra": []
537 }
538 ]
539 },
540 "config": [],
541 "extra": {
542 "ds": {
543 "scale": 0.5221053074651809,
544 "offset": [
545 8056.8561790911435,
546 -1340.279714978918
547 ]
548 },
549 "frontendVersion": "1.43.17"
550 },
551 "version": 0.4
552}