dmlc / gluon-cv

Gluon CV Toolkit
http://gluon-cv.mxnet.io
Apache License 2.0
5.82k stars 1.21k forks source link

Finetuneing a pretrained ResNet50_v1d in gluoncv #539

Open zw615 opened 5 years ago

zw615 commented 5 years ago

Hi, there! Environment: Ubuntu 18.04, MXNet-cu92 1.3.1, Gluon-Cv 0.4 (Master) I'm trying to finetuneing a gluoncv pretrained ResNet50_v1d classification model. But there is something strange going on. When I finetuned it with 256x256 image resized from some dataset of size 512x512, everything was fine. However, When I tried to finetune it with 384x384 image, the accuracy just wouldn't go up, It kept going up and down. At first, I thought it has something to do with the mxnet imread and mxnet ResizeAug. so I rewrote my own dataset class with cv2 imread and cv2 resize. Now, the accuracy is going up, but at a much lower rate which is no way compared to the rate when using 256x256 image. It usually took about 3 more epochs to get the accuracy up by 0.1% .(the total training epoch is 50) BTW, below are different resize function that I have tried:

image = cv2.resize(image, (self.size, self.size), cv2.INTER_AREA)

resize_aug = mx.image.ResizeAug(size=size)
image = resize_aug(image)

I checked they both use Area-based (resampling using pixel area relation) interpretation strategy for resize. I wonder if it may have something to do with batch_size since I halved the batch_size when using larger image.

Isn't larger image supposed to give better result? Thank you!

zhreshold commented 5 years ago

Isn't larger image supposed to give better result? No, receptive field is fixed, therefore for image classification, the performance may drop if the input is too big. Note that the global pooling is applied before last FullyConnect layer.

Jerryzcn commented 5 years ago

@JWarlock what is the batch size you are using? if batch size per gpu is less than 16 it might cause problems due to batch norm stats being not accurate. Also you need to adjust your learning rate accordingly.