Open zjbaby opened 6 years ago
I don't think you could change the input dimensions on the fly. You'll have to train a model of 240x240 yourself.
@YijinLiu mobilenet ssd的caffe模型是支持任意输入size的,是不是因为tensorflow官网提供的模型,在训练的时候,就固定了只能输入300x300?,如果我要用240x240的尺寸,我必须得重新训练一个tensorflow的模型,是吗? 我能在tensorflow官网提供的模型上,再做点什么,来让它可以支持任意尺寸的输入吗?
@zjbaby I don't know about Caffe. Do you mean if you give Caffe a smaller image, inference will take less time? Tensorflow SSD model does support resizing the input. It won't affect the inference speed since what it does is essentially resizing the image.. As far as I can tell, tflite doesn't support this. You'll have to resize the image yourself. It may cause loss of accuracy if the aspect ratio of your image is not same as the model.
@YijinLiu Thank you for your apply!~~~ As you understand, I can reduce the inpute size to reduce inference time when I use the tensorflow SSD model and caffe SSD model in opencv. so I can do much testing and find a right input size to balance the speed and the accuracy, because the main problem for me now is the speed, not the accracy. however, when I change the input size manully using "interpreter_->ResizeInputTensor()" api, the operation is wrong. And I don't know what I should do to make it work correctly
@YijinLiu 大神,我还是希望能用tensorflow lite实现这样的功能:网络的输入尺寸是可变的,即在使用模型推理时,我可以设置不同的网络输入尺寸。 我现在正在尝试重新训练 mobilenet ssd模型,使用教程:https://medium.com/tensorflow/training-and-serving-a-realtime-mobile-object-detector-in-30-minutes-with-cloud-tpus-b78971cf1193 如果我只是更改 image_resizer { fixed_shape_resizer { height: 300 width: 300 } } 中的height和width参数的话,它仍然是个固定尺寸,并不能达到我想要的目的,那我需要做些什么来实现可更改的网络输入尺寸呢?比如在训练的config文件中,有没有不固定输入尺寸的参数设置;或者是网络的哪一层,让尺寸不匹配了,然后我可以移除掉这一层,同时在推理完成后,重写代码来解析检测框。 由于刚接触深度学习和tensorflow,比较困惑,还希望能指导一下,非常感谢!~
@YijinLiu @camect Hi , I test mobilenet ssd model which downloaded from "https://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip"
and I try to change net input size for faster speed by the following code: `
but i got an error: resize input tensor: ( 1 240 240 3 ) tensorflow/contrib/lite/kernels/reshape.cc:58 num_input_elements != num_output_elements (2700 != 4332) Node number 36 (RESHAPE) failed to prepare.
Failed to allocate tensors!
Am I wrong? what should I do if I want to change net input size arbitrarily?