mediapipe onnx测试

本文主要介绍了在 Mediapipe 框架中使用 ONNX 进行计算机视觉测试的过程。通过 ONNX 导出模型并进行运行测试,以验证其在图像处理任务中的准确性和效率。
摘要由CSDN通过智能技术生成

onnx测试

   img_path=r'D:\data\val_result\1212\test\1\2\02370_1.jpg'

    img=cv2.imread(img_path)

    img_o = cv2.resize(img, (192, 192))
    img=cv2.cvtColor(img_o,cv2.COLOR_BGR2RGB)
    img = img.astype(np.float32)
    # img=img-127.5
    img/=255.0

    # dummy_input = np.ones([1, 192, 192, 3], dtype=np.float32)
    dummy_input = np.array([img])
    model_path = r'E:\project\angle_net\xuanzhuan_detect\ncnn-20220420-windows-vs2017\x64\bin/model_float32.onnx'
    # model_path = r'C:\Users\Administrator\Pictures\mm\resources.tar\resources\face_landmark_with_attention_192x192/model_float32.onnx'
    model_file_name = model_path.split(".")[0]
    session_option = onnxruntime.SessionOptions()
    session_option.optimized_model_filepath = f"{model_file_name}_cudaopt.onnx"
    session_option.graph_optimization_level = onnxruntime.Graph
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据提供的引用内容,可以了解到MediaPipe是一个用于构建基于机器学习的应用程序的框架,而mediapipe测试程序则是基于python+mediapipe的手势拖动识别程序。该程序主要包括手掌检测模型、手部地标模型、运行环境及运行方法、运行效果图等内容。其中,手掌检测模型和手部地标模型是该程序的核心部分,用于检测手掌和手指的位置和姿态,从而实现手势的识别和控制。运行环境及运行方法部分介绍了如何配置和运行该程序,而运行效果图则展示了该程序的实际效果。 代码示例: ```python # 导入MediaPipeOpenCV库 import mediapipe as mp import cv2 # 初始化MediaPipe的手部检测模型和手部地标模型 mp_hands = mp.solutions.hands mp_drawing = mp.solutions.drawing_utils hands = mp_hands.Hands(static_image_mode=False, max_num_hands=2, min_detection_confidence=0.5, min_tracking_confidence=0.5) # 打开摄像头 cap = cv2.VideoCapture(0) while cap.isOpened(): # 读取摄像头数据 success, image = cap.read() if not success: break # 将图像转换为RGB格式并进行手部检测和地标识别 image = cv2.cvtColor(cv2.flip(image, 1), cv2.COLOR_BGR2RGB) results = hands.process(image) # 绘制手部地标和连接线 if results.multi_hand_landmarks: for hand_landmarks in results.multi_hand_landmarks: mp_drawing.draw_landmarks(image, hand_landmarks, mp_hands.HAND_CONNECTIONS) # 显示图像 cv2.imshow('MediaPipe Hands', image) if cv2.waitKey(5) & 0xFF == 27: break # 释放资源 hands.close() cap.release() cv2.destroyAllWindows() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值