Link to this sectionUltralytics 문서: YOLO26과 SAHI를 사용한 슬라이스 추론#
YOLO26과 SAHI(Slicing Aided Hyper Inference)를 사용하는 방법에 관한 Ultralytics 문서에 오신 것을 환영합니다. 이 종합 가이드는 YOLO26과 함께 SAHI를 구현하는 데 필요한 모든 필수 지식을 제공합니다. SAHI란 무엇인지, 대규모 애플리케이션에서 슬라이스 추론이 왜 중요한지, 그리고 향상된 object detection 성능을 위해 이러한 기능을 YOLO26과 통합하는 방법을 심층적으로 다룹니다.
Link to this sectionSAHI 소개#
SAHI(Slicing Aided Hyper Inference)는 대규모 및 고해상도 이미지에 대해 object detection 알고리즘을 최적화하기 위해 설계된 혁신적인 라이브러리입니다. 핵심 기능은 이미지를 관리하기 쉬운 슬라이스로 분할하고, 각 슬라이스에서 object detection을 실행한 다음, 결과를 다시 하나로 합치는 것입니다. SAHI는 YOLO 시리즈를 포함한 다양한 object detection 모델과 호환되므로, 계산 리소스의 최적화된 사용을 보장하면서 유연성을 제공합니다.
Watch: How to use SAHI with Ultralytics YOLO26 to Detect Small Objects | Slicing Aided Hyper Inference 🚀
Link to this sectionSAHI의 주요 기능#
- 원활한 통합: SAHI는 YOLO 모델과 손쉽게 통합되므로, 많은 코드 수정 없이 슬라이싱 및 탐지를 시작할 수 있습니다.
- 리소스 효율성: 대형 이미지를 더 작은 부분으로 나누어 메모리 사용을 최적화함으로써 리소스가 제한된 하드웨어에서도 고품질 탐지를 실행할 수 있습니다.
- 높은 Accuracy: SAHI는 스티칭 과정에서 중첩된 탐지 상자를 병합하기 위해 스마트 알고리즘을 사용하여 탐지 정확도를 유지합니다.
Link to this section슬라이스 추론이란 무엇인가?#
슬라이스 추론은 대형 또는 고해상도 이미지를 더 작은 세그먼트(슬라이스)로 세분화하고, 이 슬라이스들에 대해 object detection을 수행한 다음, 슬라이스들을 다시 컴파일하여 원본 이미지상의 객체 위치를 재구성하는 방식을 말합니다. 이 기술은 계산 리소스가 제한적이거나 메모리 문제를 일으킬 수 있는 초고해상도 이미지로 작업할 때 매우 유용합니다.
Link to this section슬라이스 추론의 이점#
-
계산 부담 감소: 더 작은 이미지 슬라이스는 처리 속도가 빠르고 메모리를 덜 소비하므로, 저사양 하드웨어에서도 더 원활하게 작동합니다.
-
탐지 품질 유지: 각 슬라이스가 독립적으로 처리되므로, 관심 객체를 캡처하기에 충분히 큰 슬라이스라면 object detection 품질의 저하가 없습니다.
-
향상된 확장성: 이 기술은 다양한 크기와 해상도의 이미지에 걸쳐 object detection을 더 쉽게 확장할 수 있게 해주며, 위성 이미지부터 의료 진단에 이르는 광범위한 애플리케이션에 이상적입니다.
| YOLO26 without SAHI | YOLO26 with SAHI |
|---|---|
![]() | ![]() |
Link to this section설치 및 준비#
Link to this section설치#
시작하려면 최신 버전의 SAHI와 Ultralytics를 설치하십시오:
pip install -U ultralytics sahiLink to this section모듈 가져오기 및 리소스 다운로드#
테스트 이미지를 다운로드하는 방법은 다음과 같습니다:
from sahi.utils.file import download_from_url
# Download test images
download_from_url(
"https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/small-vehicles1.jpeg",
"demo_data/small-vehicles1.jpeg",
)
download_from_url(
"https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/terrain2.png",
"demo_data/terrain2.png",
)Link to this sectionYOLO26을 사용한 표준 추론#
Link to this section모델 인스턴스화#
다음과 같이 object detection을 위한 YOLO26 모델을 인스턴스화할 수 있습니다:
from sahi import AutoDetectionModel
detection_model = AutoDetectionModel.from_pretrained(
model_type="ultralytics",
model_path="yolo26n.pt",
confidence_threshold=0.3,
device="cpu", # or 'cuda:0'
)Link to this section표준 예측 수행#
이미지 경로를 사용하여 표준 추론을 수행하십시오.
from sahi.predict import get_prediction
result = get_prediction("demo_data/small-vehicles1.jpeg", detection_model)
result.export_visuals(export_dir="demo_data/", hide_conf=True)Link to this section결과 시각화#
예측된 bounding boxes 및 마스크를 내보내고 시각화하십시오:
from PIL import Image
# Open the predicted image
processed_image = Image.open("demo_data/prediction_visual.png")
# Display the predicted image
processed_image.show()Link to this sectionYOLO26을 사용한 슬라이스 추론#
슬라이스 치수와 중첩 비율을 지정하여 슬라이스 추론을 수행하십시오:
from PIL import Image
from sahi.predict import get_sliced_prediction
result = get_sliced_prediction(
"demo_data/small-vehicles1.jpeg",
detection_model,
slice_height=256,
slice_width=256,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2,
)
# Export results
result.export_visuals(export_dir="demo_data/", hide_conf=True)
# Open the predicted image
processed_image = Image.open("demo_data/prediction_visual.png")
# Display the predicted image
processed_image.show()Link to this section예측 결과 처리#
SAHI는 다양한 주석 형식으로 변환할 수 있는 PredictionResult 객체를 제공합니다:
# Access the object prediction list
object_prediction_list = result.object_prediction_list
# Convert to COCO annotation, COCO prediction, imantics, and fiftyone formats
result.to_coco_annotations()[:3]
result.to_coco_predictions(image_id=1)[:3]
result.to_imantics_annotations()[:3]
result.to_fiftyone_detections()[:3]Link to this section배치 예측#
이미지 디렉토리에 대한 배치 예측을 수행하려면 다음을 사용하십시오:
from sahi.predict import predict
predict(
model_type="ultralytics",
model_path="yolo26n.pt",
model_device="cpu", # or 'cuda:0'
model_confidence_threshold=0.4,
source="path/to/dir",
slice_height=256,
slice_width=256,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2,
)이제 표준 추론 및 슬라이스 추론 모두에 대해 YOLO26과 SAHI를 사용할 준비가 되었습니다.
Link to this section인용 및 감사의 글#
연구 또는 개발 작업에서 SAHI를 사용하는 경우, 원본 SAHI 논문을 인용하고 저자들에게 감사를 표해주십시오:
@article{akyon2022sahi,
title={Slicing Aided Hyper Inference and Fine-tuning for Small Object Detection},
author={Akyon, Fatih Cagatay and Altinuc, Sinan Onur and Temizel, Alptekin},
journal={2022 IEEE International Conference on Image Processing (ICIP)},
doi={10.1109/ICIP46576.2022.9897990},
pages={966-970},
year={2022}
}computer vision 커뮤니티를 위해 이 귀중한 리소스를 만들고 유지 관리해 준 SAHI 연구 그룹에 감사를 드립니다. SAHI와 그 제작자에 대한 자세한 내용은 SAHI GitHub repository를 방문하십시오.
Link to this sectionFAQ#
Link to this sectionobject detection에서 슬라이스 추론을 위해 YOLO26을 SAHI와 어떻게 통합합니까?#
Ultralytics YOLO26을 슬라이스 추론을 위해 SAHI(Slicing Aided Hyper Inference)와 통합하면 이미지를 관리하기 쉬운 슬라이스로 분할하여 고해상도 이미지에서의 object detection 작업을 최적화할 수 있습니다. 이 방식은 메모리 사용량을 개선하고 높은 탐지 정확도를 보장합니다. 시작하려면 ultralytics 및 sahi 라이브러리를 설치해야 합니다:
pip install -U ultralytics sahi그런 다음 테스트 이미지를 다운로드합니다:
from sahi.utils.file import download_from_url
# Download test images
download_from_url(
"https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/small-vehicles1.jpeg",
"demo_data/small-vehicles1.jpeg",
)
download_from_url(
"https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/terrain2.png",
"demo_data/terrain2.png",
)더 자세한 지침은 슬라이스 추론 가이드를 참조하십시오.
Link to this section대형 이미지에 대한 object detection을 위해 왜 YOLO26과 함께 SAHI를 사용해야 합니까?#
대형 이미지의 object detection을 위해 Ultralytics YOLO26과 SAHI를 사용하면 다음과 같은 여러 이점이 있습니다:
- 계산 부담 감소: 더 작은 슬라이스는 처리 속도가 빠르고 메모리를 덜 소비하므로, 리소스가 제한된 하드웨어에서도 고품질 탐지를 실행할 수 있습니다.
- 탐지 정확도 유지: SAHI는 지능형 알고리즘을 사용하여 중첩된 상자를 병합함으로써 탐지 품질을 보존합니다.
- 향상된 확장성: 다양한 이미지 크기와 해상도에 걸쳐 object detection 작업을 확장함으로써, SAHI는 위성 이미지 분석 및 의료 진단과 같은 다양한 애플리케이션에 이상적입니다.
문서에서 슬라이스 추론의 이점에 대해 자세히 알아보십시오.
Link to this sectionYOLO26과 SAHI를 사용할 때 예측 결과를 시각화할 수 있습니까?#
네, YOLO26과 SAHI를 사용할 때 예측 결과를 시각화할 수 있습니다. 결과를 내보내고 시각화하는 방법은 다음과 같습니다:
from PIL import Image
result.export_visuals(export_dir="demo_data/", hide_conf=True)
processed_image = Image.open("demo_data/prediction_visual.png")
processed_image.show()이 명령은 시각화된 예측을 지정된 디렉토리에 저장하며, 이후 이미지를 로드하여 노트북이나 애플리케이션에서 볼 수 있습니다. 자세한 가이드는 표준 추론 섹션을 확인하십시오.
Link to this sectionSAHI는 YOLO26 object detection을 개선하기 위해 어떤 기능을 제공합니까?#
SAHI(Slicing Aided Hyper Inference)는 Ultralytics YOLO26의 object detection을 보완하는 여러 기능을 제공합니다:
- 원활한 통합: SAHI는 YOLO 모델과 쉽게 통합되며 코드 수정이 최소한으로 필요합니다.
- 리소스 효율성: 대형 이미지를 더 작은 슬라이스로 분할하여 메모리 사용과 속도를 최적화합니다.
- 높은 정확도: 스티칭 과정에서 중첩된 탐지 상자를 효과적으로 병합함으로써, SAHI는 높은 탐지 정확도를 유지합니다.
더 깊은 이해를 위해 SAHI의 주요 기능에 대해 읽어보십시오.
Link to this sectionYOLO26과 SAHI를 사용하여 대규모 추론 프로젝트를 어떻게 처리합니까?#
YOLO26과 SAHI를 사용하여 대규모 추론 프로젝트를 처리하려면 다음 모범 사례를 따르십시오:
- 필수 라이브러리 설치: 최신 버전의 ultralytics와 sahi를 설치했는지 확인하십시오.
- 슬라이스 추론 구성: 특정 프로젝트에 맞는 최적의 슬라이스 치수와 중첩 비율을 결정하십시오.
- 배치 예측 실행: SAHI의 기능을 사용하여 이미지 디렉토리에 대한 배치 예측을 수행하면 효율성이 향상됩니다.
배치 예측 예시:
from sahi.predict import predict
predict(
model_type="ultralytics",
model_path="path/to/yolo26n.pt",
model_device="cpu", # or 'cuda:0'
model_confidence_threshold=0.4,
source="path/to/dir",
slice_height=256,
slice_width=256,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2,
)더 자세한 단계는 배치 예측 섹션을 방문하십시오.

