Code Monkey home page Code Monkey logo

brocolli's Introduction

Welcome to my github 👋

inisis's github stats

brocolli's People

Contributors

athony-neo avatar deadpoppy avatar dependabot[bot] avatar inisis avatar nihui avatar qiaolian9 avatar shiwenloong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brocolli's Issues

NotImplementedError: method sqrt is not implemented

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

Attempted to trace Detect, but tracing of legacy functions is not supported


Traceback (most recent call last):
File "pytorch_model_converter.py", line 51, in
pytorch_parser = PytorchParser(model_file, [3, 300, 300])
File "/brocolli/tests/../converter/pytorch/pytorch_parser.py", line 104, in init
self.pytorch_graph.build(self.input_shape)
File "/brocolli/tests/../converter/pytorch/pytorch_graph.py", line 115, in build
trace, output = torch.jit.get_trace_graph(self.model, (dummy_input, ))
File "/usr/lib/python3.5/contextlib.py", line 77, in exit
self.gen.throw(type, value, traceback)
File "/brocolli/tests/../converter/pytorch/pytorch_graph.py", line 100, in set_training
yield
File "/brocolli/tests/../converter/pytorch/pytorch_graph.py", line 115, in build
trace, output = torch.jit.get_trace_graph(self.model, (dummy_input, ))
File "/usr/local/lib/python3.5/dist-packages/torch/jit/init.py", line 255, in get_trace_graph
return LegacyTracedModule(f, nderivs=nderivs)(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/torch/jit/init.py", line 288, in forward
out = self.inner(*trace_inputs)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 489, in call
result = self._slow_forward(*input, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 479, in _slow_forward
result = self.forward(*input, **kwargs)
File "/brocolli/tests/ssd.py", line 163, in forward
self.priors.type(x.data.type()) # default boxes
RuntimeError: Attempted to trace Detect, but tracing of legacy functions is not supported

how to convert pytorch model to caffe model?

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

PytorchParser报错

@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.请问你有遇见过吗?
image

关于example.json的疑问

老哥,有个问题,其实在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文件是起什么作用呢。

多谢。

关于仓库量化能力扩充(LSTM 的询问)

up主您好,如果我想要把您仓库的代码进行扩充,令其可以实现 LSTM 神经网络的量化,并且想把量化后的 LSTM 层放到 GPU 上进行推理加速。
在技术上这是否是可行的呢?如果可行的话,up 您可以大致分享以下实现路线吗?我也想为您的项目添砖加瓦

test_quanzation_nets 报错解决

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()

NotImplementedError: method pow is not implemented

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

TypeError: torch.Size() takes an iterable of 'int' (item 0 is 'Tensor')

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

how to test your code

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

efficientnet?

This is very good work, I would like to ask if the efficientnet will be supported?

ssd.py 找不到

大佬,请问ssd.py在哪个链接下载,能给个链接吗,没找到

pytorch transform error

Something wrong about "align_corners" in function "upsample".

Detail:
TypeError: upsample_bilinear2d() got an unexpected keyword argument 'align_corners' (occurred when translating upsample_bilinear2d)

KeyError: 'onnx:ScatterND' YOLOv5 conversion

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.

ssd转caffe报错: keyerror: '.weight'

调试的时候,运行到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'(这个和要求的不一样)

关于ptq_example的问题

当前的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;

NotImplementedError: module InstanceNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=False) is not implemented

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?

ImportError: No module named 'ssd'

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

(Occurred when translating upsample_bilinear2d).

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()

会报下面的错误,是不是不支持双线性插值上采样呢?
1648814476(1)

errors in using pytorch_model_converter.py

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.

pytorch版本以及upsample问题

您好,inisis,您的工程非常不错,我的问题如下:1、您工程里支持的版本是0.4.0,我的pytorch项目中包含upsample layer ,torch.onnx.export()貌似不支持upsample,但是我现在用的最新版1.3可以导出,您的建议是什么呢?2、我的工程结构类似于retinanet,不知道您的项目能否完美转换。很期待您的解惑,谢谢!

How to use the quantizers with CUDA?

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.