onnx / onnx/models

Error while using the yolo2_onnx model

Open
#122 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

When I try this :
from Inference import Inference

b = Inference(modelName="yolo2",backend='tensorflow', device='CPU')
str_, time_cost = b.predict()

I get the following error:

Onnx file export [./onnx/yolo2.onnx]...start
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/hi/Desktop/bp/onnx/yolo2_onnx/test4.py', wdir='C:/Users/hi/Desktop/bp/onnx/yolo2_onnx')

File "C:\Users\hi\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)

File "C:\Users\hi\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/hi/Desktop/bp/onnx/yolo2_onnx/test4.py", line 3, in
b = Inference(modelName="yolo2",backend='tensorflow', device='CPU')

File "C:\Users\hi\Desktop\bp\onnx\yolo2_onnx\Inference.py", line 27, in init
self.prepare_model_and_backend()

File "C:\Users\hi\Desktop\bp\onnx\yolo2_onnx\Inference.py", line 35, in prepare_model_and_backend
self.is_obj_det, self.w_img, self.h_img = ONNX.save_pretrained_model_to_ONNX(self.modelName)

File "C:\Users\hi\Desktop\bp\onnx\yolo2_onnx\Onnx.py", line 96, in save_pretrained_model_to_ONNX
self.onnx_file_export(m, onnxfilepath)

File "C:\Users\hi\Desktop\bp\onnx\yolo2_onnx\Onnx.py", line 54, in onnx_file_export
torch.onnx.export(model, dummy_input, onnxfilepath )

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\onnx_init_.py", line 26, in export
return utils.export(*args, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 94, in export
operator_export_type=operator_export_type)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 226, in _export
example_outputs, propagate)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 177, in _model_to_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args, training)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\onnx\utils.py", line 144, in _trace_and_get_graph_from_model
trace, torch_out = torch.jit.get_trace_graph(model, args)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\jit_init_.py", line 77, in get_trace_graph
return LegacyTracedModule(f)(*args, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 475, in call
result = self._slow_forward(*input, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 455, in _slow_forward
return self.forward(*input, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\jit_init_.py", line 109, in forward
out = self.inner(*trace_inputs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 475, in call
result = self._slow_forward(*input, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 465, in _slow_forward
result = self.forward(*input, **kwargs)

File "C:\Users\hi\Desktop\bp\onnx\yolo2_onnx\darknet.py", line 91, in forward
x = self.modelsind

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 475, in call
result = self._slow_forward(*input, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 465, in _slow_forward
result = self.forward(*input, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\container.py", line 91, in forward
input = module(input)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 475, in call
result = self._slow_forward(*input, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 465, in _slow_forward
result = self.forward(*input, **kwargs)

File "C:\Users\hi\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 301, in forward
self.padding, self.dilation, self.groups)

TypeError: 'float' object cannot be interpreted as an integer

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the yolo2 path from Inference.py:27-35 and follow the export from Onnx.py:54 and :96 into darknet.py:91. Start with the torch.onnx.export call and the convolution traceback, then verify that model export completes without the reported TypeError and that the shown predict call proceeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.