|
本帖最后由 yinjun 于 2024-5-16 10:20 编辑
rt,运行后会报错
rknn_outputs_get, p_ctx->queue_output.size() = 0!
求大佬帮我看看怎么解决
错误日志
E RKNNAPI: Catch runtime Crash! Stack backtrace:
Segmentation Fault
# 0: 0x5e5298c38c
# 1: 0x5e5298f408
# 2: 0x72ccade5ec __kernel_rt_sigreturn
E RKNNAPI: rknn_outputs_get, p_ctx->queue_output.size() = 0!
E inference: Traceback (most recent call last):
File "rknn/api/rknn_log.py", line 309, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
File "rknn/api/rknn_base.py", line 2589, in rknn.api.rknn_base.RKNNBase.inference
File "rknn/api/rknn_runtime.py", line 554, in rknn.api.rknn_runtime.RKNNRuntime.get_outputs
Exception: E Get outputs failed, error code: RKNN_ERR_FAIL
模型
看附件
代码
- import os
- import urllib
- import traceback
- import time
- import sys
- import numpy as np
- import cv2
- import torch
- from rknn.api import RKNN
- from blazefacenumpy import BlazeFace
- ONNX_MODEL = 'best.onnx' # onnx 模型的路径
- ONNX_MODEL = 'rppg_new.onnx' # onnx 模型的路径
- ONNX_MODEL = 'blazeface128.onnx' # onnx 模型的路径
- # ONNX_MODEL = 'v3.onnx' # onnx 模型的路径
- # ONNX_MODEL = 'alexnet.onnx' # onnx 模型的路径
- TFLITE_MODEL = 'face_detection_front.tflite'
- # TFLITE_MODEL = 'alexnet_float32.tflite'
- # /anaconda/envs/horizon_bpu/lib/python3.8/site-packages/rknn/3rdparty/platform-tools/adb/linux-x86_64
- # tcpip
- RKNN_MODEL = './yolov8-ghost-pose.rknn' # 转换后的 RKNN 模型保存路径
- RKNN_MODEL = './bz128_3568.rknn' # 转换后的 RKNN 模型保存路径
- # RKNN_MODEL = './facenet——3568.rknn' # 转换后的 RKNN 模型保存路径
- RKNN_MODEL = './pfldv3.rknn' # 转换后的 RKNN 模型保存路径
- DATASET = './test.txt' # 数据集文件路径
-
- QUANTIZE_ON = False # 是否进行量化
- def plot_detections(img, detections):
- if isinstance(detections, torch.Tensor):
- detections = detections.cpu().numpy()
- # if detections.ndim == 1:
- # detections = np.expand_dims(detections, axis=0)
- # print("Found %d faces" % detections.shape[0])
-
- for i in range(detections.shape[0]):
- ymin = int(detections[i, 0] * img.shape[0])
- xmin = int(detections[i, 1] * img.shape[1])
- ymax = int(detections[i, 2] * img.shape[0])
- xmax = int(detections[i, 3] * img.shape[1])
- cv2.rectangle(img,(xmin,ymin),(xmax,ymax),(170,234,242),5,lineType=cv2.LINE_AA)
-
- # if with_keypoints:
- # for k in range(6):
- # kp_x = detections[i, 4 + k*2 ] * img.shape[1]
- # kp_y = detections[i, 4 + k*2 + 1] * img.shape[0]
- # circle = patches.Circle((kp_x, kp_y), radius=0.5, linewidth=1,
- # edgecolor="lightskyblue", facecolor="none",
- # alpha=detections[i, 16])
- # ax.add_patch(circle)
- if __name__ == '__main__':
-
- # 创建 RKNN 对象
- rknn = RKNN(verbose=False)
-
- # 检查 ONNX 模型文件是否存在
- if not os.path.exists(ONNX_MODEL):
- print('model not exist')
- exit(-1)
-
- # 配置模型预处理参数
- print('--> Config model')
- rknn.config(#reorder_channel='0 1 2', # 表示 RGB 通道
-
- mean_values=[[0, 0, 0]], # 每个通道的像素均值,预处理时对应通道减去该值
- std_values=[[255, 255, 255]], # 每个通道的像素标准差,每个通道除以该值
- optimization_level=3, # 优化级别
- quantized_method='layer',
- float_dtype="float16",
- target_platform = 'RK3568', #指定目标平台为rv1126
- # quantize_input_node=QUANTIZE_ON
- ) # 对时输入节点进行量化
-
- # 加载 ONNX 模型
- # print('--> Loading model')
- model = rknn.load_rknn(RKNN_MODEL)
- ret = rknn.init_runtime(target="rk3568")
- print("start")
- frame = cv2.imread('./test.jpg')
- frame =cv2.resize(frame,(112,112))
-
- back_net = BlazeFace(back_model=False).to("cpu")
-
-
- input = np.reshape(frame,-1)
-
-
- pred = rknn.inference(inputs=[input], data_format='nhwc')
- kk1 = np.reshape( pred[1],-1)[222:225]
- print(pred[1].astype(np.float16))
- kk =np.reshape( pred[0],-1)[2::10].astype(np.int16)
- print('pred')
- # print('bz load')
- # back_net.load_anchors("anchors.npy")
- # deback = back_net._tensors_to_detections(raw_box_tensor=pred[0],raw_score_tensor=pred[1],anchors=back_net.anchors)
- # # 4. Non-maximum suppression to remove overlapping detections:
- # filtered_detections = []
- # for i in range(len(deback)):
- # faces = back_net._weighted_non_max_suppression(deback[i])
-
- # faces = np.stack(faces) if len(faces) > 0 else np.zeros((0, 17))
- # filtered_detections.append(faces)
- # plot_detections(frame,filtered_detections[0])
- # cv2.imwrite('test_out.jpg',frame)
-
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|