SSD support for arbitrary shapes at prediction (without resize)
The single short detector is trained on fixed resolution images 300x300 or 512x512 but since the network doesn't include flattening or fully connected layers, it should be possible to do inference on arbitrary sizes without rescaling the input.
I was able to do that with the Tensorflow implementation but not with the MXNet one here. It doesn't crash and it looks like it detects the correct objects but the results are off:

My code change:
--- a/example/ssd/detect/detector.py
+++ b/example/ssd/detect/detector.py
@@ -35,8 +35,10 @@ class Detector(object):
if symbol is None:
symbol = load_symbol
self.mod = mx.mod.Module(symbol, label_names=None, context=ctx)
+
+ data_shape = (720, 1280)
self.data_shape = data_shape
- self.mod.bind(data_shapes=[('data', (batch_size, 3, data_shape, data_shape))])
+ self.mod.bind(data_shapes=[('data', (batch_size, 3, data_shape[0], data_shape[1]))])
self.mod.set_params(args, auxs)
self.data_shape = data_shape
self.mean_pixels = mean_pixels
Original image: http://data.1freewallpapers.com/download/cows-on-the-meadow-1280x720.jpg
cc @zhreshold
FYI, this is the result obtained with Tensorflow's implementation:

I would check the scaling of predictions. Looks like a display error
There is probably a scaling issue somewhere but the predictions coming out self.mod.predict are already cropped somehow:
[[ 9. 0.99957496 1. 1. 1. 1. ]
[ 9. 0.99943036 1. 1. 1. 1. ]
[ 9. 0.99912649 1. 1. 1. 1. ]
...,
[ 9. 0.15663669 1. 1. 1. 1. ]
[ 9. 0.15572004 1. 1. 1. 1. ]
[ 9. 0.15441671 1. 1. 1. 1. ]]
Ok, I found where the clipping was done: mx.contrib.symbol.MultiBoxDetection has an optional parameters clip. After setting it to False and scaling the detected rectangles correctly, I get the right results*:

Do you think it would be worth adding an option to the SSD example to do inference on original image sizes? I can prepare a pull request for that.
* I'm not sure what to think about the 3 false positives at the bottom.
@mmmikael What is the predictions without clipping? I suppose they are beyond 1s? If you can fix it, you are very welcome to do so, thanks.
@mmmikael What is the predictions without clipping? I suppose they are beyond 1s?
Yes, they are beyond 1s. To get back to image coordinates, the scaling is not anymore image width and height but the training size (300 or 512). It seems like something should be changed in MultiBoxDetection. Any idea?
If you want clip to work for original images, pass in clip range instead of true/false, and preserve the trained scaling (300, 512). The modification in MultiBoxDetection layer should be easy. @mmmikael
This helps me and I think that people want SSD to predict variant input size in practice. If it's convenient I hope you can add this feature in your implementation. @zhreshold
This will be solved in the new gluon object detection example that I'm working on.
@zhreshold Thanks.
I've tested variant input size for mxnet-ssd and I found that we just need fix a absolute anchor size(but not a relative anchor size, i.e. sizes in multibox_layer) for variant input size images to get the right result. @zhreshold
@chinakook There's not too much work to enable variant input size, however, it will break compatibility to the previous versions. That's the major reason I am reluctant to do so. If you are interested, we can set up a new branch on this fix, and release it in a proper time.
Yes, I know why's that and your viewpoint indeed. Maybe we can just write something about variant input size in README.md to issue this. @zhreshold
@apache/mxnet-committers: This issue has been inactive for the past 90 days. It has no label and needs triage.
For general "how-to" questions, our user forum (and Chinese version) is a good place to get help.
Can you please add the label 'Feature request' and 'Example' to this issue and remove 'Needs Triage'
@sandeep-krishnamurthy can we close out this issue actually? looks to have been addressed.
Checkout our new gluon-cv examples: https://gluon-cv.mxnet.io/build/examples_detection/demo_ssd.html#sphx-glr-build-examples-detection-demo-ssd-py
which fully support arbitrary shape images. I am closing this now.