Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to removed the Slice operation and replaced the input with a downscaled image and stacked it to match the channel number? #2

Open
huolianchu opened this issue Jun 24, 2020 · 6 comments

Comments

@huolianchu
Copy link

Hi,

Thanks for you work

i using my own trained model file will report error
Slice operation in .pt or in .onnx?

@miziha-zp
Copy link

more details needed as you

@sunnyden
Copy link
Owner

ONNX converts the operation of line 87 in common.py

return self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))

into a slice operation with steps.

The easiest way to eliminate the slice operation is to change this line into:

return self.conv(torch.cat([x,x,x,x], 1))

It is also possible to change this operation into a convolution operation.

@huolianchu
Copy link
Author

ONNX converts the operation of line 87 in common.py

return self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))

into a slice operation with steps.

The easiest way to eliminate the slice operation is to change this line into:

return self.conv(torch.cat([x,x,x,x], 1))

It is also possible to change this operation into a convolution operation.

Thanks a lot

@tadejj
Copy link

tadejj commented Jul 9, 2020

Hi,
Can I remove slice operation for trained model? I have trained my custom dataset, and converted it to pytorchscript. But the result is afwul (all boxes are wrong). Can I use models/onnx_export.py from ultralytics for my model and remove slice operation without retraining?
Thank you so much

@sunnyden
Copy link
Owner

sunnyden commented Jul 10, 2020 via email

@tadejj
Copy link

tadejj commented Jul 13, 2020

Of course, you can remove the slice operation without retraining.

On Thu, Jul 9, 2020, 16:17 tadejj @.***> wrote: Hi, Can I remove slice operation for trained model? I have trained my custom dataset, and converted it to pytorchscript. But the result is afwul (all boxes are wrong). Can I use models/onnx_export.py from ultralytics for my model and remove slice operation without retraining? Thank you so much — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#2 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABA7OF5ZBMCCCBZNXUXWFPTR2V4JDANCNFSM4OGM3S4A .

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants