Conversation
|
I remember that @Bigene has something extended to other transformation (affine?) |
|
@bhack, can you link to the PR? The advantage of 90 degree rotations is that they're nearly computationally free; they can be implemented by messing with input and output indexing, just like mirroring. Affine transformations are significantly more expensive, but potentially also very useful. |
|
Here's a Matlab test of the rotation logic: https://gist.github.com/drdan14/99dc38fb363913f295f5. I tried to copy the C++ rotation logic as closely as possible, offensive as nested The output looks good to me. |
|
I don't have the bandwidth to rebase this onto master, so I am closing it. |
|
@drdan14 Nevermind. I'm not satisfied with this but often caffe PR are subject to neverending rebase over the months. |
Some datasets are indifferent to which direction in the image is "up" and therefore can be augmented with random rotations. This PR implements a
rotateoption in theTransformationParametermessage which operates analogously tomirror. It'sfalseby default; setting it totruecauses images to be randomly rotated by an integer multiple of 90 degrees. Ifmirroris also enabled, there are 8 possibilities for the randomly transformed output image.An error is thrown if the input data is not square (i.e., if
datum.height() != datum.width()); the logic for dealing with square rotations is easier to start with, and I believe thattransformed_datais expected to have the same shape as the input data.I added unit tests to
test_data_transformer.cppby copying and pasting some pre-existing mirroring unit tests; the tests show that this transformation runs, but they don't prove that it does what I expect it to do (i.e., rotate an image properly). I'm not a pro at Caffe unit tests, so if anyone can suggest how to write a unit test that confirms that the rotation is working properly, I'd be happy to implement it. I can (and probably will) copy the logic to a little test script in Matlab to convince myself that the logic is working, but that's not really good enough as a unit test.I have not yet tried to train a network using therotateparameter but that's next on my list. In the mean time, eyeballs on my rotation (and generalized mirroring) logic are welcome.Update: I've trained a network using the random rotations and it worked just fine (if not necessarily any better than when random rotations were disabled).