Tencent NCNN 내보내기
NCNN은 휴대폰, 임베디드 보드, 데스크톱 컴퓨터용 Tencent 오픈 소스 신경망 추론 프레임워크입니다. format="ncnn"을 사용해 Ultralytics YOLO26 모델을 내보내면 FP32 또는 FP16 가중치를 사용하는 .param 및 .bin 파일 쌍으로 네트워크를 저장한 yolo26n_ncnn_model/ 디렉터리가 생성됩니다.
한눈에 보기#
| 속성 | 세부 정보 |
|---|---|
format 인수 | ncnn |
| 출력 | yolo26n_ncnn_model/, model.ncnn.param, model.ncnn.bin, model_ncnn.py, metadata.yaml가 들어 있는 디렉터리 |
| 실행 환경 | ARM 및 x86-64 CPU, Vulkan 드라이버를 사용하는 GPU: 휴대폰, Raspberry Pi와 같은 단일 보드 컴퓨터, 데스크톱 컴퓨터 |
| 런타임 | NCNN: ncnn Python 패키지 또는 Android, iOS, 임베디드 애플리케이션용 NCNN C++ 라이브러리 |
| 정밀도 | FP32 또는 FP16 가중치이며 INT8 내보내기는 없습니다. YOLO26n은 FP32에서 9.8 MB, FP16 가중치 사용 시 5.0 MB입니다. |
| 내보내기 호스트 | pnnx 빌드가 제공되는 플랫폼인 Linux x86-64 또는 ARM64, macOS, Windows x64입니다. 내보내기에는 GPU가 필요하지 않습니다. |
Ultralytics Platform에서 학습된 모델을 NCNN으로 내보낼 수 있으므로 로컬 내보내기 환경이 필요하지 않습니다.
빠른 시작#
Ultralytics 패키지를 설치합니다.
pip install ultralytics첫 내보내기 시 누락된 ncnn 및 pnnx 패키지가 설치되며, 내보낸 모델로 첫 예측을 실행할 때 ncnn이 누락되어 있으면 설치됩니다. 새 환경에는 다른 항목이 필요하지 않습니다. 첫 내보내기는 Restart runtime or rerun command for updates to take effect를 기록한 후 동일한 실행에서 완료됩니다. 내보내기에는 다음 버전 요구 사항이 있습니다:
| 패키지 | 필수 버전 |
|---|---|
pnnx | 정확히 20260526입니다. 내보내기는 이 버전을 설치하고 다른 버전이 있으면 대체합니다. |
ncnn | 모든 버전 |
torch | 2.0 이상입니다. 내보내기는 버전을 확인하지 않으며, 이전 버전에서는 추론 중 충돌이 발생했기 때문에 Ultralytics 테스트에서 해당 버전의 NCNN 테스트를 건너뜁니다. |
다른 설치 방법은 설치 가이드를 참조하세요. 그런 다음 모델을 내보내고 내보낸 디렉터리를 로드하여 추론을 실행하거나 정확도를 검증합니다.
from ultralytics import YOLO
# YOLO26 모델 로드
model = YOLO("yolo26n.pt")
# 모델을 NCNN 형식으로 내보내기
model.export(format="ncnn") # creates 'yolo26n_ncnn_model/'
# 대신 FP16 가중치로 내보내면 파일 크기가 절반으로 줄어듭니다.
model.export(format="ncnn", quantize=16) # creates 'yolo26n_ncnn_model/'두 내보내기 모두 동일한 yolo26n_ncnn_model/ 디렉터리에 기록되므로 두 번째 내보내기가 첫 번째 내보내기를 대체합니다.
from ultralytics import YOLO
# 내보낸 NCNN 모델 불러오기
model = YOLO("yolo26n_ncnn_model")
# 추론 실행
results = model("https://ultralytics.com/images/bus.jpg")from ultralytics import YOLO
# 내보낸 NCNN 모델 불러오기
model = YOLO("yolo26n_ncnn_model")
# COCO8 데이터셋에서 정확도 검증
metrics = model.val(data="coco8.yaml")지원 작업#
NCNN 내보내기는 YOLOv8, YOLO11, YOLO26 모델에서 Ultralytics의 7가지 작업을 모두 지원합니다. 객체 탐지, 세그멘테이션, 시맨틱 세그멘테이션, 깊이 추정, 분류, 포즈 추정, OBB가 포함됩니다. 시맨틱 세그멘테이션과 깊이 추정은 해당 헤드를 제공하는 유일한 모델 제품군인 YOLO26에서만 사용할 수 있습니다. YOLOv5u, YOLOv9, YOLOv10, YOLO12의 탐지 모델도 내보낼 수 있습니다. RT-DETR, YOLO-World, 텍스트 프롬프트 YOLOE 모델은 변환되지 않습니다. 제한 사항 및 문제 해결을 참조하세요.
내보내기 인수#
| 인수 | 유형 | 기본값 | 설명 |
|---|---|---|---|
format | str | 'ncnn' | 내보낸 모델의 대상 형식으로, 다양한 배포 환경과의 호환성을 정의합니다. |
imgsz | int 또는 tuple | 640 | 내보낸 모델에서 고정되는 모델 입력 이미지 크기입니다. 정사각형 이미지에는 정수를, 그 외에는 튜플 (height, width)을 사용합니다. 지정하지 않으면 내보내기에 체크포인트 학습 시 사용한 크기가 적용됩니다. 공식 YOLO26 체크포인트는 탐지, 세그멘테이션, 포즈 모델과 ADE20K로 사전 학습한 시맨틱 모델에 640을, OBB 모델과 Cityscapes로 사전 학습한 시맨틱 모델에 1024를, 깊이 모델에 768을, 분류 모델에 224를 사용합니다. |
quantize | int 또는 str | None | 저장된 가중치의 정밀도입니다. 16(FP16)은 파일 크기를 절반으로 줄이고, 32 또는 미지정 값은 FP32를 사용합니다. 8를 지정하면 오류가 발생하며, quantize=8으로 학습한 체크포인트는 NCNN으로 내보낼 수 없습니다. 제한 사항 및 문제 해결을 참조하세요. 더 이상 사용되지 않는 half 플래그를 대체합니다. |
nms | bool, 선택 사항 | None | NCNN 모델은 항상 외부 NMS 처리를 위해 원시 예측값을 반환합니다. NMS가 없는 헤드(False)와 내장 NMS(True)는 사용할 수 없습니다. 제한 사항 및 문제 해결을 참조하세요. |
device | str | None | 변환을 위해 모델을 추적하는 장치입니다. 기본값이며 GPU가 있는 컴퓨터에서도 사용하는 cpu, CUDA GPU용 0, Apple 실리콘용 mps 중에서 선택합니다. |
형식별 내보내기 인수 중 NCNN은 다음 인수만 지원합니다. 모든 형식에 공통으로 적용되는 인수는 내보내기 모드 문서를 참조하세요.
정밀도#
quantize은 가중치를 model.ncnn.bin에 저장하는 방식을 선택합니다. 크기는 imgsz=640로 내보낸 YOLO26n 탐지 모델의 값입니다.
quantize | 가중치 | YOLO26n 크기 |
|---|---|---|
설정 해제 또는 32 | FP32 | 9.8 MB |
16 | FP16 | 5.0 MB |
- FP16 가중치:
quantize=16은 가중치를 반정밀도로 저장하며 보정 데이터가 필요하지 않습니다. 입력과 출력은float32로 유지되므로 FP32 모델용으로 작성한 추론 코드를 변경 없이 실행할 수 있습니다. - 정확도: COCO val2017에서 x86-64 서버 CPU를 사용했을 때 YOLO26n의 FP32 및 FP16 NCNN 모델, ONNX 모델, PyTorch 모델(
rect=False)은 모두 동일한 640x640 입력에서 40.9 mAPval 50-95를 기록했습니다. - FP16 연산: NCNN은 저장된 가중치의 정밀도와 관계없이 반정밀도로 연산할 수도 있습니다. Apple M4에서는 두 내보내기 모델 모두 기본적으로 FP16 연산을 사용했습니다. 테스트 이미지 하나에서 신뢰도가 0.25를 넘는 앵커의 FP32 내보내기 모델 원시 박스 좌표는 ONNX 모델과 최대 약 2.1픽셀 차이가 났으며, ncnn 패키지에서
net.opt.use_fp16_storage = False을 설정하면 전체 출력은 0.01 이내로 일치했습니다. x86-64 서버 CPU에서는 같은 이미지의 탐지, 세그멘테이션, 깊이, 분류, 포즈, OBB 모델에서 FP32 내보내기 모델의 원시 출력이 ONNX 모델과 0.03 미만의 차이를 보였습니다. FP16 가중치를 사용하면 해당 앵커의 박스 좌표는 서버에서 약 0.3픽셀, M4에서 1.6픽셀 차이가 났습니다. M4에서 이 차이로 인한 정확도 변화는 0.1 미만이었습니다. COCO128에서 Ultralytics 검증기는 동일한 640x640 입력을 기준으로 FP32 내보내기 모델과 FP16 가중치 모델에 47.7 mAP 50-95를, PyTorch 모델(rect=False)에도 47.7을 기록했습니다.
출력 형식#
내보내기 결과로 디렉터리 하나가 생성됩니다.
| 파일 | 내용 |
|---|---|
model.ncnn.param | 텍스트 파일 형식의 네트워크 그래프 |
model.ncnn.bin | 가중치 |
model_ncnn.py | PNNX가 작성한 Python 스크립트로, ncnn 패키지를 사용해 무작위 입력으로 모델을 실행합니다. |
metadata.yaml | 클래스 이름, 작업, 이미지 크기, 배치 크기, 스트라이드 및 내보내기 인수입니다. Ultralytics는 모델을 로드할 때 이 정보를 읽습니다. |
내보내기 과정에서 디렉터리에 __pycache__ 폴더도 생성되며, 이 폴더는 삭제해도 됩니다. 모델은 in0이라는 입력 하나를 받으며, 입력 형식은 (3, height, width)입니다. 즉, RGB 이미지 한 장의 채널이 앞에 오고, float32 형식이며, 값은 0~1로 정규화됩니다. 배치 차원은 없으며 출력에도 배치 차원이 없습니다. 아래 형태는 기본 내보내기 크기를 사용하는 공식 YOLO26n 체크포인트의 값이며, 시맨틱 세그멘테이션에는 Cityscapes 체크포인트 yolo26n-sem.pt를 사용했습니다.
| 작업 | 기본 imgsz | 출력 |
|---|---|---|
| 감지 | 640 | out0 (84, 8400) |
| 분할 | 640 | out0 (116, 8400) 및 out1 (32, 160, 160) |
| 의미론적 | 1024 | out0 (19, 1024, 1024), 각 클래스와 픽셀별 점수 |
| 깊이 | 768 | out0 (1, 768, 768): depth map |
| 분류 | 224 | out0 (1000,), 클래스 확률 |
| 포즈 | 640 | out0 (56, 8400) |
| OBB | 1024 | out0 (20, 21504) |
- 원시 예측값: 탐지, 세그멘테이션, 포즈, OBB 모델은 배치 차원을 제외하고 기본 ONNX 내보내기와 동일한 원시 예측값을 반환합니다. 각 앵커에 대해 입력 픽셀 단위의 박스 중심 x, 중심 y, 너비, 높이, 클래스 점수, 작업별 값(마스크 계수 32개, 키포인트 값 17 x 3개 또는 라디안 단위의 OBB 각도)이 순서대로 포함됩니다. NMS를 직접 적용하세요.
- 세그멘테이션:
out0에는 예측값이,out1에는 마스크 프로토타입이 저장됩니다. - 시맨틱 분할: 출력에는 ONNX 내보내기의 클래스 맵이 아니라 클래스와 픽셀마다 점수가 포함되므로, 자체 코드에서 클래스 축에 대해 argmax를 계산하세요.
- NMS: NMS가 필요 없는 출력이나 내장 NMS 출력은 없습니다. 제한 사항 및 문제 해결을 참조하세요.
YOLO("yolo26n_ncnn_model")은 metadata.yaml에서 레이아웃을 읽고 배치 차원을 추가한 뒤 NMS를 적용하므로, 모델을 직접 작성한 코드에서 실행할 때만 이러한 세부 정보를 알아야 합니다. metadata.yaml의 키에는 names, task, imgsz, stride, batch, end2end, args가 포함되며, 포즈 모델에는 kpt_shape도 포함됩니다.
ncnn 패키지로 실행하기#
Ultralytics 패키지 외부에서 모델을 실행하려면 ncnn Python 패키지로 두 파일을 로드하세요. 동일한 .param 및 .bin 파일은 Android, iOS, 임베디드 Linux의 NCNN C++ 라이브러리에서도 로드할 수 있습니다.
# 먼저 내보내기: yolo export model=yolo26n.pt format=ncnn
import ncnn
import numpy as np
net = ncnn.Net()
net.opt.num_threads = 4 # 모델을 로드하기 전에 옵션 설정
assert net.load_param("yolo26n_ncnn_model/model.ncnn.param") == 0
assert net.load_model("yolo26n_ncnn_model/model.ncnn.bin") == 0
image = np.zeros((3, 640, 640), dtype=np.float32) # 레터박스 처리된 이미지: RGB, CHW, 0-1
with net.create_extractor() as ex:
ex.input("in0", ncnn.Mat(image).clone())
_, out0 = ex.extract("out0")
predictions = np.array(out0) # 형태 (84, 8400), NMS가 필요한 원시 예측값
assert predictions.shape == (84, 8400), "export a detection model at imgsz=640"ncnn.Mat(image)은 NumPy 배열의 메모리를 복사하지 않고 읽으므로, C 연속형 float32 배열을 전달하고 추출이 끝날 때까지 유지하거나, 위 예시처럼 .clone()로 복사하세요. transpose으로 만든 배열은 연속형이 아니며, 그 뒤에 astype를 적용하거나 나누기를 수행해도 레이아웃은 그대로 유지되므로 전처리는 np.ascontiguousarray(x, dtype=np.float32)로 마무리하세요. 이 모델을 테스트했을 때 비연속 배열은 오류 없이 실행되었지만 잘못된 예측값을 반환했으며, float64 배열은 Python을 비정상 종료시켰습니다.
배포#
대상 장치에서 pip install ultralytics으로 패키지를 설치하고 yolo26n_ncnn_model/ 디렉터리를 해당 장치에 복사하세요. 그러면 YOLO("yolo26n_ncnn_model")가 Ultralytics에서 첫 사용 시 설치하는 ncnn Python 패키지로 모델을 실행합니다. device 인수는 NCNN 실행 위치를 선택합니다.
device | 모델 실행 위치 |
|---|---|
설정 해제 또는 cpu | CPU에서 NCNN 실행 |
vulkan:0, vulkan:1, ... | 해당 인덱스의 Vulkan 장치에서 NCNN 실행. Vulkan GPU 추론을 참조하세요. |
CUDA GPU가 있는 컴퓨터에서 0 실행 | CPU에서 NCNN 실행: NCNN에는 CUDA 백엔드가 없습니다. |
Apple silicon에서 mps | NCNN은 CPU에서 실행하고, Ultralytics는 Apple GPU에서 전처리와 후처리를 수행합니다. M4에서는 첫 번째 이미지에 약 0.6초가 더 걸렸으며 추론 속도도 빨라지지 않았으므로 device을 설정하지 마세요. |
- 고정 입력 형태: 모델은 항상 내보내기 시점의
imgsz으로 실행되며, Ultralytics는 이 값을metadata.yaml에서 읽습니다.predict또는val에 전달한imgsz는 무시됩니다. 이미지 크기를 변경하려면 다시 내보내세요. - 배치: 모델은 이미지 한 장을 입력받으며 Ultralytics는 배치의 이미지를 하나씩 차례로 실행하므로 이미지 수에 제한이 없습니다.
val은 전달된 값과 관계없이batch=1을 설정합니다. - CPU 스레드: NCNN이 스레드 수를 직접 선택하며 Ultralytics는 이를 변경하지 않습니다. Apple M4에서는 성능 코어 수인 4개를 사용합니다. 코어가 많은 컴퓨터에 대해서는 제한 사항 및 문제 해결을 참조하세요.
Vulkan GPU 추론#
NCNN은 Vulkan을 통해 GPU에서 실행되며 CUDA 없이 AMD, Intel, ARM, Qualcomm, Apple 등의 GPU 제조업체를 지원합니다. 첫 번째 Vulkan 장치에는 device="vulkan:0"을, 두 번째 장치에는 vulkan:1를 전달하세요.
from ultralytics import YOLO
# 내보낸 NCNN 모델 불러오기
model = YOLO("yolo26n_ncnn_model")
# 첫 번째 Vulkan 장치에서 추론 실행
results = model("https://ultralytics.com/images/bus.jpg", device="vulkan:0")GPU에 Vulkan 드라이버가 필요합니다. 대부분의 최신 GPU 드라이버에 포함되어 있으며, Linux에서는 vulkaninfo으로 설치된 드라이버를 확인할 수 있습니다. 인덱스는 NCNN이 찾은 Vulkan 장치의 순서를 나타내며, 해당 장치가 실제 하드웨어 GPU일 필요는 없습니다. 결과를 신뢰하기 전에 장치를 출력해 확인하세요.
import ncnn
for i in range(ncnn.get_gpu_count()):
print(i, ncnn.get_gpu_info(i).device_name())Vulkan이 항상 CPU보다 빠른 것은 아닙니다. Apple M4에서 YOLO26n은 Vulkan 장치에서 이미지당 약 31ms, CPU에서 약 12ms가 걸렸습니다. 사용하는 장치에서 두 방식을 모두 측정하세요.
배포 가이드#
- Raspberry Pi: Raspberry Pi 보드에서 Ultralytics를 설정하는 가이드입니다. 보드 자체에서 NCNN으로 내보내는 방법을 안내합니다.
- NVIDIA Jetson: Jetson 장치의 ARM CPU에서 NCNN을 실행하고 GPU에서는 TensorRT를 사용할 수 있습니다.
- NCNN 빌드 안내: Android, iOS, Linux, macOS, Windows 및 기타 대상용 NCNN C++ 라이브러리를 빌드합니다.
- GitHub의 NCNN: 소스 코드, Python 패키지, C++ 예제가 제공됩니다.
- 대화형 추적 UI 예제: CPU만 사용하는 장치에서 NCNN 모델을 실행하는 Ultralytics 예제입니다.
- 모델 배포 옵션: NCNN과 다른 내보내기 형식을 비교합니다.
제한 사항 및 문제 해결#
- INT8:
quantize=8은quantize=8 (INT8) is not supported; format='ncnn' supports quantize=16 (FP16), 32 or None (FP32).에서 실패합니다. FP16을 사용해 파일 크기를 줄이거나, LiteRT 또는 MNN처럼 INT8 내보내기를 지원하는 형식을 사용하세요. quantize=8으로 학습한 체크포인트: 양자화 인식 학습으로 미세 조정한 체크포인트는format='ncnn' cannot export a QAT model: its Q/DQ ranges are only read by the 'onnx' and 'engine' backends에서 실패합니다. 대신 미세 조정에 사용한 원본 체크포인트를 내보내거나, 미세 조정한 체크포인트를 ONNX 또는 TensorRT로 내보내세요.- NMS가 없는 헤드: NCNN 모델은 항상 NMS가 필요한 원시 예측값을 반환합니다.
nms=False을 사용하면 YOLO26 또는 YOLOv10 모델 내보내기 시This export format does not support end2end models, disabling the end2end branch.을 기록하고 일대다 헤드를 사용합니다. 예를 들어 YOLO11과 같은 다른 탐지, 세그멘테이션, 포즈, OBB 모델에서는This model has no one-to-one head; using one-to-many outputs.를 기록합니다. - 내장 NMS:
nms=True은format=ncnn does not support embedded NMS; exporting native outputs for external NMS.을 기록하고 원시 출력을 기록합니다. - 고정 입력 형태 및 배치 크기:
dynamic=True은argument 'dynamic' is not supported for format='ncnn'에서 실패하며, 1이 아닌batch는argument 'batch' is not supported for format='ncnn'에서 실패합니다. 이미지 크기를 변경하려면 다시 내보내세요. - 변환할 수 없는 모델: RT-DETR(
rtdetr-l.pt), YOLO-Worldv2(yolov8s-worldv2.pt), 텍스트 프롬프트 YOLOE(yoloe-26s-seg.pt) 모델은 내보내기가NCNN failed to load the exported model, it may contain layers NCNN does not support.에서 실패합니다. 텍스트 프롬프트 YOLOE 모델은set_classes()로 클래스를 고정한 뒤 내보낼 수 있으며, 프롬프트가 없는yoloe-26s-seg-pf.pt모델은 그대로 내보낼 수 있습니다. - PNNX 버전: 내보내기에는
pnnx20260526이 필요하며, 최신 버전을 대체합니다. PNNX 20260704로 변환한 모델은 추론 중 충돌이 발생하기 때문입니다. - 자동 설치 비활성화:
YOLO_AUTOINSTALL=false을 사용하면 패키지가 없는 환경에서 내보내기가No module named 'ncnn'로 실패합니다.pip install --no-deps ncnn와pip install pnnx==20260526으로 패키지를 설치하세요. - CPU 코어가 많은 컴퓨터: NCNN은 감지한 CPU 코어 수를 바탕으로 스레드 수를 선택하며 Ultralytics는 이를 변경하지 않습니다. AMD EPYC 9655 프로세서 2개(논리 CPU 384개)가 있는 공유 서버에서는 스레드 352개를 선택했으며, YOLO26n은
YOLO()을 통해 이미지당 약 210~630ms가 걸렸습니다. 모델을 로드하기 전에 스레드 수를 8로 설정하면 약 34ms가 걸렸습니다.OMP_NUM_THREADS변수와 CPU 선호도(taskset)는 스레드 수를 바꾸지 않았습니다.taskset으로 CPU를 8개로 제한해도 모델은 여전히 스레드 352개로 실행되어 이미지당 약 230ms가 걸렸습니다. 모델을 로드한 뒤num_threads를 변경하면 추론 속도가 느려졌습니다. 스레드 수를 선택하려면 ncnn 패키지로 모델을 실행하고 로드 전에net.opt.num_threads을 설정하세요. - 불완전한 모델 디렉터리:
model.ncnn.bin이 없거나 일부만 복사된 경우(예: 장치로 복사하는 도중 중단된 경우), Python이 트레이스백 없이 세그먼테이션 오류로 종료됩니다. 출력 마지막 줄에 원인인fopen yolo26n_ncnn_model/model.ncnn.bin failed또는ModelBin read weight_data failed가 표시됩니다.model.ncnn.param이 없는 디렉터리는StopIteration로 실패합니다. 디렉터리를 다시 복사하세요. - 인덱스가 없는
device="vulkan":IndexError: list index out of range로 실패합니다.device="vulkan:0"와 같이 인덱스를 작성하세요. - Vulkan 장치가 GPU가 아닌 경우: 이 페이지 작성에 사용한 Linux 서버에서 NCNN이 나열한 유일한 Vulkan 장치는 CPU에서 실행되는 소프트웨어 렌더러인
llvmpipe이었습니다. 따라서device="vulkan:0"은 오류 없이 실행되지만 GPU를 사용하지 않습니다. 장치가 하나뿐인 컴퓨터에서vulkan:9처럼 존재하지 않는 인덱스를 지정해도 오류 없이 실행됩니다. - 출력 디렉터리: 한 체크포인트를 내보낼 때마다
quantize또는imgsz값과 관계없이 같은yolo26n_ncnn_model/디렉터리에 저장되므로 나중에 실행한 내보내기가 이전 결과를 대체합니다. 두 결과를 모두 보존하려면 디렉터리 이름을 바꾸세요. Ultralytics는_ncnn_model을 기준으로 형식을 인식하므로 디렉터리 이름에 해당 항목을 포함해야 합니다(예:yolo26n_fp16_ncnn_model/). 이 항목이 없는 디렉터리나.param파일의 경로를 사용하면is not a supported model format으로 실패합니다.
그 밖의 오류는 일반적인 문제 가이드를 참조하세요.
벤치마크#
Ultralytics는 두 가지 ARM 플랫폼의 NCNN 벤치마크를 공개합니다. Raspberry Pi 5 벤치마크는 YOLO26n 및 YOLO26s에서 NCNN과 다른 7개 형식을 비교하고, NVIDIA Jetson 벤치마크에는 YOLO26 탐지 모델 5종 전체의 NCNN 결과가 포함됩니다. YOLO26 모델 페이지에는 PyTorch 체크포인트의 정확도가 나와 있습니다.
내보낸 YOLO26 탐지 모델의 크기는 imgsz=640에서 model.ncnn.param과 model.ncnn.bin의 합으로 표시하며, 단위는 MB(10^6바이트)입니다. 내보내기 로그는 전체 디렉터리 크기를 MiB로 출력합니다. YOLO26n의 경우 각각 9.4 MB와 4.8 MB입니다.
| 모델 | PyTorch | NCNN FP32 | NCNN FP16 |
|---|---|---|---|
| YOLO26n | 5.5 | 9.8 | 5.0 |
| YOLO26s | 20.4 | 38.1 | 19.2 |
| YOLO26m | 44.3 | 81.8 | 41.0 |
| YOLO26l | 53.2 | 99.4 | 49.8 |
| YOLO26x | 118.7 | 223.0 | 111.7 |
2026년 11월 16일에 ultralytics 8.4.215, NCNN 1.0.20261020, PNNX 20260526으로 내보냈습니다.
NCNN 소개#
NCNN은 Tencent에서 개발했으며 QQ와 WeChat 등 Tencent 애플리케이션에서 사용됩니다. 타사 런타임 종속성이 없고 CPU와 Vulkan을 통한 GPU에서 실행되며, Ultralytics 내보내기에서 사용하는 PNNX 도구로 PyTorch 모델을 변환합니다. 전체 참조 정보는 NCNN 문서를 참조하세요.
자주 묻는 질문#
모델 크기가 중요하다면 FP16(
quantize=16)을 사용하세요. YOLO26n은 FP16 가중치를 사용하면 5.0 MB이며, FP32에서는 9.8 MB이고 보정 데이터가 필요하지 않습니다. COCO val2017에서 YOLO26n은 FP16 가중치로 FP32와 동일한 40.9 mAPval 50-95를 기록했습니다. FP16 가중치는 파일 크기를 줄일 뿐 모델 속도를 높이지 않습니다. NCNN은 하드웨어를 기준으로 연산 정밀도를 선택합니다. 정밀도를 참조하세요. 배포하기 전에 자체 데이터와 장치에서 내보낸 모델을 검증하세요.pnnx및ncnn패키지는 64비트 ARM Linux용 빌드를 제공하며, Raspberry Pi 가이드는 동일한format="ncnn"명령으로 보드에서 직접 내보내는 방법을 안내합니다. PC에서 내보낸 뒤yolo26n_ncnn_model/디렉터리를 보드에 복사할 수도 있습니다. 32비트 ARM 시스템에는pnnx빌드가 없으므로 다른 컴퓨터에서 내보내세요.ncnn은 해당 시스템용 빌드가 있지만, Ultralytics에서 테스트하지 않았습니다.NCNN 빌드 안내에 따라 플랫폼용 NCNN 라이브러리를 빌드하거나 다운로드하고,
model.ncnn.param과model.ncnn.bin를 앱에 추가한 다음 출력 형식에 설명된 대로in0입력을 전달하세요. 코드에서 이미지를 레터박스 처리하고 원시 예측값을 디코딩한 뒤 NMS를 적용해야 합니다. 바로 사용할 수 있는 앱 구성 요소를 원한다면 Ultralytics YOLO Flutter 플러그인을 사용하면 Android에서 LiteRT 내보내기 모델을, iOS에서 Core ML 내보내기 모델을 실행할 수 있습니다.먼저 스레드 수를 확인하세요. NCNN은 감지한 CPU 코어 수를 바탕으로 스레드 수를 선택하며, 코어가 수백 개인 서버에서는 이로 인해 추론 속도가 느려졌습니다. 제한 사항 및 문제 해결을 참조하세요. 해당 서버에서 스레드 8개를 사용한 YOLO26n은 이미지당 약 34ms가 걸렸으며, PyTorch와 ONNX Runtime은 둘 다 약 13ms가 걸렸습니다. NCNN이 스레드 4개를 선택하는 Apple M4에서는 약 12ms가 걸렸습니다. x86-64 서버의 경우 Ultralytics는 OpenVINO와 ONNX를 벤치마크 형식으로 사용합니다.
댓글37
질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.
gpsamt(수정됨)
I'm testing the use of ncnn on android. I converted a yolov11 model. I've tried every way to adjust the code, but I can't. The detections are not coming out correctly. The ncnn model on windows works as can be seen in the image. I'm sharing my native code in c++. If anyone can help me I'd really appreciate it.
Image detected with yolo predict model=C:\Users\guips\Downloads\best_ncnn_model source="C:\Users\guips\Downloads\brasil\test822.jpg" save_txt=true
#include <jni.h> #include <android/log.h> #include #include #include #include <opencv2/opencv.hpp> #include <ncnn/net.h> // #include <stb_image.h> // Uncomment if using stb_image
#define LOG_TAG "NCNN_DETECTOR" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, VA_ARGS) #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, VA_ARGS) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, VA_ARGS)
static ncnn::Net g_net; static std::vectorstd::string g_labels; static bool g_model_loaded = false;
struct Detection { float x, y, width, height; int label; float prob; };
static float sigmoid(float x) { return 1.0f / (1.0f + std::exp(-x)); }
static float calculate_iou(const Detection& a, const Detection& b) { float x1 = std::max(a.x, b.x); float y1 = std::max(a.y, b.y); float x2 = std::min(a.x + a.width, b.x + b.width); float y2 = std::min(a.y + a.height, b.y + b.height);
float inter_area = std::max(0.0f, x2 - x1) * std::max(0.0f, y2 - y1); float union_area = a.width * a.height + b.width * b.height - inter_area; return union_area > 0 ? inter_area / union_area : 0.0f;}
extern "C" JNIEXPORT jboolean JNICALL Java_com_example_ncnnmy_1ok_MainActivity_loadModel( JNIEnv* env, jobject thiz, jstring param_path, jstring bin_path, jstring labels_path) {
const char* param_path_str = env->GetStringUTFChars(param_path, nullptr); const char* bin_path_str = env->GetStringUTFChars(bin_path, nullptr); const char* labels_path_str = env->GetStringUTFChars(labels_path, nullptr); LOGI("Starting model loading..."); LOGD("Param path: %s", param_path_str); LOGD("Bin path: %s", bin_path_str); LOGD("Labels path: %s", labels_path_str); g_net.clear(); g_labels.clear(); g_model_loaded = false; g_net.opt.num_threads = 4; g_net.opt.use_vulkan_compute = false; g_net.opt.use_fp16_packed = false; g_net.opt.use_fp16_storage = false; g_net.opt.use_fp16_arithmetic = false; int ret = g_net.load_param(param_path_str); if (ret != 0) { LOGE("Failed to load .param file (%d)", ret); env->ReleaseStringUTFChars(param_path, param_path_str); env->ReleaseStringUTFChars(bin_path, bin_path_str); env->ReleaseStringUTFChars(labels_path, labels_path_str); return JNI_FALSE; } ret = g_net.load_model(bin_path_str); if (ret != 0) { LOGE("Failed to load .bin file (%d)", ret); env->ReleaseStringUTFChars(param_path, param_path_str); env->ReleaseStringUTFChars(bin_path, bin_path_str); env->ReleaseStringUTFChars(labels_path, labels_path_str); return JNI_FALSE; } FILE* fp = fopen(labels_path_str, "r"); if (!fp) { LOGE("Failed to open labels file: %s", labels_path_str); env->ReleaseStringUTFChars(param_path, param_path_str); env->ReleaseStringUTFChars(bin_path, bin_path_str); env->ReleaseStringUTFChars(labels_path, labels_path_str); return JNI_FALSE; } char buffer[256]; while (fgets(buffer, sizeof(buffer), fp) != nullptr) { std::string label(buffer); label.erase(std::remove(label.begin(), label.end(), '\n'), label.end()); label.erase(std::remove(label.begin(), label.end(), '\r'), label.end()); if (!label.empty()) { g_labels.push_back(label); } } fclose(fp); if (g_labels.empty()) { LOGE("No labels loaded from %s", labels_path_str); env->ReleaseStringUTFChars(param_path, param_path_str); env->ReleaseStringUTFChars(bin_path, bin_path_str); env->ReleaseStringUTFChars(labels_path, labels_path_str); return JNI_FALSE; } LOGI("Model loaded successfully"); LOGI("Total labels loaded: %zu", g_labels.size()); g_model_loaded = true; env->ReleaseStringUTFChars(param_path, param_path_str); env->ReleaseStringUTFChars(bin_path, bin_path_str); env->ReleaseStringUTFChars(labels_path, labels_path_str); return JNI_TRUE;}
extern "C" JNIEXPORT jstring JNICALL Java_com_example_ncnnmy_1ok_MainActivity_detect( JNIEnv* env, jobject thiz, jstring image_path, jdouble conf_threshold, jdouble nms_threshold) {
LOGI("Running updated detect method (no debug image)"); if (!g_model_loaded) { LOGE("Model not loaded"); return env->NewStringUTF("error:model_not_loaded"); } const char* image_path_str = env->GetStringUTFChars(image_path, nullptr); LOGI("Processing image: %s", image_path_str); // Option 1: Use OpenCV (current) cv::Mat image = cv::imread(image_path_str, cv::IMREAD_COLOR); env->ReleaseStringUTFChars(image_path, image_path_str); /* // Option 2: Use stb_image (uncomment to test) int width, height, channels; unsigned char* image_data = stbi_load(image_path_str, &width, &height, &channels, 3); env->ReleaseStringUTFChars(image_path, image_path_str); if (!image_data) { LOGE("Failed to load image with stb_image"); return env->NewStringUTF("error:image_load_failed"); } cv::Mat image(height, width, CV_8UC3, image_data); */ if (image.empty()) { LOGE("Failed to load image"); // stbi_image_free(image_data); // Uncomment if using stb_image return env->NewStringUTF("error:image_load_failed"); } LOGD("Input image: %dx%d, channels=%d", image.cols, image.rows, image.channels()); const int target_size = 640; int img_w = image.cols; int img_h = image.rows; float scale = std::min((float)target_size / img_w, (float)target_size / img_h); int new_w = static_cast<int>(img_w * scale); int new_h = static_cast<int>(img_h * scale); int dx = (target_size - new_w) / 2; int dy = (target_size - new_h) / 2; cv::Mat resized; cv::resize(image, resized, cv::Size(new_w, new_h)); cv::Mat input_mat(target_size, target_size, CV_8UC3, cv::Scalar(114, 114, 114)); resized.copyTo(input_mat(cv::Rect(dx, dy, new_w, new_h))); cv::cvtColor(input_mat, input_mat, cv::COLOR_BGR2RGB); input_mat.convertTo(input_mat, CV_32FC3, 1.0 / 255.0); ncnn::Mat in = ncnn::Mat::from_pixels(input_mat.data, ncnn::Mat::PIXEL_RGB, target_size, target_size); // stbi_image_free(image_data); // Uncomment if using stb_image ncnn::Extractor ex = g_net.create_extractor(); ex.input("in0", in); ncnn::Mat out; ex.extract("out0", out); if (out.empty()) { LOGE("Empty output from model"); return env->NewStringUTF("error:empty_model_output"); } LOGD("Output dimensions: w=%d, h=%d, c=%d", out.w, out.h, out.c); int num_preds, num_classes; bool is_decoupled = false; if (out.c == 1) { LOGD("Possible decoupled heads detected, checking for additional outputs..."); ncnn::Mat boxes, scores, classes; ex.extract("boxes", boxes); ex.extract("scores", scores); ex.extract("classes", classes); if (!boxes.empty() && !scores.empty() && !classes.empty()) { is_decoupled = true; LOGD("Decoupled heads detected: boxes=%dx%d, scores=%dx%d, classes=%dx%d", boxes.w, boxes.c, scores.w, scores.c, classes.w, classes.c); return env->NewStringUTF("error:decoupled_heads_not_implemented"); } } if (!is_decoupled) { if (out.c >= 5) { num_preds = out.h * out.w; num_classes = out.c - 5; LOGD("Interpreting as [1, num_predictions, 5 + num_classes]: num_preds=%d, num_classes=%d", num_preds, num_classes); } else if (out.h >= 5) { num_preds = out.w; num_classes = out.h - 5; LOGD("Interpreting as [1, 5 + num_classes, num_predictions]: num_preds=%d, num_classes=%d", num_preds, num_classes); } else { LOGE("Invalid output dimensions: w=%d, h=%d, c=%d", out.w, out.h, out.c); return env->NewStringUTF("error:invalid_output_dimensions"); } } if (num_classes != g_labels.size()) { LOGE("Mismatch between model outputs (%d) and labels (%zu)", num_classes, g_labels.size()); return env->NewStringUTF("error:model_labels_mismatch"); } std::vector<Detection> detections; int stride = (out.c >= 5) ? out.c : out.h; const float* data = (float*)out.data; // Log raw outputs if (num_preds > 0) { LOGD("Raw output sample: x=%.3f, y=%.3f, w=%.3f, h=%.3f, obj=%.3f", data[0], data[1], data[2], data[3], data[4]); // Log first class score if (num_classes > 0) { LOGD("Raw class score sample: class_0=%.3f", data[5]); } } for (int i = 0; i < num_preds; i++) { const float* pred = data + i * stride; float obj_score = sigmoid(pred[4]); if (obj_score < conf_threshold) continue; int class_id = 0; float max_score = sigmoid(pred[5]); for (int j = 1; j < num_classes; j++) { float score = sigmoid(pred[5 + j]); if (score > max_score) { max_score = score; class_id = j; } } float confidence = obj_score * max_score; if (confidence < conf_threshold) continue; // Normalize coordinates with sigmoid (assuming logits) float x_center = sigmoid(pred[0]) * target_size; float y_center = sigmoid(pred[1]) * target_size; float width = sigmoid(pred[2]) * target_size; float height = sigmoid(pred[3]) * target_size; // Adjust for letterbox float x = (x_center - width / 2 - dx) / scale; float y = (y_center - height / 2 - dy) / scale; width /= scale; height /= scale; LOGD("Prediction %d: x_center=%.2f, y_center=%.2f, width=%.2f, height=%.2f", i, x_center, y_center, width, height); LOGD("Transformed %d: x=%.2f, y=%.2f, width=%.2f, height=%.2f", i, x, y, width, height); // Validate coordinates if (x < 0 || y < 0 || width <= 0 || height <= 0 || x + width > img_w || y + height > img_h) { LOGD("Skipping invalid detection %d: x=%.2f, y=%.2f, w=%.2f, h=%.2f", i, x, y, width, height); continue; } // Minimum size filter if (width < 50 || height < 50) { LOGD("Skipping small detection %d: w=%.2f, h=%.2f", i, width, height); continue; } detections.push_back({x, y, width, height, class_id, confidence}); } // NMS std::sort(detections.begin(), detections.end(), [](const Detection& a, const Detection& b) { return a.prob > b.prob; }); std::vector<bool> suppressed(detections.size(), false); std::vector<Detection> final_detections; for (size_t i = 0; i < detections.size(); i++) { if (suppressed[i]) continue; final_detections.push_back(detections[i]); for (size_t j = i + 1; j < detections.size(); j++) { if (suppressed[j]) continue; float iou = calculate_iou(detections[i], detections[j]); if (iou > nms_threshold) { suppressed[j] = true; } } } LOGD("Detections after NMS: %zu", final_detections.size()); // Format results std::string result_str; for (const auto& det : final_detections) { if (!result_str.empty()) result_str += ";"; char buf[256]; snprintf(buf, sizeof(buf), "%s:%.2f,%.0f,%.0f,%.0f,%.0f", g_labels[det.label].c_str(), det.prob, det.x, det.y, det.width, det.height); result_str += buf; } return env->NewStringUTF(result_str.empty() ? "none" : result_str.c_str());}
Here is a log of the output of the flutter application.
[ ] D/NCNN_DETECTOR( 9180): Prediction 3730: x_center=640.00, y_center=640.00, width=640.00, height=640.00 [ ] D/NCNN_DETECTOR( 9180): Transformed 3730: x=320.00, y=240.00, width=640.00, height=640.00 [ ] D/NCNN_DETECTOR( 9180): Skipping invalid detection 3730: x=320.00, y=240.00, w=640.00, h=640.00 [ ] D/NCNN_DETECTOR( 9180): Prediction 3731: x_center=640.00, y_center=640.00, width=640.00, height=640.00 [ ] D/NCNN_DETECTOR( 9180): Transformed 3731: x=320.00, y=240.00, width=640.00, height=640.00 [ ] D/NCNN_DETECTOR( 9180): Skipping invalid detection 3731: x=320.00, y=240.00, w=640.00, h=640.00 [ ] D/NCNN_DETECTOR( 9180): Prediction 3732: x_center=640.00, y_center=640.00, width=640.00, height=640.00 [ ] D/NCNN_DETECTOR( 9180): Transformed 3732: x=320.00, y=240.00, width=640.00, height=640.00 [ ] D/NCNN_DETECTOR( 9180): Skipping invalid detection 3732: x=320.00, y=240.00, w=640.00, h=640.00 [ ] D/NCNN_DETECTOR( 9180): Detections after NMS: 0 [ ] I/flutter ( 9180): Detection result: none [ ] I/flutter ( 9180): STATUS: No objects detected [ ] E/libEGL ( 9180): called unimplemented OpenGL ES API
Glenn JocherUltralytics(수정됨)@gpsamt looking at your logs, the issue appears to be with output format parsing. YOLO11 NCNN outputs have no separate objectness score, and the class scores are already sigmoid-activated, so don't apply sigmoid again. Try parsing each prediction like this:
// Box is x_center, y_center, width, height (no sigmoid needed) float x_center = pred[0]; float y_center = pred[1]; float width = pred[2]; float height = pred[3]; // pred[4 .. 4+nc) are the per-class scores; take the max class as the confidence // Convert from center format to corner format float x = (x_center - width / 2 - dx) / scale; float y = (y_center - height / 2 - dy) / scale;Also verify your model's actual output format by checking if coordinates are normalized (0-1) or absolute (0-640). The repeated 640.00 values suggest coordinate parsing issues. For official Android deployment examples, refer to the NCNN Android documentation.
aram199922
Hey everyone, I have trained yolo11n.pt pretrained model on my custom dataset. Run the detection on a video and got quite good results. Now trying to export ncnn with the given guide, files are being generated correctly, however the detection on the same video seems corrupted. I am trying to detect potholes on road, however ncnn model predict 300 potholes on each frame. Any suggestion?
aram199922
One more note is that I have trained my model with 736p, 640p modes are converting fine. But does this mean I can't conver higher resolution trained model to ncnn?
Glenn JocherUltralytics@aram199922 The issue with your NCNN model detecting 300 potholes likely relates to confidence thresholds. When exporting to NCNN, default thresholds may not transfer properly. Try explicitly setting a higher confidence threshold during inference:
# Load the NCNN model ncnn_model = YOLO("your_model_ncnn_model") # Run inference with higher confidence threshold results = ncnn_model("video.mp4", conf=0.5) # Adjust this value as neededRegarding your 736p model - yes, you can export higher resolution models to NCNN by specifying the custom size during export:
model = YOLO("your_trained_model.pt") model.export(format="ncnn", imgsz=736) # Use your training resolutionThis ensures the exported model maintains the same input dimensions you used during training. Let me know if this helps resolve the issue!
gpsamt
Hello. Does anyone have any example of implementing the converted ncnn model in android?
PabloBR99
Do this work with YOLOv12?
Glenn JocherUltralytics(수정됨)@PabloBR99 YOLO12 isn't recommended for NCNN export due to training instability and performance limitations. For NCNN deployments, we strongly recommend using YOLO26 (or YOLO11), which offer optimized performance and stability across all platforms. You can find the NCNN export guide in our documentation.
gpsamt
I am exporting a YOLOv11s model to ncnn. My model has 4 classes, however, when I perform the export, it appears that it is identifying 3 classes: PyTorch: starting from '/content/drive/MyDrive/IAGeneration/yolo11/runs/detect/train3/weights/best.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 8, 8400) (18.3 MB). In Android Studio, this message appears:
2025-03-04 17:08:58.490 3853-3853 NcnnDetector com.example.agroinsect D Starting detection 2025-03-04 17:08:58.502 3853-3853 NcnnDetector com.example.test D Param file size: 22768 bytes 2025-03-04 17:08:58.504 3853-3853 NcnnDetector com.example.test D Load param result: 0 2025-03-04 17:08:58.504 3853-3853 NcnnDetector com.example.test D Bin file size: 10633344 bytes 2025-03-04 17:08:58.596 3853-3853 NcnnDetector com.example.test D Load model result: 10633344 2025-03-04 17:08:58.597 3853-3853 NcnnDetector com.example.test D Failed to load model file
[ +82 ms] D/CompatChangeReporter( 3853): Compat change id reported: 312399441; UID 10209; state: ENABLED [ +11 ms] D/nativeloader( 3853): Load /data/app/~~yVwXpMN1F9boaEz-oh0Bpw==/com.example.test-J2_0Fz9v3HSf0USV8uxz6Q==/lib/x86_64/libncnn_detector.so using ns clns-7 from class loader (caller=/data/app/~~yVwXpMN1F9boaEz-oh0Bpw==/com.example.test-J2_0Fz9v3HSf0USV8uxz6Q==/base.apk!classes4.dex): ok [ ] D/NcnnDetector( 3853): Library ncnn_detector loaded successfully [ ] D/NcnnDetector( 3853): Starting detection [ +10 ms] D/NcnnDetector( 3853): Param file size: 22768 bytes [ +2 ms] D/NcnnDetector( 3853): Load param result: 0 [ ] D/NcnnDetector( 3853): Bin file size: 10633344 bytes [ +97 ms] D/NcnnDetector( 3853): Load model result: 10633344 [ +1 ms] D/NcnnDetector( 3853): Failed to load model file [ ] I/flutter ( 3853): Native detect result: null [ ] I/flutter ( 3853): Detections received: [] [ ] I/flutter ( 3853): No detections found.
I have repeated the process several times, but I have not been able to resolve it. I found this answer: 'The current problem (Load model result: 37825744) suggests difficulties in exporting or compatibility.'"
Glenn JocherUltralytics@gpsamt thank you for reporting this issue. Let's address both aspects systematically:
-
Class Count Mismatch:
The output shape (1,8,8400) suggests your model is correctly configured for 4 classes (4 classes + 4 box coordinates = 8). This indicates the export itself is successful. The Android implementation might need adjustment to handle the 4-class output format. -
Model Loading Failure:
The "Failed to load model file" error typically indicates either:
- Missing/corrupted
.paramor.binfiles in deployment - Architecture mismatch between PyTorch and NCNN versions
- Incorrect Android NCNN implementation
We recommend:
- Verify successful local inference with your NCNN model using
yolo predict model='yolo11n_ncnn_model'before Android deployment - Ensure you're using the latest NCNN Android library from Tencent's NCNN GitHub repo
- Double-check that all NCNN model files are properly bundled in your Android assets
For specific Android implementation guidance, please consult NCNN's official Android deployment documentation.
-
gpsamt(수정됨)
I made several attempts and ended up not proceeding, however I really wanted to test my trained model running on android with ncnn. I made an export on windows of a yolo11 model trained in colab. To test the converted model yolo --> ncnn I did a test with an image with two objects. C:\Users\guips\Downloads>yolo predict model=C:\Users\guips\Downloads\best_ncnn_model source="C:\Users\guips\Downloads\brasil\test129.jpg" save_txt=true WARNING ⚠️ Unable to automatically guess model task, assuming 'task=detect'. Explicitly define task for your model, i.e. 'task=detect', 'segment', 'classify','pose' or 'obb'. Ultralytics 8.3.105 🚀 Python-3.11.9 torch-2.6.0+cpu CPU (12th Gen Intel Core(TM) i7-12700KF) Loading C:\Users\guips\Downloads\best_ncnn_model for NCNN inference...
image 1/1 C:\Users\guips\Downloads\brasil\test129.jpg: 640x640 2 Car, 103.0ms Speed: 20.4ms preprocess, 103.0ms inference, 24.2ms postprocess per image at shape (1, 3, 640, 640) Results saved to runs\detect\predict6 1 label saved to runs\detect\predict6\labels 💡 Learn more at https://docs.ultralytics.com/modes/predict
When I try to run the same image in the android application with flutter I can't. In TFLITE the output was (1,8,8400) Now it seems to be outputting (1,9,8400). I'm not able to work with the output data. I/flutter (14031): Labels loaded: 4E/libEGL (14031): called unimplemented OpenGL ES API I/flutter (14031): Storage permission denied D/InsetsController(14031): hide(ime(), fromIme=false) I/ImeTracker(14031): com.example.ncnnmy_ok:e29c5e1e: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN E/libEGL (14031): called unimplemented OpenGL ES API D/InsetsController(14031): hide(ime(), fromIme=false) I/ImeTracker(14031): com.example.ncnnmy_ok:6f2d251e: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN E/libEGL (14031): called unimplemented OpenGL ES API D/CompatChangeReporter(14031): Compat change id reported: 312399441; UID 10223; state: ENABLED I/flutter (14031): Image dimensions: 680.0x453.0 I/flutter (14031): Running inference on /data/user/0/com.example.ncnnmy_ok/cache/a6b569b8-5ff1-4466-ad32-49121fb24aa4/38.jpg D/MainActivity(14031): Received method call: detect I/NCNN (14031): Detecting on image: /data/user/0/com.example.ncnnmy_ok/cache/a6b569b8-5ff1-4466-ad32-49121fb24aa4/38.jpg I/NCNN (14031): Original image size: 680x453 I/NCNN (14031): Output dimensions: w=8400, h=9, c=1 I/NCNN (14031): Output saved to /data/user/0/com.example.ncnnmy_ok/cache/a6b569b8-5ff1-4466-ad32-49121fb24aa4/38.jpg_ncnn_output.txt W/NCNN (14031): Output has 4424 channels, expected 8. Using first 8 channels W/NCNN (14031): Invalid box at idx=9: w=0.000000, h=0.000000 W/NCNN (14031): Invalid box at idx=15: w=-0.010868, h=-0.063400 W/NCNN (14031): Invalid box at idx=16: w=-0.630245, h=-0.447460 W/NCNN (14031): Invalid box at idx=17: w=-0.685141, h=-0.837424 . . . W/NCNN (14031): Invalid box at idx=347: w=-0.077838, h=0.846499 F/libc (14031): Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x71c0c2499110 in tid 14031 (ample.ncnnmy_ok), pid 14031 (ample.ncnnmy_ok)
Build fingerprint: 'google/sdk_gphone64_x86_64/emu64xa:16/BP22.250221.010/13193326:user/release-keys' Revision: '0' ABI: 'x86_64' Timestamp: 2025-04-15 01:29:54.291432600+0000 Process uptime: 156s Cmdline: com.example.ncnnmy_ok pid: 14031, tid: 14031, name: ample.ncnnmy_ok >>> com.example.ncnnmy_ok <<< uid: 10223 signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x000071c0c2499110 rax 000071c0c2499100 rbx 000071c247d33be0 rcx 0000000000000004 rdx 0000000000000008 r8 00007ffc6ffc4080 r9 00007ffc6ffc40a0 r10 0000000000e8cada r11 0000000000000213 r12 00007ffc6ff903b0 r13 000071c247d33c88 r14 00007ffc6ff90718 r15 000071c247d33be0 rdi 00007ffc6ff8f840 rsi 0000000000000167 rbp 00007ffc6ff8f970 rsp 00007ffc6ff8f8b0 rip 000071c053d969ea 90 total frames backtrace: #00 pc 00000000000109ea /data/app/~~ygC8oOQ2RMgj_IeB2wDRKw==/com.example.ncnnmy_ok-1Q_3JHdbdZSe1RwVvc5qjQ==/lib/x86_64/libnative-lib.so (BuildId: 63a90d5f64ab095e3ac958c5db79324dfa15e937) #01 pc 000000000000fd3a /data/app/~~ygC8oOQ2RMgj_IeB2wDRKw==/com.example.ncnnmy_ok-1Q_3JHdbdZSe1RwVvc5qjQ==/lib/x86_64/libnative-lib.so (BuildId: 63a90d5f64ab095e3ac958c5db79324dfa15e937) #02 pc 000000000000e8aa /data/app/~~ygC8oOQ2RMgj_IeB2wDRKw==/com.example.ncnnmy_ok-1Q_3JHdbdZSe1RwVvc5qjQ==/lib/x86_64/libnative-lib.so (Java_com_example_ncnnmy_1ok_MainActivity_detect+2634) (BuildId: 63a90d5f64ab095e3ac958c5db79324dfa15e937) #03 pc 000000000022c80b /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+219) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #04 pc 0000000000211dd4 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+756) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #05 pc 0000000000461715 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+181) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #06 pc 00000000005f74b2 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2402) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #07 pc 0000000000233611 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+10625) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #08 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #09 pc 00000000000006a4 anonymous:71c395b1d000 (com.example.ncnnmy_ok.MainActivity.configureFlutterEngine$lambda$0+0) #10 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #11 pc 00000000005f6706 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+102) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #12 pc 00000000005f7498 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2376) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #13 pc 0000000000234b05 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+15989) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #14 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #15 pc 0000000000000604 anonymous:71c395b1d000 (com.example.ncnnmy_ok.MainActivity.$r8$lambda$8rE-0sywqH2S4u1lhbBM5kfBEYE+0) #16 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #17 pc 00000000005f6706 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+102) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #18 pc 00000000005f7498 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2376) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #19 pc 0000000000234b05 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+15989) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #20 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #21 pc 00000000000005b8 anonymous:71c395b1d000 (com.example.ncnnmy_ok.MainActivity$$ExternalSyntheticLambda0.onMethodCall+0) #22 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #23 pc 00000000005f6706 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+102) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #24 pc 00000000005f7498 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2376) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #25 pc 00000000002346e5 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+14933) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #26 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #27 pc 00000000001bfabc anonymous:71c054260000 (io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage+0) #28 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #29 pc 00000000005f6706 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+102) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #30 pc 00000000005f7498 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2376) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #31 pc 00000000002346e5 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+14933) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #32 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #33 pc 00000000001b1954 anonymous:71c054260000 (io.flutter.embedding.engine.dart.DartMessenger.invokeHandler+0) #34 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #35 pc 00000000005f6706 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+102) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #36 pc 00000000005f7498 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2376) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #37 pc 0000000000233611 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+10625) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #38 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #39 pc 00000000001b19d8 anonymous:71c054260000 (io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger+0) #40 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #41 pc 00000000005f6706 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+102) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #42 pc 00000000005f827f /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2319) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #43 pc 000000000023482d /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+15261) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #44 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #45 pc 00000000001b1168 anonymous:71c054260000 (io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run+0) #46 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #47 pc 00000000009978fb /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+907) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #48 pc 000000000022c99c /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+140) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #49 pc 0000000000160efc [anon_shmem:dalvik-jit-code-cache] (offset 0x2000000) (android.os.Handler.handleCallback+156) #50 pc 00000000000718af [anon_shmem:dalvik-jit-code-cache] (offset 0x2000000) (android.os.Handler.dispatchMessage+159) #51 pc 000000000006e9a4 [anon_shmem:dalvik-jit-code-cache] (offset 0x2000000) (android.os.Looper.loopOnce+1348) #52 pc 0000000000212136 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+806) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #53 pc 000000000046175c /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+252) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #54 pc 00000000005f74b2 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2402) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #55 pc 0000000000234b05 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+15989) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #56 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #57 pc 000000000027c140 /system/framework/framework.jar (offset 0x1274000) (android.os.Looper.loop+0) #58 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #59 pc 00000000005f6706 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+102) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #60 pc 00000000005f7498 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2376) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #61 pc 0000000000234b05 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+15989) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #62 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #63 pc 00000000001f1254 /system/framework/framework.jar (offset 0x7000) (android.app.ActivityThread.main+0) #64 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #65 pc 00000000009978fb /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+907) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #66 pc 000000000022c99c /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+140) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #67 pc 0000000000212136 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+806) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #68 pc 000000000046175c /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+252) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #69 pc 000000000088b130 /apex/com.android.art/lib64/libart.so (_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+2240) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #70 pc 00000000007e0f1a /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) (.__uniq.165753521025965369065708152063621506277)+42) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #71 pc 000000000022c80b /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+219) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #72 pc 0000000000211dd4 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+756) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #73 pc 0000000000461715 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+181) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #74 pc 00000000005f74b2 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+2402) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #75 pc 0000000000233611 /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp(art::interpreter::SwitchImplContext*)+10625) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #76 pc 000000000022eb25 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+5) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #77 pc 000000000027f6ec /system/framework/framework.jar (offset 0x2430000) (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+0) #78 pc 00000000005ef3f2 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238)+466) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #79 pc 00000000009978fb /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+907) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #80 pc 000000000022c99c /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+140) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #81 pc 00000000007fc865 /system/framework/x86_64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2693) (BuildId: 5539d75c58ae9a874c8bdd56a20d5ad37b7a2757) #82 pc 0000000000212136 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+806) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #83 pc 000000000046175c /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+252) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #84 pc 000000000088bc46 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, __va_list_tag*)+518) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #85 pc 000000000072f31a /apex/com.android.art/lib64/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, __va_list_tag*)+602) (BuildId: 53a0485d03b4e7011d7d555e293a17af) #86 pc 00000000000eefae /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+126) (BuildId: 0e1c658a58fcbbaafa02d3d78a368ee8) #87 pc 000000000011b496 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vectorandroid::String8 const&, bool)+966) (BuildId: 0e1c658a58fcbbaafa02d3d78a368ee8) #88 pc 0000000000004708 /system/bin/app_process64 (main+1640) (BuildId: e2134dffba60b5f40425e9c838419a02) #89 pc 0000000000054ea5 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+117) (BuildId: 2fa253bed5a3b3aee8fce00edb55a139) Lost connection to device.
These are the first layers of the .param file and the last ones.
7767517 275 327 Input in0 0 1 in0 Convolution conv_0 1 1 in0 1 0=32 1=3 11=3 12=1 13=2 14=1 2=1 3=2 4=1 5=1 6=864 Swish silu_84 1 1 1 2 Convolution conv_1 1 1 2 3 0=64 1=3 11=3 12=1 13=2 14=1 2=1 3=2 4=1 5=1 6=18432 Swish silu_85 1 1 3 4 Convolution conv_2 1 1 4 5 0=64 1=1 11=1 12=1 13=1 14=0 2=1 3=1 4=0 5=1 6=4096
Last layer
Split splitncnn_27 1 2 313 314 315 BinaryOp add_16 2 1 310 312 316 0=0 Split splitncnn_28 1 2 316 317 318 BinaryOp add_17 2 1 314 317 319 0=0 BinaryOp div_18 1 1 319 320 0=3 1=1 2=2.000000e+00 BinaryOp sub_19 2 1 318 315 321 0=1 Concat cat_21 2 1 320 321 322 0=0 Reshape reshape_167 1 1 252 323 0=8400 1=1 BinaryOp mul_20 2 1 322 323 324 0=2 Sigmoid sigmoid_163 1 1 303 325 Concat cat_22 2 1 324 325 out0 0=0
I thank you in advance for your attention and help.
UltralyticsAssistantUltralytics
👋 Hello, thank you for your interest in Ultralytics 🚀! It's exciting to see discussions around optimizing YOLO models for mobile and embedded devices. The link you shared regarding NCNN integration is a great starting point for exploring this topic: https://docs.ultralytics.com/zh/integrations/ncnn/.
If you're encountering issues or have specific queries regarding the NCNN export or deployment, here are a few recommendations:
-
If this is a 🐛 Bug Report, please provide a minimum reproducible example so our team can better understand and debug any potential issues.
-
If this is an ❓ integration or optimization question, please provide as much context as possible, such as your model configuration, device specifications, and any logs or error messages.
For further learning and exploration, you may also find these resources helpful:
- Integration Examples: Comprehensive guides for integrating YOLO with various platforms and tools.
- NCNN Documentation: Specific details about NCNN and its benefits for resource-constrained environments.
Upgrade
Ensure you're using the latest Ultralytics package and dependencies by upgrading your environment with the following command:
pip install -U ultralyticsEnvironments
To experiment with YOLO in diverse, GPU-enabled environments, check out the following setups:
- Notebooks with free GPU:
- Cloud services like Google Cloud and AWS.
- Docker Image for efficient deployment and reproducibility
.
Status
This badge indicates the status of Ultralytics CI tests, which ensure the reliability of YOLO models across various environments. A green badge means all tests are successful ✅.
Lastly, this is an automated response to guide you as quickly as possible, but rest assured that an Ultralytics engineer will follow up soon to assist you further. Feel free to share additional information or questions in the meantime 😊.
haitao5676I have created a single target tracking model for deployment on Android devices. How can I export the ncnn file for deployment using my own model?
haitao5676I have resolved the issue of using the model trained by ncnn in Python and am now preparing to deploy Java references for Android. Excuse me!
Glenn JocherUltralytics@xiao5676wen thank you for your update. To deploy your YOLO11 NCNN model on Android, you'll need to build NCNN for Android using Tencent NCNN's build guide and integrate the exported model using the NCNN Android SDK. For detailed integration steps, refer to the official NCNN documentation for Android. Let me know if you encounter issues!
-
haitao5676How can I export ncnn using the PT file I trained myself?
Glenn JocherUltralytics@xiao5676wen to export your trained YOLO11
.ptmodel to NCNN format, load your model using theYOLOclass in Python and then call theexportmethod withformat="ncnn". Example:from ultralytics import YOLO model = YOLO("path_to_your_trained_model.pt") model.export(format="ncnn") # Creates the NCNN modelFor additional details, refer to the NCNN export documentation.
trungnb34
Hi everyone NCNN can be inferred from the int8 model I have a question. when converting Yolo model to int8 . Can ultralytics support it and Does the accuracy decrease much? Thanks
Glenn JocherUltralytics(수정됨)@trungnb34 Ultralytics can export YOLO models to NCNN in FP16 with
quantize=16, but INT8 quantization is not currently supported for NCNN exports (quantize=8is rejected for this format). For details, refer to the Export to NCNN guide.robert-hardman
Hello ultralytics==8.3.53 Like it doesn't support int8 yet
File "C:\Users***\AppData\Local\Programs\Python\Python312\Lib\site-packages\ultralytics\engine\exporter.py", line 253, in call validate_args(fmt, self.args, fmts_dict["Arguments"][flags.index(True) + 1]) File "C:\Users***AppData\Local\Programs\Python\Python312\Lib\site-packages\ultralytics\engine\exporter.py", line 144, in validate_args assert arg in valid_args, f"ERROR \u274c\ufe0f argument '{arg}' is not supported for format='{format}'" ^^^^^^^^^^^^^^^^^ AssertionError: ERROR \u274c\ufe0f argument 'int8' is not supported for format='ncnn'
Glenn JocherUltralytics@robert-hardman thank you for raising this issue. Currently, INT8 quantization is not supported for NCNN exports in Ultralytics. For updates on supported features, keep an eye on our Export documentation. Let us know if you have further questions!
1
amrboef66
Hellooo, im trying to run interference on a raspberry Pi 5, now indeed NCNN has the fastest time, but i need it to be even quicker, so i tried reducing the image format from 640 to 480, since my model does not require such a large image size, but when i do that it misidentifies and puts bounding boxes everywhere on screen. How do i reduce image size while still allowing the model to run accurately?
Also, do you have any thoughts on how i can make it quicker, perhaps a different method? I am already using Nano model and int8 quantisation.
Thank you so much!
Glenn JocherUltralytics@amrboef66 to improve accuracy with a smaller image size, consider fine-tuning your model on images of the desired size. Additionally, you might explore using a more efficient model architecture or further optimizing your inference pipeline.
abdullah000123
Can we directly export model in ncnn while training or we only can convert model which i obtained after training ie converting from pt to ncnn if we can convert directly while training whats is benefit in case of accuracy and also give me code if we can export directly while training model
Paula DerrengerUltralytics@abdullah000123 you can only export a YOLOv8 model to NCNN format after training is complete. Direct export during training is not supported. Exporting post-training ensures that the model is fully trained and optimized before conversion, which does not impact accuracy. For exporting, you can use the following command after training:
from ultralytics import YOLO model = YOLO("yolov8n.pt") model.export(format="ncnn")For more details, please refer to the NCNN export guide.
woerstcase
Hey there!
I tried and on my Mac M2 Mac the inference time got from around 60ms to 30ms. And in a custom Model even faster.
But now i have the "problem" that the BBoxes are very flickering. Is there a good technique to make the bbox drawing even more smooth. I tried some approaches like drawing over 5 Frames for e.g. But if i have same classes on the image the bbox starts wandering trough the image.
best regards
Glenn JocherUltralyticsHey there! 👋
Great to hear about the speed improvements on your Mac M2! For smoothing out the flickering BBoxes, one approach is to apply a moving average or some form of temporal smoothing to the bounding box coordinates across frames. This helps in making the position more stable. A simple example could be:
# Assuming bbox is a list of bounding box coordinates for the current frame # prev_bboxes is a list of previous bounding boxes (could store N previous states) smoothed_bbox = current_bbox * alpha + prev_bbox * (1 - alpha)alphais a weighting factor that determines the balance between the current and previous frame's information (e.g.,alpha=0.6). This approach assumesprev_bboxis the bounding box coordinate from the previous frame. Adjustalphabased on your preference for smoothness vs. responsiveness.If you're handling multiple objects of the same class, consider incorporating an object tracker that assigns unique IDs to each object. This way, you can apply the smoothing individually to each tracked object, preventing the "wandering" effect across objects of the same class.
Hope this helps! Let us know if you have any more questions. 😊
Best regards
1woerstcase
Worked for me! With my custom Model the inference time is around 15ms!
This is my smoothing function:
#Smoothing function def smooth_bbox(current_bbox, prev_bbox): if prev_bbox is None: return current_bbox smoothed_bbox = [(c * alpha + p * (1 - alpha)) for c, p in zip(current_bbox, prev_bbox)] return smoothed_bbox
....#later in the code i use it like this
for box, confidence, cls in zip(boxes, confidences, classes): x1, y1, x2, y2 = map(int, box[:4]) # Extract bounding box coordinates class_name = names[int(cls)] # Generate a unique key for each bbox assuming no tracking ID available bbox_key = f"{x1}_{y1}_{x2}_{y2}" # Apply smoothing current_bbox = [x1, y1, x2, y2] if bbox_key in prev_bboxes: smoothed_coords = smooth_bbox(current_bbox, prev_bboxes[bbox_key]) else: smoothed_coords = current_bbox # Update prev_bboxes prev_bboxes[bbox_key] = smoothed_coords # Calculate the center of the smoothed bbox center_x = int((smoothed_coords[0] + smoothed_coords[2]) / 2) center_y = int((smoothed_coords[1] + smoothed_coords[3]) / 2)best regards
Glenn JocherUltralyticsHey there!
Great to see your impressive inference times, and thanks for sharing your smoothing function! 🚀 It looks like a solid approach. To address the flickering and "wandering" of bounding boxes for objects of the same class, you might consider integrating an object tracking algorithm like SORT or DeepSORT that assigns unique IDs to each object. This way, you can ensure that the smoothing you apply is object-specific.
Here's a small tweak to include object tracking by simply creating a unique key based on the object's class and center coordinates, assuming you'd implement tracking to assign IDs:
# Assuming bbox_key generation after object tracking assigns a unique track_id bbox_key = f"{class_name}_{track_id}" # Use this key for previous bbox retrieval and smoothing applicationThis tweak can help keep the smoothing consistent across consecutive frames for the same object, reducing "wandering."
Hope this helps make your bboxes smooth as silk! Let me know if you have other questions or if there's more we can help with.
Happy coding! 😊
Best regards