物体検出とは?
物体検出(Object Detection)は、画像の中から「何が写っているか(クラス)」「どこにあるか(位置)」を見つけるタスクです。
一般的には、物体ごとにバウンディングボックス(長方形)とラベルを出力します。
ComfyUI では、もっぱらマスク生成の入口として使います。 画像の中から犬を検出して消したり、顔だけ検出してリファインしたり… とにかく出番が多い技術ですね。
代表的な手法
本来の物体検出の世界ではいろいろな系統がありますが、ComfyUI 目線だと以下が代表的です。
YOLO 系
特定の物体(車、人、犬など)を検出するための、伝統的かつ強力なモデル群です。

{
"id": "ffcc6c64-e535-4685-ab04-be903b4cdf3c",
"revision": 0,
"last_node_id": 7,
"last_link_id": 5,
"nodes": [
{
"id": 3,
"type": "UltralyticsDetectorProvider",
"pos": [
-131.74129771892854,
275.10463657117793
],
"size": [
225.47324988344883,
100.20074983277442
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "BBOX_DETECTOR",
"type": "BBOX_DETECTOR",
"links": [
2
]
},
{
"name": "SEGM_DETECTOR",
"type": "SEGM_DETECTOR",
"links": null
}
],
"properties": {
"cnr_id": "comfyui-impact-subpack",
"ver": "1.3.5",
"Node name for S&R": "UltralyticsDetectorProvider"
},
"widgets_values": [
"segm/person_yolov8m-seg.pt"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 2,
"type": "LoadImage",
"pos": [
-192.01296976493634,
433.54398787774375
],
"size": [
288.15658006702404,
326
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
1
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"1f421a11eb7f46ffcf970787036c5cc1.jpg",
"image"
]
},
{
"id": 1,
"type": "ImpactSimpleDetectorSEGS",
"pos": [
137.03559995799336,
275.10463657117793
],
"size": [
244.07421875,
310
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "bbox_detector",
"type": "BBOX_DETECTOR",
"link": 2
},
{
"name": "image",
"type": "IMAGE",
"link": 1
},
{
"name": "sam_model_opt",
"shape": 7,
"type": "SAM_MODEL",
"link": null
},
{
"name": "segm_detector_opt",
"shape": 7,
"type": "SEGM_DETECTOR",
"link": null
}
],
"outputs": [
{
"name": "SEGS",
"type": "SEGS",
"links": [
5
]
}
],
"properties": {
"cnr_id": "comfyui-impact-pack",
"ver": "61bd8397a18e7e7668e6a24e95168967768c2bed",
"Node name for S&R": "ImpactSimpleDetectorSEGS"
},
"widgets_values": [
0.5,
0,
3,
10,
0.5,
0,
0,
0.7,
0
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 7,
"type": "SEGSPreview",
"pos": [
416.62826858269676,
275.10463657117793
],
"size": [
332.13668518001396,
314
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "segs",
"type": "SEGS",
"link": 5
},
{
"name": "fallback_image_opt",
"shape": 7,
"type": "IMAGE",
"link": null
}
],
"outputs": [
{
"name": "IMAGE",
"shape": 6,
"type": "IMAGE",
"links": null
}
],
"properties": {
"cnr_id": "comfyui-impact-pack",
"ver": "61bd8397a18e7e7668e6a24e95168967768c2bed",
"Node name for S&R": "SEGSPreview"
},
"widgets_values": [
true,
0.1
]
}
],
"links": [
[
1,
2,
0,
1,
1,
"IMAGE"
],
[
2,
3,
0,
1,
0,
"BBOX_DETECTOR"
],
[
5,
1,
0,
7,
0,
"SEGS"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1.01525597994771,
"offset": [
522.496714378834,
-22.433780096160543
]
},
"frontendVersion": "1.34.3",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- 圧倒的に高速で、リアルタイム処理に使われるほど軽いです。
- 「人」「車」など、あらかじめ決めたクラス集合に対して学習しておき、その中から検出するです。
- モデルが無い場合は、自分で学習する必要があります。
DETR 系
CNN ではなく Transformer を使った検出モデルです。
ComfyUI で直接扱う機会はほとんどありませんが、物体検出の文脈で名前だけ見かけることはあると思います。
テキストでの物体検出
上の検出器は、あらかじめ決めたクラスしか検出できないため、人や車といった代表的なもの以外を検出しようとすると途端に使いづらくなります。
ComfyUI 的に重要なのは、テキストで物体を指定できるタイプ の検出です。
Grounding DINO
- 画像エンコーダ+テキストエンコーダで画像とテキストの特徴を対応付けるモデルです。
- 「red car」「traffic light」など、プロンプト(テキスト)で指示したものを何でも検出できます。
Florence-2

{
"id": "b3c4cb62-a4e3-43d1-8cab-97b76da640ea",
"revision": 0,
"last_node_id": 5,
"last_link_id": 4,
"nodes": [
{
"id": 2,
"type": "DownloadAndLoadFlorence2Model",
"pos": [
-172.8312043876651,
730.6295594867262
],
"size": [
258.6021484375,
139.84973267580756
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [
{
"name": "lora",
"shape": 7,
"type": "PEFTLORA",
"link": null
}
],
"outputs": [
{
"name": "florence2_model",
"type": "FL2MODEL",
"links": [
1
]
}
],
"properties": {
"cnr_id": "comfyui-florence2",
"ver": "00b63382966a444a9fefacb65b8deb188d12a458",
"Node name for S&R": "DownloadAndLoadFlorence2Model"
},
"widgets_values": [
"microsoft/Florence-2-base-ft",
"fp16",
"sdpa",
true
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 1,
"type": "Florence2Run",
"pos": [
162.05970658979237,
378.9941029603949
],
"size": [
400,
364
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 3
},
{
"name": "florence2_model",
"type": "FL2MODEL",
"link": 1
}
],
"outputs": [
{
"name": "image",
"type": "IMAGE",
"links": [
4
]
},
{
"name": "mask",
"type": "MASK",
"links": null
},
{
"name": "caption",
"type": "STRING",
"links": null
},
{
"name": "data",
"type": "JSON",
"links": null
}
],
"properties": {
"cnr_id": "comfyui-florence2",
"ver": "00b63382966a444a9fefacb65b8deb188d12a458",
"Node name for S&R": "Florence2Run"
},
"widgets_values": [
"coffee",
"caption_to_phrase_grounding",
true,
false,
1024,
3,
true,
"",
1234,
"fixed"
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 4,
"type": "LoadImage",
"pos": [
-199.4499034371617,
176.5861666100186
],
"size": [
283.34567757826187,
480.9894372866636
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
3
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"download (1).jpg",
"image"
]
},
{
"id": 5,
"type": "PreviewImage",
"pos": [
620.7629211596435,
281.30273069624826
],
"size": [
397.0780228385779,
544.4469000769693
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 4
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
1,
2,
0,
1,
1,
"FL2MODEL"
],
[
3,
4,
0,
1,
0,
"IMAGE"
],
[
4,
1,
0,
5,
0,
"IMAGE"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 1.015255979947711,
"offset": [
299.4499034371617,
-76.58616661001861
]
},
"frontendVersion": "1.34.3",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- 画像を見てキャプション生成・物体検出・セグメンテーションなど、1 つのモデルで何役もこなす汎用的な VLM です。
- LLM に近い構造を持つため、Grounding DINO よりも複雑な文章で指示できるのが強みです。
ComfyUI での使いどころ(マスク生成として)
ComfyUIでは、物体検出はほぼ マスク生成の入口 として使います。
とはいえ、物体検出モデルから出力されるのは BBOX(長方形)だけです。
これだけでも inpainting によるオブジェクト除去などには役立ちますが、例えば人を検出したとき、そのほとんどの領域が背景で、マスクとして使うには少し無駄が多いですね。
そのため、これらの検出結果は単体で使うのではなく、後段のマッティングやセグメンテーションと併用することが多いです。次はそれらを見ていきましょう。