#thanks to link:https://bbs.huaweicloud.com/blogs/180532
#http://github.com/deepinsight/insightface
# -*- coding: utf-8 -*-
import cv2
import torch
import numpy as np
import onnxruntime
# image to tensor
def img2tensor(image):
img = cv2.cvtColor(image , cv2.COLOR_BGR2RGB)
img = np.transpose(img, (2, 0, 1))
img = torch.from_numpy(img).unsqueeze(0).float().cuda()
img.div_(255).sub_(0.5).div_(0.5)
return img
# tensor to numpy
def to_numpy(tensor):
return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()
# create an inference
ort_session = onnxruntime.InferenceSession("partial_fc_glint360k_r50.onnx")
# load image
image = cv2.imread('../1.jpg')
img = img2tensor(image)
# inference
ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(img)}
f1 = ort_session.run(None, ort_inputs)[0] # array
emb = f1.reshape(512,)
f1 = emb / np.linalg.norm(emb)
# load image
image = cv2.imread('../2.jpg')
img = img2tensor(image)
# inference
ort_inputs = {ort_session.get_inputs()[0].name: to_numpy(img)}
f2 = ort_session.run(None, ort_inputs)[0] # array
emb = f2.reshape(512,)
f2 = emb / np.linalg.norm(emb)
print((f1*f1).sum())
sim = np.dot(f1, f2)
print("置信度:",sim)
没有合适的资源?快使用搜索试试~ 我知道了~
insightface-arcface onnx 推理代码和模型 partial-fc-glint360k-r50
共2个文件
py:1个
onnx:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 93 浏览量
2023-03-26
17:04:37
上传
评论
收藏 153.58MB ZIP 举报
温馨提示
insightface_arcface onnx 推理代码和模型 partial_fc_glint360k_r50
资源推荐
资源详情
资源评论
收起资源包目录
archface.zip (2个子文件)
insightface_onnx_feature.py 1KB
partial_fc_glint360k_r50.onnx 166.31MB
共 2 条
- 1
资源评论
图像处理大大大大大牛啊
- 粉丝: 1w+
- 资源: 79
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- anaconda mac安装包
- 简单介绍Scratch到python.docx
- 毕业设计基于LabView+MATLAB的说话人识别系统源码.zip
- 基于solr和协同过滤算法的构件检索与推荐系统+源代码+文档说明
- 详细描述了Delphi多线程编程,超级简单易懂
- 基于Pyqt5设计简易版水果识别系统源码.zip
- 课程设计基于Labview的转子动平衡测控系统源码+文档说明.zip
- mysql node.js 基于协同过滤美食推荐系统-数据库+源代码+文档说明
- 两种MovieLens数据集上电影推荐 三种协同过滤(item user svd分解)+源代码+文档说明
- excel.js插件可应用于微信小程序,H5对xlxs文件的操作
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功