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

Add illustrations of transforms with sphinx-gallery #3652

Merged
merged 20 commits into from
Apr 19, 2021

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Apr 8, 2021

This PR uses sphinx-gallery to add an example that illustrates how the transforms affect a given image.

Closes #1409
#1426

Copy link
Member Author

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it looks like it went fine - it's almost a miracle!

The gallery is at https://504027-73328905-gh.circle-artifacts.com/0/docs/auto_examples/index.html and contains one (very WIP) example so far.

Backlinks are added properly: https://504027-73328905-gh.circle-artifacts.com/0/docs/transforms.html#torchvision.transforms.Pad.forward

@fmassa what are your first impressions?

docs/requirements.txt Show resolved Hide resolved
@@ -76,6 +76,11 @@ Transforms on PIL Image and torch.\*Tensor
.. autoclass:: Pad
:members:

.. include:: gen_modules/backreferences/torchvision.transforms.Pad.examples
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a better way to do this with more recent versions of sphinx-gallery (and possibly even with this one, I didn't dive too much into it)

img = Image.fromarray(astronaut())

plt.figure().suptitle("Before padding")
plt.imshow(np.asarray(img))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Surely there's a better way to render PIL images...

@fmassa
Copy link
Member

fmassa commented Apr 14, 2021

This approach looks great, thanks!

How do you want to approach this, get a small example with a few transforms merged and then progressively extend it?

Also, it might be good to avoid using skimage and instead provide our own version of astronaut for testing purposes

@NicolasHug
Copy link
Member Author

Thanks for the feedback!

How do you want to approach this, get a small example with a few transforms merged and then progressively extend it?

Pretty much, yeah. I was thinking of inviting the community to contribute with more transform illustrations once the basis is merged?

Also, it might be good to avoid using skimage and instead provide our own version of astronaut for testing purposes

OK, I wasn't sure about this - I'll include the image as an asset.

@NicolasHug NicolasHug changed the title WIP Add illustrations of transforms with sphinx-gallery Add illustrations of transforms with sphinx-gallery Apr 16, 2021
@NicolasHug NicolasHug marked this pull request as ready for review April 16, 2021 13:22
@NicolasHug
Copy link
Member Author

NicolasHug commented Apr 16, 2021

@fmassa I think this is ready for a review. The latest example is here: https://519065-73328905-gh.circle-artifacts.com/0/docs/auto_examples/plot_transforms.html#sphx-glr-auto-examples-plot-transforms-py

I think we can merge this one and them I'll open an issue to invite contributors to expand it

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

One thing we might want to consider when scaling up with implementing examples for other transforms is to potentially split the gallery in a few different ones, grouped by transformation type (color / geometric / etc).

@NicolasHug NicolasHug merged commit f85996e into pytorch:master Apr 19, 2021
@NicolasHug NicolasHug deleted the gallery branch April 19, 2021 14:05
facebook-github-bot pushed a commit that referenced this pull request May 4, 2021
Reviewed By: NicolasHug

Differential Revision: D28169127

fbshipit-source-id: 8233282c3b03a051f253f6a0447029ed9d85ac4b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add examples of transformation to docs
5 participants