Link to this section의미론적 분할 (Semantic Segmentation)#
의미론적 분할은 이미지의 모든 픽셀에 클래스 레이블을 할당하여 전체 장면을 아우르는 밀도 높은 클래스 맵을 생성합니다. 개별 객체를 분리하는 인스턴스 분할과 달리, 의미론적 분할은 존재하는 객체의 수와 관계없이 동일한 클래스의 모든 픽셀을 하나로 그룹화합니다.
의미론적 분할 모델의 출력은 각 픽셀 값이 예측된 클래스 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 - 속도(Speed) 지표는 RTX3090 인스턴스를 사용하여 Cityscapes 검증 이미지에서 평균을 낸 값입니다.
재현 방법:yolo semantic val data=cityscapes.yaml batch=1 device=0|cpu imgsz=2048 - Params 및 FLOPs 값은 Conv 및 BatchNorm 레이어를 병합하는
model.fuse()후의 융합된 모델에 대한 값입니다. 사전 훈련된 체크포인트는 전체 훈련 아키텍처를 유지하므로 더 높은 수치를 보일 수 있습니다.
Link to this section학습(Train)#
Cityscapes8 데이터셋에서 1024 이미지 크기로 100 에폭(epochs) 동안 YOLO26n-sem을 학습시킵니다. 사용 가능한 전체 인수 목록은 구성(Configuration) 페이지를 참조하십시오.
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 모드 상세 정보는 학습(Train) 페이지를 참조하십시오.
Link to this section데이터셋 형식#
의미론적 분할 데이터셋은 일반적으로 PNG 형식의 단일 채널 마스크 이미지를 사용하며, 각 픽셀 값은 클래스 ID를 나타냅니다. 값이 255인 픽셀은 "무시(ignore)"로 처리되어 손실 계산에서 제외됩니다. 데이터셋 YAML 파일에는 이미지 및 해당 마스크 디렉터리로의 경로가 명시되어야 합니다. 형식에 대한 자세한 내용은 의미론적 분할 데이터셋 가이드를 참조하십시오. 지원되는 데이터셋으로는 Cityscapes 및 ADE20K가 있습니다.
Link to this section검증(Val)#
학습된 YOLO26n-sem 모델의 정확도(accuracy)를 의미론적 분할 데이터셋에서 검증합니다. 의도한 데이터셋 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 모드 세부 정보는 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 | - | - | 기본 다각형(Polygon) 없음. |
모든 작업에 걸친 작업별 Results 필드는 작업별 예측 결과 섹션을 참조하십시오.
Link to this section인스턴스 분할 vs 의미론적 분할#
| 측면 | 인스턴스 분할 (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 |
| 동일 클래스 객체 | 개별 인스턴스로 유지됨 | 동일한 클래스 영역으로 병합됨 |
| 다각형(Polygons) | 예, result.masks.xy 및 result.masks.xyn을 통해 | 기본적으로 다각형 출력 없음 |
| 박스 및 신뢰도(Confidence) | 예, result.boxes를 통해 | 인스턴스별 박스 또는 신뢰도 점수 없음 |
| 일반적인 용도 | 계수, 추적, 자르기, 객체 수준 측정 | 밀도 높은 장면 라벨링, 주행 가능 영역, 토지 피복, 의료 영역 |
Link to this section내보내기(Export)#
YOLO26n-sem 모델을 ONNX, CoreML 등과 같은 다른 형식으로 내보냅니다(Export).
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 의미론적 분할 내보내기 형식은 아래 표와 같습니다. 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, half, 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.onnx | ✅ | imgsz, batch, name, int8, data, fraction, device |
전체 export 세부 사항은 Export 페이지에서 확인하십시오.
Link to this sectionFAQ#
Link to this section사용자 지정 데이터셋에서 YOLO26 의미론적 분할 모델을 어떻게 학습시키나요?#
사용자 지정 데이터셋에서 YOLO26 의미론적 분할 모델을 학습시키려면 각 픽셀 값이 클래스 ID(0, 1, 2, ...)를 나타내고 값이 255인 픽셀은 학습 중 무시되는 PNG 마스크 이미지를 준비해야 합니다. 이미지 및 마스크 디렉터리를 가리키는 데이터셋 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인스턴스 분할과 의미론적 분할의 차이점은 무엇인가요?#
인스턴스 분할과 의미론적 분할은 모두 픽셀 수준의 작업이지만 중요한 차이점이 있습니다:
- **의미론적 분할**은 모든 픽셀에 클래스 라벨을 할당하지만 동일 클래스의 개별 객체는 구분하지 않습니다. 예를 들어, 장면 속 모든 자동차는 동일한 클래스 라벨을 공유합니다.
- **인스턴스 분할**은 각 개별 객체를 별도로 식별하며, 동일한 클래스에 속하더라도 각 객체에 대해 별도의 마스크를 생성합니다.
의미론적 분할은 자율 주행이나 토지 피복 매핑과 같은 장면 이해 작업에 가장 적합하며, 인스턴스 분할은 개별 객체를 계수하거나 추적하는 것이 중요할 때 선호됩니다.
Link to this section인스턴스 분할 데이터를 사용하여 의미론적 분할을 학습시킬 수 있나요?#
네 가능합니다. 데이터셋이 Ultralytics YOLO 다각형 라벨(이미지당 .txt 하나)을 사용하는 경우, 데이터셋 YAML에서 masks_dir을 생략하십시오. 로더가 다각형을 이미지당 의미론적 마스크로 실시간 변환합니다. 다중 클래스 데이터셋(N > 1)의 경우, 추가적인 background 클래스가 names에 자동으로 추가됩니다. 단일 클래스 데이터셋(N == 1)의 경우 학습은 1개 클래스로 유지되며, 선언된 클래스는 마스크에서 1이 되고 덮이지 않은 픽셀은 0이 됩니다. 자세한 내용은 의미론적 분할 데이터셋 가이드를 참조하십시오.
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) 페이지를 참조하십시오.