Comments (3)
@haiyang-tju
maybe you need to fix input image size, then you can change here .
replace *.size() to [int,int] or use scale_factor
from centernet-condinst.
Thanks for your reply. @CaoWGG
I searched and tried many options, and there is no good solutions. One painful way is to edit the parameter align_corners=False
, and with the default opset_version
. And this will give two UserWarnings, I don't know if it will actually have an impact.
UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
:undefined
"See the documentation of nn.Upsample for details.".format(mode))
torch.onnx.export(model, input, "./bb.onnx", export_params=True)
None
***/lib/python3.6/site-packages/torch/onnx/symbolic_helper.py:198: UserWarning: You are trying to export the model with onnx:Upsample for ONNX opset version 9. This operator might cause results to not match the expected results by PyTorch.
:undefined
ONNX's Upsample/Resize operator did not match Pytorch's Interpolation until opset 11. Attributes to determine how to transform the input were added in onnx:Resize in opset 11 to support Pytorch's behavior (like coordinate_transformation_mode and nearest_mode).
We recommend using opset 11 and above for models using this operator.
"" + str(_export_onnx_opset_version) + ". "
And maybe this can solve the error.
pytorch/pytorch#22906 (comment)
from centernet-condinst.
Reference here, I made a custom layer with double upsampling. And it can be successfully exported to onnx.
class resize_bilinear(nn.Module):
def __init__(self, in_shape):
super(resize_bilinear, self).__init__()
self.in_shape = in_shape
self.rhw = 2
self.out_shape = self.in_shape*self.rhw
self.cal_parameters()
def cal_parameters(self):
y = torch.arange(self.out_shape, dtype=torch.float32)
ty = (y + 1) / self.rhw + 0.5 * (1 - 1.0 / self.rhw) - 1
zero = torch.zeros([1])
ty = torch.max(ty, zero)
ty_floor = ty.floor()
ty_ceil = ty.ceil()
dy = ty - ty_floor
dydy = dy.view(-1,1) * dy.view(-1)
iy0 = ty_floor.long()
iy1 = torch.clamp(ty_ceil,0,self.in_shape-1).long()
self.iy0 = nn.Parameter(iy0, requires_grad=False)
self.iy1 = nn.Parameter(iy1, requires_grad=False)
self.dy = nn.Parameter(dy, requires_grad=False)
self.dydy = nn.Parameter(dydy, requires_grad=False)
def forward(self, x):
if x is None:
return x
im_iy0 = x.index_select(2, self.iy0)
im_iy1 = x.index_select(2, self.iy1)
d = im_iy0.index_select(3, self.iy0) * (1 - 2*self.dy + self.dydy) + \
im_iy1.index_select(3, self.iy0) * (self.dy - self.dydy) + \
im_iy0.index_select(3, self.iy1) * (self.dy - self.dydy) + \
im_iy1.index_select(3, self.iy1) * self.dydy
return d
from centernet-condinst.
Related Issues (18)
- Is this repo the one in arxiv 1911.06667? HOT 3
- Is it a bug, I think we may not need to mutiply 2? HOT 1
- How to train cocodataset
- Model Release HOT 1
- 关于CenterNet后接segmentation的请教 HOT 1
- Is the mean and variance of the coco dataset calculated?
- instance_masks的大小每张图不一样,最后如何组batch的勒?
- 关于运行时间的问题
- segmentation image size
- Why did it stay in the'' Starting Training ''interface and then automatically exit,为什么他停留在starting training后就不动了
- mask生成是完全基于yolact的**吗 HOT 8
- `ransform_segs` in the `utils.image` did not upload to the repo. HOT 4
- Please upload your opts.py to this repo.
- do you use FPN?
- nothing
- 关于效果展示 HOT 1
- 准确率问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from centernet-condinst.