weiliu89 / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
4.77k stars 1.68k forks source link

Could SSD train with images of any size? #235

Open baiyancheng20 opened 8 years ago

baiyancheng20 commented 8 years ago

Hi, @weiliu89 I want to know how to train models with images of any size rather than resizing to the fixed size, even if the batch size is set to one? Thank you.

weiliu89 commented 8 years ago

Yes. It is doable. I have trained a model by keeping the original aspect ratio instead of warping, it improves the performance a bit but is a bit slower. Current released code has some bugs for that part. If I have time, I would update the code to include such functionality.

yeongrok commented 8 years ago

When keeping the original aspect ratio, is it possible to use diffirent size of images?? eg. some are 300x500 and some are 1280x728. Actually I've tried but I've get wiered result. Was there some points that I missed but should be considered? Thank you

Supersak80 commented 7 years ago

Hi @weiliu89, if I want to train SSD with images of size 1024x1024, is this possible, and is it as simple as changing 'resize_width' and 'resize_height' in /examples/ssd/pascal.py, assuming that I have properly created the lmdbs for my own dataset?I suspect that other params have to change since you're expecting the feature map activations to be of specific size based on a specific input size such as 300x300 or 500x500?

yeongrok commented 7 years ago

Hi, @Supersak80 If you want to use 300 model or 500 model, just resize your images into 300 or 500, or not bit sized objects will not be detected. If you want to use original image size, you need to modify model structure like adding some conv. and/or pooling layers, defining additional source layers for loc, conf. Another way is just to adjust min, max size parameters in priorbox layer, but it will very likely have low performance because receptive field's size is not enough for detection

catsdogone commented 7 years ago

@yeongrok Did you success? I also try to keep the original image ratio and traing while the ap is not good.

weiliu89 commented 7 years ago

examples/ssd/ssd_pascal_orig.py should be able to handle images of any size during training.

baiyancheng20 commented 7 years ago

@weiliu89 Hi, could you add an example for coco to handle images of any size during training? Thank you. I have tried but I met with this problem OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp, line 3959 terminate called after throwing an instance of 'cv::Exception' what(): /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/color.cpp:3959: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColor.

Goldit commented 7 years ago

Hi @weiliu89 , does examples/ssd/ssd_pascal_orig.py work with 500x500? The configurations are quite different than ssd_pascal_500.py.

weiliu89 commented 7 years ago

@baiyancheng20 Please add [force_color](https://github.com/weiliu89/caffe/blob/ssd/examples/ssd/ssd_coco.py#L178) when you train with COCO images (because some images are gray).

@Goldit You can find the training and scoring scripts for 512x512 model from the pretrained models I have provided.

baiyancheng20 commented 7 years ago

@weiliu89 I checked the deploy prototxt for ssd_pascal_orig.py name: "VGG_VOC0712_SSD_300x300_orig_deploy" input: "data" input_shape { dim: 1 dim: 3 dim: 300 dim: 300 } Does this mean that the model will resize any image to 300*300 when it is used for deploying? If like this, I think a little wired because we keep the ratio when training.

weiliu89 commented 7 years ago

@baiyancheng20 There is an FIT_SMALL_SIZE option in the transform parameter.

griffintin commented 7 years ago

@weiliu89 when use FIT_SMALL_SIZE, why supported batch_size is 1? If all input images are with the same resolution, can this condition be removed? and I read the ssd_pascal_orig.py, the batch_size is set to number of GPUs

jianbohuang commented 6 years ago

@griffintin Because all data in the batch [n,c,h,w] should have a same [c,h,w], but FIT_SMALL_SIZE let each img keep their own shape.