Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize and noise policies #2252

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ducha-aiki
Copy link
Contributor

Works only for cv::Mat stored databases.
@immars kindly rebased my branch to current master and added gaussian noise.
P.S. Travis is failing because of different OpenCV version, which does not have CLAHE function.
Adds different resize and noise policies to data_transformer like:

transform_param {
    crop_size: 227
    resize_param {
      prob: 0.5
      resize_mode: WARP
      height: 256
      width: 256
      interp_mode: LINEAR
    }
    resize_param {
      prob: 0.25
      resize_mode: BY_LARGE_SIZE
      height: 256
      width: 256
      interp_mode: AREA
    }
      resize_param {
      prob: 0.2
      resize_mode: BY_SMALL_SIZE_AND_PAD
      height: 256
      width: 256
      pad_mode: MIRRORED
      interp_mode: NEAREST
    }
      resize_param {
      prob: 0.05
      resize_mode: BY_SMALL_SIZE_AND_PAD
      height: 256
      width: 256
      pad_mode: CONSTANT
      pad_value: 104
      pad_value: 117
      pad_value: 124
      interp_mode: NEAREST
    }
    noise_param {
    prob: 0.6
    }
    noise_param {
    hist_eq: true
    prob: 0.2
    }  
    noise_param {
    decolorize: true
    gauss_blur: true
    prob: 0.2
    }  

@lukeyeager
Copy link
Contributor

We've done something similar with DIGITS on the database creation side of things. I would love to see these options in caffe instead - nice work!

A few thoughts from our research:

  1. Padding with REPEAT_NEAREST was terrible. The network learns to recognize those distinctive lines on the edge of the screen and it throws off the training. CONSTANT wasn't much better. We had better luck padding with random noise than anything else. By all means, leave REPEAT_NEAREST in there and let people try it for themselves, but I'd like to see RANDOM added as another option in the future.
  2. Our go-to resize method is halfway in between your FIT_SMALL_SIZE (or "crop") and FIT_LARGE_SIZE_AND_PAD (or "fill") - something we call "half crop, half fill" (great name, I know). You might want to look into it.

Both of those are more suggestions than critiques. This looks like a step in the right direction!

FYI, here is what HALF_CROP with RANDOM noise looks like (resize code here):

resize_options

@ducha-aiki
Copy link
Contributor Author

Thanks for suggestions. From my experience, best padding is mirroring. Second - warping.
The third best was padding with mean pixel.

I like DIGITS, but resizing when creating dataset is too rigid compared to online data augmentation.

@lukeyeager
Copy link
Contributor

resizing when creating dataset is too rigid compared to online data augmentation

Right, I agree. That's why I'm excited to see this going into caffe!

@ducha-aiki
Copy link
Contributor Author

Have you tested mean or mirror padding?

@lukeyeager
Copy link
Contributor

Have you tested mean or mirror padding?

I haven't. Mirror sounds promising. I'll check it out when I find some time.

@bhack
Copy link
Contributor

bhack commented Apr 3, 2015

/cc @mtamburrano

weiliu89 added a commit to weiliu89/caffe that referenced this pull request Apr 14, 2015
@bhack
Copy link
Contributor

bhack commented Jan 1, 2016

Just another PR is dying in natural drifting from master. Is this project alive?

@ducha-aiki
Copy link
Contributor Author

@bhack more dead than alive. It is merged in my main branch elu https://github.com/ducha-aiki/caffe but separate headers haven`t merged yet there.

@bhack
Copy link
Contributor

bhack commented Jan 2, 2016

@lukeyeager is your team still interested?

@bhack
Copy link
Contributor

bhack commented Jan 2, 2016

@ducha-aiki It makes sense to rebase?

@ducha-aiki
Copy link
Contributor Author

@bhack it is not question to me :) I can do rebase, but am not as patient as you with @mtamburrano ;)
so will rebase only if it is needed.

@ducha-aiki
Copy link
Contributor Author

@bhack Actually, I agree with https://github.com/zer0n/deepframeworks/blob/master/README.md
caffe is nice as industry standard for deployment and fast training of standard models.

But not as suitable as before for experiments.

@bhack
Copy link
Contributor

bhack commented Jan 2, 2016

@ducha-aiki I'm not so patient ;) I've not contributed anymore until the MIA status of BVLC core devs will be clarified. Other frameworks are getting momentum so I think that there is more choice now. I'll try to use your fork directly instead of trying to rebase this.

@ducha-aiki
Copy link
Contributor Author

@bhack if you give me a way to contact you, will notify when merge current master into my fork.
Btw, multiscale training is not always good, at least one I have tested :(
https://github.com/ducha-aiki/caffenet-benchmark/blob/master/Augmentation.md

@bhack
Copy link
Contributor

bhack commented Jan 2, 2016

Things like basic augmentation could be part of the industrial standard ;)

@bhack
Copy link
Contributor

bhack commented Jan 2, 2016

I think that Imagenet dataset is quite rich to cover scales. But in other cases, with a smaller dataset it could be useful.

@bhack
Copy link
Contributor

bhack commented Jan 3, 2016

@ducha-aiki Can be used with lmdb created with convert_imageset utility?

@ducha-aiki
Copy link
Contributor Author

@bhack yes, but compressed (aka jpeg, png, etc ) only.

@lukeyeager
Copy link
Contributor

@lukeyeager is your team still interested?

Yes. I think somebody around here implemented their own version of this, but it would be great to have it standard in BVLC/caffe.

@ducha-aiki
Copy link
Contributor Author

@lukeyeager @bhack
rebased to current bvlc-master here https://github.com/ducha-aiki/caffe/tree/augmentations
not linted or wrote tests yet.

@ducha-aiki
Copy link
Contributor Author

@shelhamer @ronghanghu
I have rebased this PR to current master in other branch and can write tests/expand/shrink number of features in augmentation branch, if caffe is interested in data augmentation.
If not, I will abandon this. Any feedback please?

@mtamburrano
Copy link
Contributor

really useful PR, we already tested it and would be nice to see it merged on master.
Just my 2 cents

@TimZaman
Copy link

What a shame.. RIP PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants