Link to this section시맨틱 세그멘테이션#
시맨틱 세그멘테이션은 이미지의 모든 픽셀에 클래스 라벨을 할당하여 전체 장면을 포괄하는 밀도 높은 클래스 맵을 생성합니다. 개별 객체를 분리하는 인스턴스 세그멘테이션과 달리, 시맨틱 세그멘테이션은 존재하는 객체의 수와 관계없이 동일한 클래스에 속한 모든 픽셀을 하나로 그룹화합니다.
시맨틱 세그멘테이션 모델의 출력은 각 픽셀 값이 예측된 클래스 ID에 대응하는 단일 높이x너비 클래스 맵입니다. 이로 인해 시맨틱 세그멘테이션은 자율 주행, 의료 영상 처리, 토지 피복 매핑과 같은 장면 해석 작업에 이상적입니다.
Use task=semantic or the yolo semantic CLI task for semantic segmentation. YOLO26 semantic segmentation model files use the -sem suffix, such as yolo26n-sem.pt.
Link to this section모델#
Cityscapes 데이터셋으로 사전 학습된 YOLO26 시맨틱 세그멘테이션 모델은 아래와 같습니다.
모델은 처음 사용할 때 최신 Ultralytics 릴리스에서 자동으로 다운로드됩니다.
| 모델 | 크기 (픽셀) | mIoUval | 속도 RTX3090 PyTorch (ms) | 파라미터 (M) | FLOPs (B) |
|---|---|---|---|---|---|
| YOLO26n-sem | 1024 × 2048 | 78.3 | 4.4 ± 0.0 | 1.6 | 22.7 |
| YOLO26s-sem | 1024 × 2048 | 80.8 | 8.4 ± 0.0 | 6.5 | 88.8 |
| YOLO26m-sem | 1024 × 2048 | 82.0 | 19.9 ± 0.1 | 14.3 | 304.5 |
| YOLO26l-sem | 1024 × 2048 | 82.9 | 26.5 ± 0.1 | 17.9 | 384.7 |
| YOLO26x-sem | 1024 × 2048 | 83.6 | 48.9 ± 0.2 | 40.2 | 861.7 |
- mIoUval 값은 Cityscapes 검증 세트에서 단일 모델 단일 스케일로 측정한 결과입니다.
yolo semantic val data=cityscapes.yaml device=0 imgsz=2048명령으로 재현하십시오. - 속도 메트릭은 RTX3090 인스턴스를 사용하여 Cityscapes 검증 이미지에서 평균을 낸 결과입니다.
yolo semantic val data=cityscapes.yaml batch=1 device=0|cpu imgsz=2048명령으로 재현하십시오. - 파라미터 및 FLOPs 값은 Conv 및 BatchNorm 레이어를 병합하는
model.fuse()후의 융합된 모델에 대한 것입니다. 사전 학습된 체크포인트는 전체 학습 아키텍처를 유지하므로 더 높은 수치를 보일 수 있습니다.
Link to this section학습 (Train)#
이미지 크기 1024에서 100 에폭 동안 Cityscapes8 데이터셋으로 YOLO26n-sem을 학습하십시오. 사용 가능한 전체 인자 목록은 구성 페이지를 참조하십시오.
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n-sem.yaml") # build a new model from YAML
model = YOLO("yolo26n-sem.pt") # load a pretrained model (recommended for training)
model = YOLO("yolo26n-sem.yaml").load("yolo26n-sem.pt") # build from YAML and transfer weights
# Train the model
results = model.train(data="cityscapes8.yaml", epochs=100, imgsz=1024)전체 train 모드 상세 정보는 학습 페이지를 참조하십시오.
Link to this section데이터셋 형식#
시맨틱 세그멘테이션 데이터셋은 일반적으로 PNG 형식의 단일 채널 마스크 이미지를 사용하며, 각 픽셀 값은 클래스 ID를 나타냅니다. 값이 255인 픽셀은 "무시" 대상으로 처리되어 손실 계산에서 제외됩니다. 데이터셋 YAML 파일에는 이미지 경로와 해당 마스크 디렉토리가 명시되어야 합니다. 형식에 대한 자세한 내용은 시맨틱 세그멘테이션 데이터셋 가이드를 참조하십시오. 지원되는 데이터셋으로는 Cityscapes와 ADE20K가 있습니다.
Link to this section검증 (Val)#
시맨틱 세그멘테이션 데이터셋에서 학습된 YOLO26n-sem 모델의 정확도를 검증하십시오. 검증 시 의도한 데이터셋 YAML이 사용되도록 data 인자를 명시적으로 전달하십시오.
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n-sem.pt") # load an official model
model = YOLO("path/to/best.pt") # load a custom model
# Validate the model
metrics = model.val(data="cityscapes.yaml")
metrics.miou # mean Intersection over Union
metrics.pixel_accuracy # overall pixel accuracyLink to this section예측 (Predict)#
학습된 YOLO26n-sem 모델을 사용하여 이미지에 대한 예측을 수행하십시오.
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n-sem.pt") # load an official model
model = YOLO("path/to/best.pt") # load a custom model
# Predict with the model
results = model("https://ultralytics.com/images/bus.jpg") # predict on an image
# Access the results
for result in results:
semantic_mask = result.semantic_mask.data # class map, shape (H,W), integer dtype selected by class count전체 predict 모드 상세 정보는 예측 페이지를 참조하십시오.
Link to this section결과 출력#
YOLO 시맨틱 세그멘테이션은 이미지당 하나의 Results 객체를 반환합니다. 각 결과는 개체 마스크 목록 대신 전체 이미지에 대한 밀도 높은 클래스 맵을 하나 저장합니다. 동일한 클래스로 예측된 픽셀은 서로 다른 개체에 속하더라도 동일한 클래스 ID를 공유합니다.
| 속성 | 유형 | 형상 | 설명 |
|---|---|---|---|
result.semantic_mask | SemanticMask | (H,W) | 밀도 높은 클래스 맵. |
result.semantic_mask.data | torch.uint8torch.int16torch.int32 | (H,W) | 클래스 ID; 클래스 수에 따라 dtype이 선택됩니다. |
result.masks | - | - | 인스턴스 마스크 없음. |
result.boxes | - | - | 인스턴스 박스/신뢰도 없음. |
result.masks.xy | - | - | 기본 폴리곤 없음. |
모든 태스크에 걸친 태스크별 Results 필드에 대해서는 태스크별 예측 결과 섹션을 참조하십시오.
Link to this section인스턴스 세그멘테이션 대 시맨틱 세그멘테이션#
| 측면 | 인스턴스 세그멘테이션 (task="segment") | 시맨틱 세그멘테이션 (task="semantic") |
|---|---|---|
| 예측 목표 | 감지된 각 객체를 개별적으로 세그멘테이션 | 모든 픽셀에 클래스 ID 할당 |
| 출력 필드 | result.masks | result.semantic_mask |
| 메인 데이터 | result.masks.data | result.semantic_mask.data |
| 형상 | (N,H,W) | (H,W) |
| 픽셀 값 | 이진 마스크 값: 0 또는 1 | 클래스 ID: 0, 1, 2, ... |
| Dtype | torch.uint8 | torch.uint8torch.int16torch.int32 |
| 동일 클래스 객체 | 개별 인스턴스로 유지 | 동일한 클래스 영역으로 병합 |
| 폴리곤 | 예, result.masks.xy 및 result.masks.xyn을 통해 가능 | 기본적으로 폴리곤 출력 없음 |
| 박스 및 신뢰도 | 예, result.boxes를 통해 가능 | 인스턴스별 박스 또는 신뢰도 점수 없음 |
| 일반적인 용도 | 계수, 추적, 자르기, 객체 수준 측정 | 밀도 높은 장면 레이블링, 주행 가능 영역, 토지 피복, 의료 영역 |
Link to this section내보내기 (Export)#
YOLO26n-sem 모델을 ONNX, CoreML 등 다른 형식으로 내보내기.
from ultralytics import YOLO
# Load a model
model = YOLO("yolo26n-sem.pt") # load an official model
model = YOLO("path/to/best.pt") # load a custom model
# Export the model
model.export(format="onnx")사용 가능한 YOLO26 의미론적 분할(semantic segmentation) 내보내기 형식은 아래 표와 같습니다. format 인수를 사용하여 모든 형식으로 내보낼 수 있습니다(예: format='onnx' 또는 format='engine'). 내보낸 모델에 대해 즉시 예측하거나 검증할 수 있습니다(예: yolo predict model=yolo26n-sem.onnx). 내보내기가 완료되면 모델에 대한 사용 예제가 표시됩니다.
| 형식 | format 인수 | 모델 | 메타데이터 | 인수 |
|---|---|---|---|---|
| PyTorch | - | yolo26n-sem.pt | ✅ | - |
| TorchScript | torchscript | yolo26n-sem.torchscript | ✅ | imgsz, half, dynamic, optimize, nms, batch, device |
| ONNX | onnx | yolo26n-sem.onnx | ✅ | imgsz, half, int8, dynamic, simplify, opset, nms, batch, data, fraction, device |
| OpenVINO | openvino | yolo26n-sem_openvino_model/ | ✅ | imgsz, half, dynamic, int8, nms, batch, data, fraction, device |
| TensorRT | engine | yolo26n-sem.engine | ✅ | imgsz, half, dynamic, simplify, workspace, int8, nms, batch, data, fraction, device |
| CoreML | coreml | yolo26n-sem.mlpackage | ✅ | imgsz, dynamic, half, int8, nms, batch, device |
| TF SavedModel | saved_model | yolo26n-sem_saved_model/ | ✅ | imgsz, keras, int8, nms, batch, data, fraction, device |
| TF GraphDef | pb | yolo26n-sem.pb | ❌ | imgsz, batch, device |
| TF Lite | tflite | yolo26n-sem.tflite | ✅ | imgsz, half, int8, nms, batch, data, fraction, device |
| TF Edge TPU | edgetpu | yolo26n-sem_edgetpu.tflite | ✅ | imgsz, int8, data, fraction, device |
| TF.js | tfjs | yolo26n-sem_web_model/ | ✅ | imgsz, half, int8, nms, batch, data, fraction, device |
| PaddlePaddle | paddle | yolo26n-sem_paddle_model/ | ✅ | imgsz, batch, device |
| MNN | mnn | yolo26n-sem.mnn | ✅ | imgsz, batch, int8, half, device |
| NCNN | ncnn | yolo26n-sem_ncnn_model/ | ✅ | imgsz, half, batch, device |
| IMX500 | imx | yolo26n-sem_imx_model/ | ✅ | imgsz, int8, data, fraction, nms, device |
| RKNN | rknn | yolo26n-sem_rknn_model/ | ✅ | imgsz, batch, name, int8, data, fraction, device |
| ExecuTorch | executorch | yolo26n-sem_executorch_model/ | ✅ | imgsz, batch, device |
| Axelera | axelera | yolo26n-sem_axelera_model/ | ✅ | imgsz, batch, int8, data, fraction, device |
| DEEPX | deepx | yolo26n-sem_deepx_model/ | ✅ | imgsz, int8, data, optimize, device |
| Qualcomm QNN | qnn | yolo26n-sem_qnn_model/ | ✅ | imgsz, batch, name, int8, data, fraction, device |
전체 export 세부 정보는 Export 페이지를 참조하십시오.
Link to this sectionFAQ#
Link to this section사용자 정의 데이터셋으로 YOLO26 의미론적 분할 모델을 학습하려면 어떻게 해야 합니까?#
사용자 정의 데이터셋으로 YOLO26 의미론적 분할 모델을 학습하려면 각 픽셀 값이 클래스 ID(0, 1, 2, ...)를 나타내는 PNG 마스크 이미지를 준비해야 하며, 값이 255인 픽셀은 학습 중에 무시됩니다. 이미지와 마스크 디렉토리를 가리키는 데이터셋 YAML 파일을 생성한 후 모델을 학습하십시오:
from ultralytics import YOLO
# Load a pretrained YOLO26 semantic segmentation model
model = YOLO("yolo26n-sem.pt")
# Train the model
results = model.train(data="path/to/your_dataset.yaml", epochs=100, imgsz=512)사용 가능한 추가 인수는 Configuration 페이지를 확인하십시오.
Link to this section인스턴스 분할(instance segmentation)과 의미론적 분할(semantic segmentation)의 차이점은 무엇입니까?#
인스턴스 분할과 의미론적 분할은 모두 픽셀 수준의 작업이지만 중요한 차이점이 있습니다:
- **의미론적 분할**은 모든 픽셀에 클래스 레이블을 할당하지만 동일한 클래스의 개별 객체를 구분하지 않습니다. 예를 들어, 장면의 모든 자동차는 동일한 클래스 레이블을 공유합니다.
- **인스턴스 분할**은 각 개별 객체를 별도로 식별하며, 동일한 클래스에 속하더라도 각 객체에 대해 고유한 마스크를 생성합니다.
의미론적 분할은 자율 주행 및 토지 피복 매핑과 같은 장면 이해 작업에 가장 적합하며, 인스턴스 분할은 개별 객체를 계산하거나 추적할 때 선호됩니다.
Link to this section인스턴스 분할 데이터를 사용하여 의미론적 분할을 학습할 수 있습니까?#
네, 가능합니다. 데이터셋이 Ultralytics YOLO 다각형 레이블(이미지당 하나의 .txt 파일)을 사용하는 경우 데이터셋 YAML에서 masks_dir을 생략하면 로더가 즉석에서 다각형을 이미지당 의미론적 마스크로 변환합니다. 다중 클래스 데이터셋(N > 1)의 경우 추가적인 background 클래스가 names에 자동으로 추가됩니다. 단일 클래스 데이터셋(N == 1)의 경우 학습은 1개 클래스로 유지되며, 선언된 클래스는 마스크에서 1이 되고 덮이지 않은 픽셀은 0이 됩니다. 자세한 내용은 Semantic Segmentation Dataset Guide를 참조하십시오.
Link to this section의미론적 분할을 위해 어떤 데이터셋이 지원됩니까?#
Ultralytics YOLO26은 여러 의미론적 분할 데이터셋에 대한 기본 구성을 제공합니다:
- Cityscapes: 자율 주행 연구에 널리 사용되는 19개 클래스의 도시 거리 장면입니다.
- ADE20K: 150개 클래스를 포함하는 대규모 장면 파싱 데이터셋입니다.
픽셀 값이 클래스 ID에 해당하는 PNG 마스크 주석을 제공하는 모든 사용자 정의 데이터셋을 사용할 수도 있습니다.
Link to this section사전 학습된 YOLO26 의미론적 분할 모델을 검증하려면 어떻게 해야 합니까?#
평가에 사용된 데이터셋 YAML을 사용하여 사전 학습된 YOLO26 의미론적 분할 모델을 검증하십시오:
from ultralytics import YOLO
# Load a pretrained model
model = YOLO("yolo26n-sem.pt")
# Validate the model
metrics = model.val(data="cityscapes.yaml")
print("Mean IoU:", metrics.miou)
print("Pixel Accuracy:", metrics.pixel_accuracy)이 단계를 통해 의미론적 분할 성능을 평가하는 표준 척도인 mIoU(mean Intersection over Union) 및 픽셀 정확도와 같은 검증 지표를 얻을 수 있습니다.
Link to this sectionYOLO26 의미론적 분할 모델을 ONNX 형식으로 내보내려면 어떻게 해야 합니까?#
Python 또는 CLI 명령을 사용하여 YOLO26 의미론적 분할 모델을 ONNX 형식으로 내보내십시오:
from ultralytics import YOLO
# Load a pretrained model
model = YOLO("yolo26n-sem.pt")
# Export the model to ONNX format
model.export(format="onnx")다양한 형식으로 내보내는 방법에 대한 자세한 내용은 Export 페이지를 참조하십시오.