Mobilenet SSD Input Image Size

血红的双手。 提交于 2019-12-23 10:10:22

问题


I would like to train a Mobilenet SSD Model on a custom dataset.

I have looked into the workflow of retraining a model and noticed the image_resizer{} block in the config file:

https://github.com/tensorflow/models/blob/d6d0868209833e014074d6cb4f32558e7acf2a6d/research/object_detection/samples/configs/ssd_mobilenet_v1_pets.config#L43

Does the aspect ratio here have to be 1:1 like 300x300 or can I specify a custom ratio?

All my dataset images are 960x256 - so could I just input this size for height and width? Or do I need to resize all the images to have an aspect ratio of 1:1?


回答1:


Choose the height and width, in the model file (as per your link), to be the shape of the input image at which you want your model to train and operate. The model will resize input images to the specified size, if it has to.

So this could be the size of your input images (if your hardware can train and operate a model at that size):

image_resizer {
    fixed_shape_resizer {
        height: 256
        width: 960
    }
}

The choice will depend on the size of the training images and the resources required to train (and use) that size of model.

I typically use 512x288 as this size model runs happily on a Raspberry Pi. I prepare training images, at a variety of scales, at exactly this size. So the image resizer does no work during training.

For inference, I input images at 1920x1080, so the image resizer scales them to 512x288 before they pass into the Mobilenet, maintaining the aspect ratio.

However, the aspect ratio is not important in my domain since such distortions occur naturally.

So yes, just use your training image dimensions.




回答2:


If you keep is as it is the network will resize your input images to 300x300 regardless the actual size of your images. An other thing you can try is replace the image_resizer block with the below change:

image_resizer 
{
  keep_aspect_ratio_resizer 
  {
    min_dimension: 600
    max_dimension: 1024
  }
}

,which will feed the network with your input images unshaped, in the range [min_dim, max_dim]. I dont know though if this will work cause i believe the ssd detector requires the input images to be resized as squares, meaning having same height and width e.g 224x224 or 128x128. You dont have to make any manual changes to your hard images.



来源:https://stackoverflow.com/questions/48929519/mobilenet-ssd-input-image-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!