ncnn [pnnx] stylegan2-pytorch-cpu转换出错 (pt正常)

jxct1oxe  于 2022-10-22  发布在  其他
关注(0)|答案(4)|浏览(232)

error log | 日志或报错信息 | ログ

pnnxparam = /content/g_bb.pnnx.param
pnnxbin = /content/g_bb.pnnx.bin
...
device = cpu
inputshape = [1,512]f32
inputshape2 =
customop =
moduleop =
terminate called after throwing an instance of 'torch::jit::ErrorReport'
terminate called recursively

context | 编译/运行环境 | バックグラウンド

colab cpu

how to reproduce | 复现步骤 | 再現方法

  1. 使用 stylegan2-pytorch-cpu
  2. 命令 /content/pnnx /content/g_bb.pt inputshape=[1,512]f32
  3. pt文件

more | 其他 | その他

pt文件应该正常, 使用

!wget https://github.com/Klanly/buildcv/releases/download/100.200/g_bb.pt
import torch
model = torch.jit.load("g_bb.pt")

import numpy as np
x = torch.rand(1,512)

img=model(x)

from PIL import Image
Image.fromarray(np.transpose((img[0].detach().numpy()+1)*127.5,(1,2,0)).astype(np.uint8))

在colab cpu上可得正常图

========
mmgeneration 的 stylegan2,
用 pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.12.0/index.html

stylegan2.zip
同样的问题

whlutmcx

whlutmcx1#

如果是libtorch版本问题麻烦也看看这个 (要多开一个issue吗?):
lutzroeder/netron#932
https://github.com/lutzroeder/netron/files/9147239/min-dalle-bart-dec_mini.pt.zip

命令:
!/content/pnnx '/content/min-dalle-bart-dec_mini.pt' inputshape=[3]f32,[2,64]i32,[2,64,1024]f32,[12,4,256,1024]f32,[1]i32,[1]i32
报错信息:

Load torchscript failed: version_ <= kMaxSupportedFileFormatVersionINTERNAL ASSERT FAILED at "../caffe2/serialize/inline_container.cc":147, please report a bug to PyTorch. Attempted to read a PyTorch file with version 10, but the maximum supported version for reading is 6. Your PyTorch installation may be too old.

ms与exp_()和multinomial()有关

=================
同类问题:

bart_enc_mega.zip

bart_dec_mega.zip

上面data/里null掉了, 完整权重在:
https://drive.google.com/uc?export=download&id=1V0kcScUxFU-9-vEQQzaZvGDMfcJJbaED
https://drive.google.com/uc?export=download&id=1TAtjMPIOgnGaLqWbx6MV-2NzMOt72LgA
解压后约10G, 重新用zip打包后改后缀为.pt

t

ukqbszuj

ukqbszuj2#

再一条issue, libtorch的MKLDNN在colab的linux上狂吃内存, 我是加了这几条 (哪条起作用不明)

os.environ["USE_MKLDNN"] = "0"
os.environ["LRU_CACHE_CAPACITY"] = "1"
torch.set_grad_enabled(False)
torch.backends.mkldnn.set_flags(False)

才把stylegan2 trace完的, pnnx也有同样的问题, 能改的话最好改掉.

hc2pp10m

hc2pp10m3#

可以试试 https://github.com/miemie2013/ncnn
这个仓库实现了ncnn的stylegan2ada和stylegan3

np8igboo

np8igboo4#

可以试试 https://github.com/miemie2013/ncnn 这个仓库实现了ncnn的stylegan2ada和stylegan3

ty, 不过主要想用pyncnn, 自己写自定义层有点难度...

相关问题