sunnyden / YOLOV5_NCNN_Android

YOLOv5 C++ Implementation on Android using NCNN framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

huolianchu opened this issue · comments

Hi,

Thanks for you work

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

more details needed as you

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.

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

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

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!