1 Star 0 Fork 0

Di/Pytorch_Retinaface

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
genwts.py 983 Bytes
一键复制 编辑 原始数据 按行查看 历史
wangxinyu 提交于 2020-04-09 18:24 . update genwts
import torch
from torch import nn
import torchvision
import os
import struct
#from torchsummary import summary
def main():
print('cuda device count: ', torch.cuda.device_count())
device = 'cuda:1'
net = torch.load('retinaface.pth')
net = net.to(device)
net.eval()
print('model: ', net)
#print('state dict: ', net.state_dict().keys())
tmp = torch.ones(1, 3, 384, 640).to(device)
print('input: ', tmp)
out = net(tmp)
print('output:', out)
if os.path.exists('retinaface.wts'):
return
f = open("retinaface.wts", 'w')
f.write("{}\n".format(len(net.state_dict().keys())))
for k,v in net.state_dict().items():
print('key: ', k)
print('value: ', v.shape)
vr = v.reshape(-1).cpu().numpy()
f.write("{} {}".format(k, len(vr)))
for vv in vr:
f.write(" ")
f.write(struct.pack(">f", float(vv)).hex())
f.write("\n")
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tulipdi/Pytorch_Retinaface.git
git@gitee.com:tulipdi/Pytorch_Retinaface.git
tulipdi
Pytorch_Retinaface
Pytorch_Retinaface
master

搜索帮助