Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

[Docs] Refactor the embedded Gradio demos (#1901)

Nima Boscarinob5249b7016e6
diff --git a/docs/source/_templates/page.html b/docs/source/_templates/page.html
index 54b80920e..de11d28e7 100644
--- a/docs/source/_templates/page.html
+++ b/docs/source/_templates/page.html
@@ -3,6 +3,7 @@
{{ super() }}
<!-- DocsQA integration start -->
<script src="https://jina-docqa-ui.netlify.app/dist/qabot.js"></script>
+ <script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/3.3.1/gradio.js"></script>
<script>
// This prevents the global search interfere with qa-bot internal text input.
document.addEventListener('DOMContentLoaded', () => {
diff --git a/docs/source/applications/image_stitching.rst b/docs/source/applications/image_stitching.rst
index b6fec6382..c6f7f8575 100644
--- a/docs/source/applications/image_stitching.rst
+++ b/docs/source/applications/image_stitching.rst
@@ -25,6 +25,7 @@ Explore with your data: https://colab.research.google.com/github/kornia/tutorial
Interactive Demo
----------------
.. raw:: html
- :file: gradio/stitching_gradio.html
+
+ <gradio-app space="kornia/Image-Stitching"></gradio-app>
Visit the demo on `Hugging Face Spaces <https://huggingface.co/spaces/kornia/Image-Stitching>`_.
diff --git a/docs/source/enhance.rst b/docs/source/enhance.rst
index b08064fad..6c2775496 100644
--- a/docs/source/enhance.rst
+++ b/docs/source/enhance.rst
@@ -5,8 +5,6 @@ kornia.enhance
The functions in this section perform normalisations and intensity transformations.
-* `Interactive Demo`_
-
Adjustment
----------
@@ -24,6 +22,14 @@ Adjustment
.. autofunction:: sharpness
.. autofunction:: solarize
+Interactive Demo
+~~~~~~~~~~~~~~~~
+.. raw:: html
+
+ <gradio-app space="kornia/kornia-image-enhancement"></gradio-app>
+
+Visit the demo on `Hugging Face Spaces <https://huggingface.co/spaces/kornia/kornia-image-enhancement>`_.
+
Equalization
------------
@@ -64,11 +70,3 @@ Modules
.. autoclass:: AddWeighted
.. autoclass:: Invert
-
-
-Interactive Demo
-----------------
-.. raw:: html
- :file: gradio/enhance_gradio.html
-
-Visit the demo on `Hugging Face Spaces <https://huggingface.co/spaces/kornia/kornia-image-enhancement>`_.
diff --git a/docs/source/filters.rst b/docs/source/filters.rst
index d17004091..c5594ba0c 100644
--- a/docs/source/filters.rst
+++ b/docs/source/filters.rst
@@ -8,8 +8,6 @@ The functions in this sections perform various image filtering operations.
Blurring
--------
-* `Interactive Demo`_
-
.. autofunction:: blur_pool2d
.. autofunction:: box_blur
.. autofunction:: gaussian_blur2d
@@ -18,17 +16,30 @@ Blurring
.. autofunction:: motion_blur
.. autofunction:: unsharp_mask
+Interactive Demo
+~~~~~~~~~~~~~~~~
+.. raw:: html
+
+ <gradio-app space="kornia/kornia-image-filtering"></gradio-app>
+
+Visit the demo on `Hugging Face Spaces <https://huggingface.co/spaces/kornia/kornia-image-filtering>`_.
+
Edge detection
--------------
-* `Interactive Demo`_
-
.. autofunction:: canny
.. autofunction:: laplacian
.. autofunction:: sobel
.. autofunction:: spatial_gradient
.. autofunction:: spatial_gradient3d
+Interactive Demo
+~~~~~~~~~~~~~~~~
+.. raw:: html
+
+ <gradio-app space="kornia/edge_detector"></gradio-app>
+
+Visit the demo on `Hugging Face Spaces <https://huggingface.co/spaces/kornia/edge_detector>`_.
Filtering API
-------------
@@ -65,10 +76,3 @@ Module
.. autoclass:: SpatialGradient3d
.. autoclass:: MotionBlur
.. autoclass:: UnsharpMask
-
-
-Interactive Demo
-----------------
-
-.. raw:: html
- :file: gradio/edge_detector_gradio.html
diff --git a/docs/source/geometry.line.rst b/docs/source/geometry.line.rst
index 6a6a65169..0969ab36a 100644
--- a/docs/source/geometry.line.rst
+++ b/docs/source/geometry.line.rst
@@ -11,4 +11,5 @@ kornia.geometry.line
.. autoclass:: Hyperplane
.. raw:: html
- :file: gradio/line_fitting.html
+
+ <gradio-app space="kornia/Line-Fitting"></gradio-app>
diff --git a/docs/source/geometry.transform.rst b/docs/source/geometry.transform.rst
index f0368081b..ca319ee4a 100644
--- a/docs/source/geometry.transform.rst
+++ b/docs/source/geometry.transform.rst
@@ -73,7 +73,6 @@ Module
.. autoclass:: Vflip
.. autoclass:: Rot180
.. autoclass:: Resize
-* `Interactive Demo`_
.. autoclass:: Rescale
.. autoclass:: Affine
.. autoclass:: HomographyWarper
@@ -88,9 +87,3 @@ Image registration
.. automodule:: kornia.geometry.transform.image_registrator
:members:
-
-Interactive Demo
-----------------
-
-.. raw:: html
- :file: gradio/resize_antialias.html
diff --git a/docs/source/gradio/edge_detector_gradio.html b/docs/source/gradio/edge_detector_gradio.html
deleted file mode 100644
index 03facc04a..000000000
--- a/docs/source/gradio/edge_detector_gradio.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<script type="module"
-src="https://gradio.s3-us-west-2.amazonaws.com/3.3/gradio.js">
-</script>
-<gradio-app space="kornia/edge_detector"></gradio-app>
diff --git a/docs/source/gradio/edge_filter_gradio.html b/docs/source/gradio/edge_filter_gradio.html
deleted file mode 100644
index 6b4a8d2e3..000000000
--- a/docs/source/gradio/edge_filter_gradio.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/3.2/gradio.js">
-</script>
-<gradio-app space="kornia/kornia-edge-detection"></gradio-app>
diff --git a/docs/source/gradio/enhance_gradio.html b/docs/source/gradio/enhance_gradio.html
deleted file mode 100644
index 0c4cc45c1..000000000
--- a/docs/source/gradio/enhance_gradio.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<script type="module"
-src="https://gradio.s3-us-west-2.amazonaws.com/3.1.7/gradio.js">
-</script>
-<gradio-app space="kornia/kornia-image-enhancement" src="https://hf.space/embed/kornia/kornia-image-enhancement/+"></gradio-app>
diff --git a/docs/source/gradio/filtering_operators_gradio.html b/docs/source/gradio/filtering_operators_gradio.html
deleted file mode 100644
index 244691c5c..000000000
--- a/docs/source/gradio/filtering_operators_gradio.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/3.3/gradio.js"></script>
-<gradio-app space="kornia/kornia-image-filtering"></gradio-app>
diff --git a/docs/source/gradio/line_fitting.html b/docs/source/gradio/line_fitting.html
deleted file mode 100644
index e2278af40..000000000
--- a/docs/source/gradio/line_fitting.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/3.1.7/gradio.js"></script>
-<gradio-app space="kornia/Line-Fitting"></gradio-app>
diff --git a/docs/source/gradio/morphological_operators.html b/docs/source/gradio/morphological_operators.html
deleted file mode 100644
index 5aa0d7165..000000000
--- a/docs/source/gradio/morphological_operators.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-<script type="module"
-src="https://gradio.s3-us-west-2.amazonaws.com/3.3/gradio.js">
-</script>
-<gradio-app space="kornia/morphological_operators"></gradio-app>
diff --git a/docs/source/gradio/resize_antialias.html b/docs/source/gradio/resize_antialias.html
deleted file mode 100644
index fc4a7907c..000000000
--- a/docs/source/gradio/resize_antialias.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<script type="module"
-src="https://gradio.s3-us-west-2.amazonaws.com/3.1.7/gradio.js">
-</script>
-<gradio-app space="kornia/kornia-resize-antialias" src="https://hf.space/embed/kornia/kornia-resize-antialias/+"></gradio-app>
diff --git a/docs/source/gradio/stitching_gradio.html b/docs/source/gradio/stitching_gradio.html
deleted file mode 100644
index 7612c8759..000000000
--- a/docs/source/gradio/stitching_gradio.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/3.1.7/gradio.js"></script>
-<gradio-app space="kornia/Image-Stitching"></gradio-app>
diff --git a/docs/source/morphology.rst b/docs/source/morphology.rst
index baa4fe350..cf84f6596 100644
--- a/docs/source/morphology.rst
+++ b/docs/source/morphology.rst
@@ -12,6 +12,9 @@ kornia.morphology
.. autofunction:: bottom_hat
Interactive Demo
-----------------
+~~~~~~~~~~~~~~~~
.. raw:: html
- :file: gradio/morphological_operators.html
+
+ <gradio-app space="kornia/morphological_operators"></gradio-app>
+
+Visit the demo on `Hugging Face Spaces <https://huggingface.co/spaces/kornia/morphological_operators>`_.
diff --git a/kornia/geometry/transform/affwarp.py b/kornia/geometry/transform/affwarp.py
index 982e59137..16dfafcb1 100644
--- a/kornia/geometry/transform/affwarp.py
+++ b/kornia/geometry/transform/affwarp.py
@@ -668,6 +668,10 @@ class Resize(nn.Module):
>>> out = Resize((6, 8))(img)
>>> print(out.shape)
torch.Size([1, 3, 6, 8])
+
+ .. raw:: html
+
+ <gradio-app space="kornia/kornia-resize-antialias"></gradio-app>
"""
def __init__(