Toybrick

标题: 测试RKNN_Toolkit 1.7.0 - openpose 模型输出 缺少 Prob (可能性)维度 [打印本页]

作者: jasonzhu12    时间: 2021-10-13 09:54
标题: 测试RKNN_Toolkit 1.7.0 - openpose 模型输出 缺少 Prob (可能性)维度
按照本论坛的教程 - 人工智能开发系列(7) OPENPOSE开发与实现能运行生成的RKNN1.7模型。
问题:
对比原openpose 模型 和 RKNN2.1 模型 的输出,RKNN1.7模型缺失一个可能性的维度。


请问:
RKNN1.7模型,能输出带Prob 的三维数组吗?


代码:
        # Inference
        print('--> Running model')
        frameinput = np.transpose(frame, [2, 0, 1])
        t = time.time()
        [output] = rknn.inference(inputs=[frameinput], data_format="nchw")
        elapsed = time.time() - t
        print('inference image: %.4f seconds.' % (elapsed))
        np.set_printoptions(threshold=np.inf)

        #print('done')
        output = output.reshape(1, 57, 46, 46)
        H = output.shape[2]
        W = output.shape[3]

        # Empty list to store the detected keypoints
        points = []

        for i in range(nPoints):
            # confidence map of corresponding body's part.
            probMap = output[0, i, :, :]

            # Find global maxima of the probMap.
            minVal, prob, minLoc, point = cv2.minMaxLoc(probMap)

            # Scale the point to fit on the original image
            x = (frameWidth * point[0]) / W
            y = (frameHeight * point[1]) / H

            if prob > threshold :
                cv2.circle(frame, (int(x), int(y)), 8, (0, 255, 255), thickness=-1, lineType=cv2.FILLED)
                cv2.putText(frame, "{}".format(i), (int(x), int(y)), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, lineType=cv2.LINE_AA)

                # Add the point to the list if the probability is greater than the threshold
                points.append((int(x), int(y)))
            else :
                points.append(None)

        print(*points, sep = "\n")


备注:
RKNN_Toolkit2.1 中,也能输出三维数组,也就是说,2.1模型能输出Prob(可能性),但数值不准确,这点需要后续版本做好。

RKNN 模型
(184, 64)
(184, 80)
(152, 80)
(128, 104)
(96, 112)
(216, 72)
(240, 120)
(240, 168)
(184, 168)
(176, 224)
(192, 304)
(224, 168)
(240, 224)
(256, 280)
(176, 56)
(192, 48)
(168, 48)
(200, 48)



原有Openpose 模型
Keypoints - Nose : [(188, 60, 0.8160867)]
Keypoints - Neck : [(187, 77, 0.7589266)]
Keypoints - R-Sho : [(156, 83, 0.7545046)]
Keypoints - R-Elb : [(132, 107, 0.76606584)]
Keypoints - R-Wr : [(99, 117, 0.7454262)]
Keypoints - L-Sho : [(219, 76, 0.77488446)]
Keypoints - L-Elb : [(243, 124, 0.82001984)]
Keypoints - L-Wr : [(244, 171, 0.79118824)]
Keypoints - R-Hip : [(187, 171, 0.5874096)]
Keypoints - R-Knee : [(179, 228, 0.7373779)]
Keypoints - R-Ank : [(195, 307, 0.775934)]
Keypoints - L-Hip : [(227, 164, 0.6115459)]
Keypoints - L-Knee : [(244, 227, 0.82441866)]
Keypoints - L-Ank : [(260, 284, 0.72565466)]
Keypoints - R-Eye : [(180, 59, 0.82342505)]
Keypoints - L-Eye : [(195, 53, 0.8087529)]
Keypoints - R-Ear : [(171, 52, 0.8098956)]
Keypoints - L-Ear : [(203, 51, 0.61288214)]










欢迎光临 Toybrick (https://t.rock-chips.com/) Powered by Discuz! X3.3