Unverified Commit 59b27ed6 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Add links to collab (#7854)

parent 90e0b792
...@@ -56,6 +56,10 @@ jobs: ...@@ -56,6 +56,10 @@ jobs:
sed -i -e 's/-j auto/-j 1/' Makefile sed -i -e 's/-j auto/-j 1/' Makefile
make html make html
# Below is an imperfect way for us to add "try on collab" links to all of our gallery examples.
# sphinx-gallery will convert all gallery examples to .ipynb notebooks and stores them in
# build/html/_downloads/<some_hash>/<example_name>.ipynb
# We copy all those ipynb files in a more convenient folder so that we can more easily link to them.
mkdir build/html/_generated_ipynb_notebooks mkdir build/html/_generated_ipynb_notebooks
for file in `find build/html/_downloads`; do for file in `find build/html/_downloads`; do
if [[ $file == *.ipynb ]]; then if [[ $file == *.ipynb ]]; then
......
...@@ -56,6 +56,26 @@ extensions = [ ...@@ -56,6 +56,26 @@ extensions = [
"beta_status", "beta_status",
] ]
# We override sphinx-gallery's example header to prevent sphinx-gallery from
# creating a note at the top of the renderred notebook.
# https://github.com/sphinx-gallery/sphinx-gallery/blob/451ccba1007cc523f39cbcc960ebc21ca39f7b75/sphinx_gallery/gen_rst.py#L1267-L1271
# This is because we also want to add a link to google collab, so we write our own note in each example.
from sphinx_gallery import gen_rst
gen_rst.EXAMPLE_HEADER = """
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "{0}"
.. LINE NUMBERS ARE GIVEN BELOW.
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_{1}:
"""
sphinx_gallery_conf = { sphinx_gallery_conf = {
"examples_dirs": "../../gallery/", # path to your example scripts "examples_dirs": "../../gallery/", # path to your example scripts
"gallery_dirs": "auto_examples", # path to where to save gallery generated output "gallery_dirs": "auto_examples", # path to where to save gallery generated output
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
Optical Flow: Predicting movement with the RAFT model Optical Flow: Predicting movement with the RAFT model
===================================================== =====================================================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_optical_flow.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_others_plot_optical_flow.py>` to download the full example code.
Optical flow is the task of predicting movement between two images, usually two Optical flow is the task of predicting movement between two images, usually two
consecutive frames of a video. Optical flow models take two images as input, and consecutive frames of a video. Optical flow models take two images as input, and
predict a flow: the flow indicates the displacement of every single pixel in the predict a flow: the flow indicates the displacement of every single pixel in the
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
Repurposing masks into bounding boxes Repurposing masks into bounding boxes
===================================== =====================================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_repurposing_annotations.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_others_plot_repurposing_annotations.py>` to download the full example code.
The following example illustrates the operations available The following example illustrates the operations available
the :ref:`torchvision.ops <ops>` module for repurposing the :ref:`torchvision.ops <ops>` module for repurposing
segmentation masks into object localization annotations for different tasks segmentation masks into object localization annotations for different tasks
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
Tensor transforms and JIT Tensor transforms and JIT
========================= =========================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_scripted_tensor_transforms.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_others_plot_scripted_tensor_transforms.py>` to download the full example code.
This example illustrates various features that are now supported by the This example illustrates various features that are now supported by the
:ref:`image transformations <transforms>` on Tensor images. In particular, we :ref:`image transformations <transforms>` on Tensor images. In particular, we
show how image transforms can be performed on GPU, and how one can also script show how image transforms can be performed on GPU, and how one can also script
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
Illustration of transforms Illustration of transforms
========================== ==========================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_transforms.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_others_plot_transforms.py>` to download the full example code.
This example illustrates the various transforms available in :ref:`the This example illustrates the various transforms available in :ref:`the
torchvision.transforms module <transforms>`. torchvision.transforms module <transforms>`.
""" """
......
""" """
======================= =========
Video API Video API
======================= =========
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_video_api.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_others_plot_video_api.py>` to download the full example code.
This example illustrates some of the APIs that torchvision offers for This example illustrates some of the APIs that torchvision offers for
videos, together with the examples on how to build datasets and more. videos, together with the examples on how to build datasets and more.
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
Visualization utilities Visualization utilities
======================= =======================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_visualization_utils.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_others_plot_visualization_utils.py>` to download the full example code.
This example illustrates some of the utilities that torchvision offers for This example illustrates some of the utilities that torchvision offers for
visualizing images, bounding boxes, segmentation masks and keypoints. visualizing images, bounding boxes, segmentation masks and keypoints.
""" """
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
How to write your own Datapoint class How to write your own Datapoint class
===================================== =====================================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_custom_datapoints.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_v2_transforms_plot_custom_datapoints.py>` to download the full example code.
This guide is intended for advanced users and downstream library maintainers. We explain how to This guide is intended for advanced users and downstream library maintainers. We explain how to
write your own datapoint class, and how to make it compatible with the built-in write your own datapoint class, and how to make it compatible with the built-in
Torchvision v2 transforms. Before continuing, make sure you have read Torchvision v2 transforms. Before continuing, make sure you have read
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
How to write your own v2 transforms How to write your own v2 transforms
=================================== ===================================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_custom_transforms.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_v2_transforms_plot_custom_transforms.py>` to download the full example code.
This guide explains how to write transforms that are compatible with the This guide explains how to write transforms that are compatible with the
torchvision transforms V2 API. torchvision transforms V2 API.
""" """
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
How to use CutMix and MixUp How to use CutMix and MixUp
=========================== ===========================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_cutmix_mixup.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_v2_transforms_plot_cutmix_mixup.py>` to download the full example code.
:class:`~torchvision.transforms.v2.CutMix` and :class:`~torchvision.transforms.v2.CutMix` and
:class:`~torchvision.transforms.v2.MixUp` are popular augmentation strategies :class:`~torchvision.transforms.v2.MixUp` are popular augmentation strategies
that can improve classification accuracy. that can improve classification accuracy.
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
Datapoints FAQ Datapoints FAQ
============== ==============
https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/_generated_ipynb_notebooks/plot_datapoints.ipynb .. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_datapoints.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_v2_transforms_plot_datapoints.py>` to download the full example code.
Datapoints are Tensor subclasses introduced together with Datapoints are Tensor subclasses introduced together with
``torchvision.transforms.v2``. This example showcases what these datapoints are ``torchvision.transforms.v2``. This example showcases what these datapoints are
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
Getting started with transforms v2 Getting started with transforms v2
================================== ==================================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_transforms_v2.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_v2_transforms_plot_transforms_v2.py>` to download the full example code.
Most computer vision tasks are not supported out of the box by ``torchvision.transforms`` v1, since it only supports Most computer vision tasks are not supported out of the box by ``torchvision.transforms`` v1, since it only supports
images. ``torchvision.transforms.v2`` enables jointly transforming images, videos, bounding boxes, and masks. This images. ``torchvision.transforms.v2`` enables jointly transforming images, videos, bounding boxes, and masks. This
example showcases the core functionality of the new ``torchvision.transforms.v2`` API. example showcases the core functionality of the new ``torchvision.transforms.v2`` API.
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
Transforms v2: End-to-end object detection example Transforms v2: End-to-end object detection example
================================================== ==================================================
.. note::
Try on `collab <https://colab.research.google.com/github/pytorch/vision/blob/gh-pages/main/_generated_ipynb_notebooks/plot_transforms_v2_e2e.ipynb>`_
or :ref:`go to the end <sphx_glr_download_auto_examples_v2_transforms_plot_transforms_v2_e2e.py>` to download the full example code.
Object detection is not supported out of the box by ``torchvision.transforms`` v1, since it only supports images. Object detection is not supported out of the box by ``torchvision.transforms`` v1, since it only supports images.
``torchvision.transforms.v2`` enables jointly transforming images, videos, bounding boxes, and masks. This example ``torchvision.transforms.v2`` enables jointly transforming images, videos, bounding boxes, and masks. This example
showcases an end-to-end object detection training using the stable ``torchvision.datasets`` and ``torchvision.models`` showcases an end-to-end object detection training using the stable ``torchvision.datasets`` and ``torchvision.models``
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment