Spatial Transformer Networks with Keras

Spatial Transformer Networks (STN) have been there since 2015 but I haven’t found an easy-to-follow example of it for #Keras.

On the other hand, Kevin Zakka’s implementation of STN is by far one of the cleanest ones but it’s purely in TensorFlow 1. So, I decided to take the utility functions from his implementation and prepare an end-to-end example in #Keras out of it. You can find it here:

Comes with a Colab Notebook and also a TensorBoard callback that helps visualize the progressions of the transformations learned by STN during training.

Notice how the STN module is able to figure out transformations for the dataset that may be helpful to boost its performance -


Thanks, Sayuk! More concrete examples of how to combine the myriad techniques and tools helps the folks who come after you.

re: the tensorboard line in the notebook. Have you played with If you changed that line then anyone could upload to a public hosted TensorBoard and they could share links to their specific runs. here’s a deep link to a demo colab showing how to upload to directly if you’re interested.


The last time I tried it (which is not very long ago) image data wasn’t supported.

1 Like

I believe it is now (but am not an expert). Here are some relevant docs: Displaying image data in TensorBoard  |  TensorFlow

1 Like

It’s supported in TensorBoard which is what I have demonstrated in my example above. By the time of that development, it wasn’t supported on

1 Like

Aha - thanks for clarifying.

1 Like

We was talking about

1 Like

Probably there is still some hope that it is in the roadmap. You could upvote and subscribe to

1 Like