inisis / brocolli Goto Github PK
View Code? Open in Web Editor NEWEverything in Torch Fx
License: MIT License
Everything in Torch Fx
License: MIT License
如题。。。
Traceback (most recent call last):
File "/media/3255035b-77ce-41e8-8665-808657363219/deep-learning/predict_floder.py", line 147, in
main()
File "/media/3255035b-77ce-41e8-8665-808657363219/deep-learning/predict_floder.py", line 104, in main
pytorch_parser.convert()
File "/home/miniconda3/envs/py39/lib/python3.9/site-packages/brocolli/converter/pytorch_caffe_parser.py", line 51, in convert
self.text_net, self.binary_weights = self.gen_ir()
File "/home/miniconda3/envs/py39/lib/python3.9/site-packages/brocolli/converter/pytorch_caffe_parser.py", line 363, in gen_ir
raise NotImplementedError(
NotImplementedError: method sqrt is not implemented
models.py中的f"conv_{module_i}“ 出现该错误,将f去掉即可
While I was trying to convert SSD300_vgg16 model to Caffe with phase = 'test' instead of 'export' I got the following error :
File "/root/brocolli/converter/pytorch/pytorch_caffe_parser.py", line 138, in gen_IR
node_type = layer_map[onnx_node_type]
KeyError: 'prim::PythonOp'
recently I research scnn model ,I have trained it with the pytorch ,now I am facing a question that I need to convert the pytorch model to caffe model ,I have tried the tools you recommend to me ,the scnn pytorch net link is :"https://github.com/harryhan618/SCNN_Pytorch "and the convert tool link is :"https://github.com/hahnyuan/nn_tools"
I use it to transform it ,the output error is like this:.....140674339123632:batch_norm_blob15 getting
relu15 was added to layers
140674339123704:relu_blob15 was added to blobs
Add blob relu_blob15 : torch.Size([1, 128, 36, 100])
140674339123704:relu_blob15 getting
:::x.shape::: torch.Size([1, 128, 36, 100])
conv16 was added to layers
140674339126368:conv_blob16 was added to blobs
Add blob conv_blob16 : torch.Size([1, 128, 1, 100])
Traceback (most recent call last):
File "example/scnn_pytorch_to_caffe.py", line 26, in
pytorch_to_caffe.trans_net(net,input,name)
File "./pytorch_to_caffe.py", line 716, in trans_net
out = net.forward(input_var)
File "./model.py", line 36, in forward
x = self.message_passing_forward(x)
File "./model.py", line 62, in message_passing_forward
x = self.message_passing_once(x, ms_conv, v, r)
File "./model.py", line 89, in message_passing_once
out.append(slices[i] + F.relu(conv(out[i - 1])))
The general meaning is when dealing with the slice operation error occors,can you help me to have a look at the question ,thank you
While trying to convert MMDetection SSD300 model the following error occurred:
TypeError: forward() missing 1 required positional argument: 'img_metas'
RuntimeError: Exporting the operator max_unpool2d to ONNX opset version 13 is not supported. Please feel free to request support or submit a pull request on PyTorch
I want to convert siamrpn which has two inputs to caffe , how to do it? thank you
大佬,后续会支持pytorch 1.0版本么
Urlopen error when downloading the mini imagenet dataset
@Inis 你好,我在转换模型时候报output 2 of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer.请问你有遇见过吗?
Dear sir :
I want to convert the scnn pytorch model to caffemodel,does your tool work?or can you give me some advice ,thank you !
老哥,有个问题,其实在pytorch_model_converter里的pytorch_parser.run(model_file)之后,ssd的caffemodel和prototxt就已经生成了。
后面为什么要再跑ssd_layer.py example.json pytorch_model/best.pth.prototxt new.prototxt ,其中example.json文件是起什么作用呢。
多谢。
RuntimeError: Exporting the operator linalg_norm to ONNX opset version 13 is not supported. Please feel free to request support or submit a pull request on PyTorch GitHub.
你好,请问ssd.py文件的下载链接哪里有呀
up主您好,如果我想要把您仓库的代码进行扩充,令其可以实现 LSTM 神经网络的量化,并且想把量化后的 LSTM 层放到 GPU 上进行推理加速。
在技术上这是否是可行的呢?如果可行的话,up 您可以大致分享以下实现路线吗?我也想为您的项目添砖加瓦
1.win10/11情况下,需要删除dataloader的 num_workers=8
否则会出以下错
E AttributeError: Can't pickle local object 'test_mnist..MNISTCHINA'
2.#121 pytorch_quantizer.prepare()改成 pytorch_quantizer.prepare_calibration()
Traceback (most recent call last):
File "/media/3255035b-77ce-41e8-8665-808657363219/deep-learning/predict_floder.py", line 147, in
main()
File "/media/3255035b-77ce-41e8-8665-808657363219/deep-learning/predict_floder.py", line 104, in main
pytorch_parser.convert()
File "/home/miniconda3/envs/py39/lib/python3.9/site-packages/brocolli/converter/pytorch_caffe_parser.py", line 51, in convert
self.text_net, self.binary_weights = self.gen_ir()
File "/home/miniconda3/envs/py39/lib/python3.9/site-packages/brocolli/converter/pytorch_caffe_parser.py", line 396, in gen_ir
raise NotImplementedError(
NotImplementedError: method pow is not implemented
Hi, when i run the demo
from brocolli.converter.pytorch_onnx_parser import PytorchOnnxParser
model = models.resnet18(pretrained=False)
x = torch.rand(1 ,3 ,224, 224)
runner = PytorchOnnxParser(model, x)
runner.convert()
runner.save("resnet18.onnx")
runner.check_result()
it tell me:
---> 36 self.input_shape = map_replace(input_shape, get_torch_size)
/opt/conda/lib/python3.7/site-packages/brocolli/converter/utils.py in map_replace(args, fn)
44 return list(map_replace(elem, fn) for elem in args)
45 else:
---> 46 return fn(args)
/opt/conda/lib/python3.7/site-packages/brocolli/converter/utils.py in get_torch_size(obj)
25
26 def get_torch_size(obj):
---> 27 return torch.Size(obj)
TypeError: torch.Size() takes an iterable of 'int' (item 0 is 'Tensor')
i wonder what cause the problem
hi,
i want to test your code and then convert my model.but i could not find your "test_pytorch.py" file. and may some errors:No module named model.classifier.could you tell me how to solve this problem? thanks
Dear sir :
I want to convert the scnn pytorch model to caffemodel,does your tool work?or can you give me some advice ,thank you !
This is very good work, I would like to ask if the efficientnet will be supported?
大佬,请问ssd.py在哪个链接下载,能给个链接吗,没找到
Something wrong about "align_corners" in function "upsample".
Detail:
TypeError: upsample_bilinear2d() got an unexpected keyword argument 'align_corners' (occurred when translating upsample_bilinear2d)
http://120.224.26.73:15030 地址无法访问,麻烦大佬看看
Traceback (most recent call last):
File "/self/pytorch_quan/brocolli-master/brocolli/converter/pytorch_onnx_parser.py", line 13, in
from .onnx_layers import *
ImportError: attempted relative import with no known parent package
While trying to convert the YOLOv5 model, I'm getting KeyError for 'onnx:ScatterND', 'onnx:Range', 'onnx:Expand', 'onnx:Where' and 'onnx:Equal'. Could you please help me on how to get rid this error? I have got the same error when tried with the docker image also.
我编译安装了https://github.com/inisis/caffe.git过后,在brocolli/tests下运行 pytorch_model_converter.py出现No module named 'ssd'的错误,import caffe是成功的,请问应该怎么解决呀?
$ python3 pytorch_model_converter.py
Traceback (most recent call last):
File "pytorch_model_converter.py", line 19, in
from ssd import *
ModuleNotFoundError: No module named 'ssd'
free(): invalid pointer
Aborted (core dumped)
调试的时候,运行到pytorch_parser.run(model_file)报错:
pytorch_parser.run(model_file)
text_net,binary_weight = self.genIR()
layer-data=fun(current_node)
weight = self.state_dict[weight_name]
keyerror: '.weight'
您知道问题出在哪里吗?
我的环境是:torch0.4
numpy'1.14.3'(这个和要求的不一样)
need support onnxruntime 1.15.1
当前的master分支的代码在运行ptq_example.py的时候会出现如下问题
Traceback (most recent call last):
File "/home/p4ai/model_test/test/brocolli/ptq_example_402.py", line 126, in <module>
pytorch_quantizer.convert()
File "/home/p4ai/model_test/test/brocolli/brocolli/quantization/quantizer.py", line 359, in convert
quantized = Linear.from_float(module)
File "/home/p4ai/model_test/test/brocolli/brocolli/quantization/quantization_layers/linear.py", line 55, in from_float
qlinear.act_scale = torch.Tensor(act_scale).to(qweight.device)
IndexError: slice() cannot be applied to a 0-dim tensor.
环境为python 3.9;使用cpu;pytorch版本为1.9.0+cu102;
Thank you for sharing such an excellent open source component!
I encountered a problem:
File "/pycode/brocolli/brocolli/converter/pytorch_caffe_parser.py", line 51, in convert
self.text_net, self.binary_weights = self.gen_ir()
File "/pycode/brocolli/brocolli/converter/pytorch_caffe_parser.py", line 230, in gen_ir
raise NotImplementedError("module %s is not implemented" % (module))
NotImplementedError: module InstanceNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=False) is not implemented
May I ask how to handle it?
Hi, I'm newer to use caffe, so when I run this project some problem comes out. There is no ssd directory or package in project, so whether it's code by author or need to install ? confusions
hello,使用的是你提供的docker环境,
需要转换的模型是语义分割任务,上采样时使用的是:self.upsample = nn.Upsample(scale_factor=scale_factor, mode="bilinear", align_corners=False)。
在转caffe时使用下面的代码调用的你接口:
runner = Runner("parsing_net", model, [1, 3, 480, 640], 13, fuse=True)
runner.pyotrch_inference()
runner.convert()
runner.caffe_inference()
runner.check_result()
I was trying to convertYOLOx-Darknet53 and got the KeyError: 'onnx::Range'.
I tried with the latest docker image. Doesn't it support conversion of YOLOX- Darknet53?
hello ,有遇到过这个问题不??
pytorch_graph.py->extract()->line 130
因为不在同一台电脑,以上是出问题的定位,请见谅
output = self.detect(
loc.view(loc.size(0), -1, 4), # loc preds
self.softmax(conf.view(conf.size(0), -1,
self.num_classes)), # conf preds
self.priors.type(type(x.data.type())) # default boxes
)
output 2 of traced region did not have observable data dependence with trace inputs; this probably indicates your program cannot be understood by the tracer.
but when I Modify the code
output = (
loc.view(loc.size(0), -1, 4), # loc preds
self.softmax(conf.view(-1, self.num_classes)), # conf preds
)
Traceback (most recent call last):
File "/home/zt/brocolli-master/tests/pytorch_model_converter.py", line 55, in
pytorch_parser.run(model_file)
File "/home/zt/brocolli-master/converter/core/parser.py", line 18, in run
text_net, binary_weights = self.gen_IR()
File "/home/zt/brocolli-master/converter/pytorch/pytorch_parser.py", line 126, in gen_IR
layer_data = func(current_node)
File "/home/zt/brocolli-master/converter/pytorch/pytorch_parser.py", line 228, in rename_Conv
weight = self.state_dict[weights_name]
KeyError: 'base.weight'
Please help me.
您好,inisis,您的工程非常不错,我的问题如下:1、您工程里支持的版本是0.4.0,我的pytorch项目中包含upsample layer ,torch.onnx.export()貌似不支持upsample,但是我现在用的最新版1.3可以导出,您的建议是什么呢?2、我的工程结构类似于retinanet,不知道您的项目能否完美转换。很期待您的解惑,谢谢!
Hi ,Thank you for your wonderful and impressive project! seen the test/quantization/test_quanzation_nets.py use the cpu to load nets and datasets, I'd like follow your idea to trace my model and quantizate with GPU ways,but when i set model.cuda() and use the input_data.cuda() then the error raised:RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
then go to the erro raised location: dummy_input = self.gen_input_tensor(self.input_shape)
def gen_input_tensor(self, shapes):
input_tensor = []
for shape in shapes:
if isinstance(shape, (tuple, list)):
if all(isinstance(element, int) for element in shape):
input_tensor.append(torch.rand(shape).to(torch.float32))
else:
input_tensor.append(self.gen_input_tensor(shape))
else:
input_tensor.append(torch.rand(shape).to(torch.float32))
return input_tensor
is this func determine the inputs's type from my origin "input_data.cuda()" to other kind types that finally caused the error?
and would pls tell some details about how to use your demo with our own datasets and nets in a GPU way?
thank you very much!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.