Comments (1)
- Convert pytorch model to onnx
import os
import io
import numpy as np
import argparse
import torch.onnx
from torchkit.backbone import get_model
from torchkit.util.utils import l2_norm
parser = argparse.ArgumentParser(description='export pytorch model to onnx')
parser.add_argument('--ckpt_path', default=None, type=str, required=True, help='')
parser.add_argument('--onnx_name', default=None, type=str, required=True, help='')
parser.add_argument('--model_name', default=None, type=str, required=True, help='')
args = parser.parse_args()
def main():
net = get_model(args.model_name)
input_size = [112, 112]
embedding_size = 512
torch_model = net(input_size)
if not os.path.isfile(args.ckpt_path):
print("Invalid ckpt path: %s" % args.ckpt_path)
return
torch_model.load_state_dict(torch.load(args.ckpt_path))
torch_model.eval()
batch_size = 1
x = torch.randn(batch_size, 3, input_size[0], input_size[1], requires_grad=True)
torch_out = torch_model(x)
torch_out = l2_norm(torch_out)
torch.onnx.export(torch_model,
x,
"%s.onnx" % args.onnx_name,
export_params=True,
opset_version=10,
do_constant_folding=True,
input_names = ['input'],
output_names = ['output'])
print("finished")
if __name__ == '__main__':
main()
- Convert onnx to TNN model
please refer to tnn guide https://github.com/Tencent/TNN/blob/master/doc/en/user/convert_en.md
from tface.
Related Issues (20)
- The use of landmark HOT 2
- How make it converge to a very low loss?
- ekd's result is satisfactory
- del
- 为了训练人脸识别模型,准备数据时img2tfrecord.py需要5p file,可以提供一个工具生成5p file吗? HOT 1
- 执行generate_pseudo_labels/gen_pseudo_labels.py到了GENERATE NEGATIVE PAIRS时,没有任何进展一直显示0% HOT 1
- quality/generate_pseudo_labels/gen_pseudo_labels.py中用到的数据集/data/home/fuzhaoou/Dataset/MS1M/MS1M_arcface_112,可以给一个下载地址吗? HOT 1
- The two papers have inconsistencies in their explanations of DC
- M3DFEL model checkpoints for inference
- ANRL代码问题咨询
- 请问是否有支持224尺寸输入的人脸识别预训练模型?
- M3DFEL的FLOPs
- Problems with STIL test results HOT 2
- Root to Privacy-Preserving Face Recognition Using Random Frequency Components HOT 2
- STIL how to train on the other datasets. HOT 1
- 为什么四种伪造方法训练结果一样? HOT 1
- TypeError: expected Tensor as element 2 in argument 0,but got NoneType
- hello,ckpt_path,Is it not provided?
- please offer the .pkl file of STIL
- M3DFEL论文结果无法复现 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tface.