Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

the rename is here: torchgeometry -> kornia

edgarriba3330ff67d5c8
diff --git a/.gitignore b/.gitignore
index e0387f788..8cd46957d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,5 @@ torchgeometry.egg-info/
.dev_env
.mypy_cache/*
.coverage
+*bak
+*ipynb_checkpoints*
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index c288bed56..931fc2689 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -1,17 +1,17 @@
-Contributing to PyTorch Geometry
-================================
+Contributing to Kornia
+======================
-**Welcome !!** This is the PyTorch Geometry library contributors corner. If you are reading this, it means that you have interest in **Computer Vision and Geometry**, and willing to contribute to the project.
+**Welcome !!** This is the Kornia library contributors corner. If you are reading this, it means that you have interest in **Differentiable Computer Vision**, and willing to contribute to the project.
Everyone is welcomed to get involved with the project. There are different ways in how you can put your two cents:
-1. Ask/Answer questions in the ``#geometry`` PyTorch Slack channel:
+1. Ask/Answer questions in the ``#kornia`` PyTorch Slack channel:
- We suggest you to join the channel in order to get more involved to the PyTorch ecosystem. Send an email to `[email protected] <[email protected]>`_ in order to get access.
- Please, don't use GitHub issues for Q&A.
-2. Report bugs through `GitHub issues <https://github.com/arraiyopensource/torchgeometry/issues>`_:
+2. Report bugs through `GitHub issues <https://github.com/arraiyopensource/kornia/issues>`_:
- Do a quick search first to see whether others reported a similar issue.
- In case you find an unreported bug, please open a new ticket.
@@ -26,7 +26,7 @@ Everyone is welcomed to get involved with the project. There are different ways
- We will always have an open ticket showing the current roadmap.
- Pick an unassigned feature (or potentially propose new one) or an open bug ticket.
- - Follow the instructions from Developing PyTorch Geometry in order to setup your development environment and start coding.
+ - Follow the instructions from Developing Kornia in order to setup your development environment and start coding.
- Checkout our coding conventions. See more details below.
- Run the test framework locally and make sure all works as expected before sending a pull request.
- Open a Pull Request, get the green light from the CI and get your code merged.
@@ -39,8 +39,8 @@ Everyone is welcomed to get involved with the project. There are different ways
- Currently looking for some kind of server donation in order to test *CUDA* code. (Please contact us).
-Developing PyTorch Geometry
-===========================
+Developing Kornia
+=================
In order to start to develop, please follow the steps below:
@@ -48,15 +48,15 @@ In order to start to develop, please follow the steps below:
.. code:: bash
- pip uninstall torchgeometry
- pip uninstall torchgeometry # run this command twice
+ pip uninstall kornia
+ pip uninstall kornia # run this command twice
-2. Clone a copy of PyTorch Geometry from source:
+2. Clone a copy of Kornia from source:
.. code:: bash
- git clone https://github.com/arraiyopensource/torchgeometry.git
- cd torchgeometry
+ git clone https://github.com/arraiyopensource/kornia.git
+ cd kornia
3. Create a new branch with a meaningful name reflecting your contribution. See an example:
@@ -72,7 +72,7 @@ In order to start to develop, please follow the steps below:
source ./path.bash.inc
python setup.py develop
- python -c "import torchgeometry; print(torchgeometry.__version__)"
+ python -c "import kornia; print(kornia.__version__)"
To install, or update the conda environment run ``setup_dev_env.sh``
@@ -120,7 +120,7 @@ Pull Request
============
Once you finish implementing a feature or bug-fix, please send a Pull Request to
-https://github.com/arraiyopensource/torchgeometry through the website.
+https://github.com/arraiyopensource/kornia through the website.
If you are not familiar with creating a Pull Request, here are some guides:
@@ -146,7 +146,7 @@ To run the test suite locally, make sure that you have activated the conda envir
.. code:: bash
- python setup.py test
+ make test
Licence
=======
diff --git a/Makefile b/Makefile
index cb4620847..8530986ce 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ test-cpu: FORCE
pytest --typetest cpu -vx
test-cpu-cov: FORCE
- pytest --typetest cpu -vx --cov=torchgeometry test
+ pytest --typetest cpu -vx --cov=kornia test
test-gpu: FORCE
pytest --typetest cuda -vx
@@ -15,7 +15,7 @@ lint: FORCE
python verify.py --check lint
autopep8: FORCE
- autopep8 --in-place --aggressive --recursive torchgeometry/ test/
+ autopep8 --in-place --aggressive --recursive kornia/ test/
mypy: FORCE
python verify.py --check mypy
@@ -27,6 +27,6 @@ install: FORCE
python setup.py install
uninstall: FORCE
- pip uninstall torchgeometry
+ pip uninstall kornia
FORCE:
diff --git a/README.rst b/README.rst
index 4a56fc053..ae963ee66 100644
--- a/README.rst
+++ b/README.rst
@@ -1,22 +1,22 @@
.. raw:: html
<p align="center">
- <img width="50%" src="https://github.com/arraiy/torchgeometry/blob/master/docs/source/_static/img/torchgeometry_logo.svg" />
+ <img width="50%" src="https://github.com/arraiy/kornia/blob/master/docs/source/_static/img/kornia_logo.svg" />
</p>
--------------------------------------------------------------------------------
-.. image:: https://travis-ci.com/arraiyopensource/torchgeometry.svg?branch=master
- :target: https://travis-ci.com/arraiyopensource/torchgeometry
+.. image:: https://travis-ci.com/arraiyopensource/kornia.svg?branch=master
+ :target: https://travis-ci.com/arraiyopensource/kornia
-.. image:: https://codecov.io/github/arraiyopensource/torchgeometry/branch/master/graph/badge.svg
- :target: https://codecov.io/github/arraiyopensource/torchgeometry
+.. image:: https://codecov.io/github/arraiyopensource/kornia/branch/master/graph/badge.svg
+ :target: https://codecov.io/github/arraiyopensource/kornia
-.. image:: https://badge.fury.io/py/torchgeometry.svg
- :target: https://badge.fury.io/py/torchgeometry
+.. image:: https://badge.fury.io/py/kornia.svg
+ :target: https://badge.fury.io/py/kornia
-.. image:: https://readthedocs.org/projects/torchgeometry/badge/?version=latest
- :target: https://torchgeometry.readthedocs.io/en/latest/?badge=latest
+.. image:: https://readthedocs.org/projects/kornia/badge/?version=latest
+ :target: https://kornia.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
The *PyTorch Geometry* package is a geometric computer vision library for `PyTorch <https://pytorch.org/>`_.
@@ -30,7 +30,7 @@ Installation
.. code:: bash
- pip install torchgeometry
+ pip install kornia
**From source:**
@@ -42,7 +42,7 @@ Installation
.. code:: bash
- pip install git+https://github.com/arraiyopensource/torchgeometry
+ pip install git+https://github.com/arraiyopensource/kornia
Quick Usage
===========
@@ -50,7 +50,7 @@ Quick Usage
.. code:: python
import torch
- import torchgeometry as tgm
+ import kornia as tgm
x_rad = tgm.pi * torch.rand(1, 3, 3)
x_deg = tgm.rad2deg(x_rad)
@@ -60,19 +60,19 @@ Quick Usage
Examples
========
-Run our Jupyter notebooks `examples <https://github.com/arraiyopensource/torchgeometry/tree/master/examples/>`_ to learn to use the library.
+Run our Jupyter notebooks `examples <https://github.com/arraiyopensource/kornia/tree/master/examples/>`_ to learn to use the library.
Cite
============
-If you are using torchgeometry in your research-related documents, it is recommended that you cite the poster.
+If you are using kornia in your research-related documents, it is recommended that you cite the poster.
.. code:: bash
@misc{Arraiy2018,
author = {E. Riba, M. Fathollahi, W. Chaney, E. Rublee and G. Bradski}
- title = {torchgeometry: when PyTorch meets geometry},
+ title = {kornia: when PyTorch meets geometry},
booktitle = {PyTorch Developer Conference},
year = {2018},
url = {https://drive.google.com/file/d/1xiao1Xj9WzjJ08YY_nYwsthE-wxfyfhG/view?usp=sharing}
@@ -81,4 +81,4 @@ If you are using torchgeometry in your research-related documents, it is recomme
Contributing
============
-We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us. Please, consider to read the `CONTRIBUTING <https://github.com/arraiyopensource/torchgeometry/blob/master/CONTRIBUTING.rst>`_ notes.
+We appreciate all contributions. If you are planning to contribute back bug-fixes, please do so without any further discussion. If you plan to contribute new features, utility functions or extensions, please first open an issue and discuss the feature with us. Please, consider to read the `CONTRIBUTING <https://github.com/arraiyopensource/kornia/blob/master/CONTRIBUTING.rst>`_ notes.
diff --git a/docs/Makefile b/docs/Makefile
index 0d74eef25..316e362da 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
-SPHINXPROJ = torchgeometry
+SPHINXPROJ = kornia
SOURCEDIR = source
BUILDDIR = build
diff --git a/docs/source/_static/img/kornia_logo.svg b/docs/source/_static/img/kornia_logo.svg
new file mode 100644
index 000000000..dd7e3ff51
--- /dev/null
+++ b/docs/source/_static/img/kornia_logo.svg
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="Layer_1"
+ x="0px"
+ y="0px"
+ viewBox="0 0 610 160"
+ xml:space="preserve"
+ sodipodi:docname="kornai_logo.svg"
+ width="610"
+ height="160"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
+ id="metadata4166"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
+ id="defs4164"><clipPath
+ id="clipPath20"
+ clipPathUnits="userSpaceOnUse"><path
+ id="path22"
+ d="M 0,256 H 787.274 V 0 H 0 Z"
+ inkscape:connector-curvature="0" /></clipPath></defs><sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1299"
+ inkscape:window-height="713"
+ id="namedview4162"
+ showgrid="false"
+ inkscape:snap-text-baseline="true"
+ inkscape:zoom="1.4142136"
+ inkscape:cx="256.09235"
+ inkscape:cy="-4.3199171"
+ inkscape:window-x="67"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="g4285"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:measure-start="5.39155e-06,112.499"
+ inkscape:measure-end="63.1753,74"><sodipodi:guide
+ position="188.0904,85"
+ orientation="0,1"
+ id="guide1151"
+ inkscape:locked="false"
+ inkscape:label=""
+ inkscape:color="rgb(0,0,255)" /><sodipodi:guide
+ position="610,19.979676"
+ orientation="1,0"
+ id="guide1153"
+ inkscape:locked="false"
+ inkscape:label=""
+ inkscape:color="rgb(0,0,255)" /><sodipodi:guide
+ position="105,103.5721"
+ orientation="1,0"
+ id="guide1155"
+ inkscape:locked="false" /><sodipodi:guide
+ position="145,19.979676"
+ orientation="1,0"
+ id="guide1159"
+ inkscape:locked="false"
+ inkscape:label=""
+ inkscape:color="rgb(0,0,255)" /><sodipodi:guide
+ position="63.789695,-1.3686142e-06"
+ orientation="0,1"
+ id="guide1161"
+ inkscape:locked="false" /><sodipodi:guide
+ position="0,74"
+ orientation="1,0"
+ id="guide1163"
+ inkscape:locked="false" /><sodipodi:guide
+ position="67.140101,125.61907"
+ orientation="1,0"
+ id="guide1184"
+ inkscape:locked="false" /><sodipodi:guide
+ position="580,31.952388"
+ orientation="1,0"
+ id="guide73"
+ inkscape:locked="false"
+ inkscape:label=""
+ inkscape:color="rgb(0,0,255)" /><sodipodi:guide
+ position="73.789713,160"
+ orientation="0,1"
+ id="guide75"
+ inkscape:locked="false"
+ inkscape:label=""
+ inkscape:color="rgb(0,0,255)" /><sodipodi:guide
+ position="30,85"
+ orientation="1,0"
+ id="guide115"
+ inkscape:locked="false"
+ inkscape:label=""
+ inkscape:color="rgb(0,0,255)" /></sodipodi:namedview>
+<style
+ type="text/css"
+ id="style4135">
+ .st0{fill:#EE4C2C;}
+ .st1{fill:#252525;}
+</style>
+
+
+<g
+ id="g4169"
+ transform="matrix(0.01254343,0,0,-0.01254343,87.294429,82.620175)"><g
+ id="g12"
+ transform="matrix(29.293123,0,0,29.828611,-4567.6833,2088.1565)"><path
+ inkscape:connector-curvature="0"
+ d="M 0,0 101.079,58.924 204.117,-0.001 V -117.847 L 102.062,-176.764 0,-117.845 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path14" /></g><g
+ id="g16"
+ transform="matrix(29.293123,0,0,29.828611,-2360.0634,-53.581135)"
+ style="fill:none;fill-opacity:1;stroke:#a0b4c8;stroke-opacity:1"><g
+ id="g18"
+ clip-path="url(#clipPath20)"
+ transform="translate(6.1133073e-6,2.1524702e-6)"
+ style="fill:none;fill-opacity:1;stroke:#a0b4c8;stroke-opacity:1"><g
+ id="g24"
+ transform="translate(165.1074,186.9204)"
+ style="fill:none;fill-opacity:1;stroke:#a0b4c8;stroke-opacity:1" /></g></g><g
+ id="g28"
+ transform="matrix(32.401339,0,0,32.993649,-1355.1965,283.75836)"><path
+ inkscape:connector-curvature="0"
+ d="M -1.087391,0 55.82461,32.491 55.49661,-32.844 -1.087391,-65.589 Z"
+ style="fill:#2a6d9b;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path30" /></g><g
+ id="g32"
+ transform="matrix(32.401339,0,0,32.993649,-3436.3007,1684.4478)"
+ style="fill:#ff0000"><path
+ inkscape:connector-curvature="0"
+ d="M -0.88117326,0 56.223821,33.143 114.27598,0 56.476821,-32.645 Z"
+ style="fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path34" /></g><g
+ id="g28-1"
+ transform="matrix(-32.401339,0,0,32.993649,-1826.7904,283.75836)"
+ style="fill:#00ff00"><path
+ inkscape:connector-curvature="0"
+ d="M 0,0 56.912,32.491 56.584,-32.844 0,-65.589 Z"
+ style="fill:#00ff00;fill-opacity:1;fill-rule:nonzero;stroke:none"
+ id="path30-0" /></g></g><g
+ id="g4285"
+ transform="matrix(11.512843,0,0,11.51284,-1062.3103,-394.41039)"
+ style="fill:#333333"><text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:discretionary-ligatures;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ x="103.84724"
+ y="45.551811"
+ id="text5094"><tspan
+ sodipodi:role="line"
+ id="tspan5092"
+ x="103.84724"
+ y="45.551811"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.739398px;line-height:0;font-family:Ubuntu;-inkscape-font-specification:'Ubuntu, Normal';font-variant-ligatures:discretionary-ligatures;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1">kornia</tspan></text>
+
+
+
+
+
+
+
+
+
+<flowRoot
+ xml:space="preserve"
+ id="flowRoot280"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:discretionary-ligatures;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#333333;fill-opacity:1;stroke:none"
+ transform="matrix(0.08685954,0,0,0.08685954,86.11026,30.079963)"><flowRegion
+ id="flowRegion282"
+ style="fill:#333333"><rect
+ id="rect284"
+ width="138"
+ height="76"
+ x="379"
+ y="61.574005"
+ style="fill:#333333" /></flowRegion><flowPara
+ id="flowPara286" /></flowRoot></g></svg>
\ No newline at end of file
diff --git a/docs/source/_static/img/torchgeometry_logo.svg b/docs/source/_static/img/torchgeometry_logo.svg
deleted file mode 100644
index 0b57fadb1..000000000
--- a/docs/source/_static/img/torchgeometry_logo.svg
+++ /dev/null
@@ -1,160 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- version="1.1"
- id="Layer_1"
- x="0px"
- y="0px"
- viewBox="0 0 910 261.574"
- xml:space="preserve"
- sodipodi:docname="torchgeometry_logo.svg"
- width="910"
- height="261.57401"
- inkscape:version="0.92.3 (2405546, 2018-03-11)"><metadata
- id="metadata4166"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
- id="defs4164"><clipPath
- id="clipPath20"
- clipPathUnits="userSpaceOnUse"><path
- id="path22"
- d="M 0,256 H 787.274 V 0 H 0 Z"
- inkscape:connector-curvature="0" /></clipPath></defs><sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1299"
- inkscape:window-height="713"
- id="namedview4162"
- showgrid="false"
- inkscape:snap-text-baseline="true"
- inkscape:zoom="1"
- inkscape:cx="429.9915"
- inkscape:cy="242.64115"
- inkscape:window-x="67"
- inkscape:window-y="27"
- inkscape:window-maximized="1"
- inkscape:current-layer="g4169"
- showguides="true"
- inkscape:guide-bbox="true" />
-<style
- type="text/css"
- id="style4135">
- .st0{fill:#EE4C2C;}
- .st1{fill:#252525;}
-</style>
-
-<g
- id="g4159"
- transform="matrix(5.226194,0,0,5.226194,-26.302096,-3.84007)">
- <g
- id="g4157">
- <path
- class="st1"
- d="M 62.6,20 H 59 v 9.3 H 56.3 V 2.9 c 0,0 6.3,0 6.6,0 7,0 10.3,3.4 10.3,8.3 0,5.8 -4.1,8.7 -10.6,8.8 z M 62.8,5.4 c -0.3,0 -3.9,0 -3.9,0 v 12.1 l 3.8,-0.1 c 5,-0.1 7.7,-2.1 7.7,-6.2 0,-3.7 -2.6,-5.8 -7.6,-5.8 z"
- id="path4143"
- inkscape:connector-curvature="0"
- style="fill:#252525" />
- <path
- class="st1"
- d="m 85.4,29.2 -1.6,4.2 c -1.8,4.7 -3.6,6.1 -6.3,6.1 -1.5,0 -2.6,-0.4 -3.8,-0.9 l 0.8,-2.4 c 0.9,0.5 1.9,0.8 3,0.8 1.5,0 2.6,-0.8 4,-4.5 L 82.8,29.1 75.3,10 h 2.8 l 6.1,16 6,-16 h 2.7 z"
- id="path4145"
- inkscape:connector-curvature="0"
- style="fill:#252525" />
- <path
- class="st1"
- d="M 101.9,5.5 V 29.4 H 99.2 V 5.5 H 89.9 V 2.9 h 21.3 v 2.5 h -9.3 z"
- id="path4147"
- inkscape:connector-curvature="0"
- style="fill:#252525" />
- <path
- class="st1"
- d="m 118.8,29.9 c -5.4,0 -9.4,-4 -9.4,-10.2 0,-6.2 4.1,-10.3 9.6,-10.3 5.4,0 9.3,4 9.3,10.2 0,6.2 -4.1,10.3 -9.5,10.3 z m 0.1,-18.1 c -4.1,0 -6.8,3.3 -6.8,7.8 0,4.7 2.8,7.9 6.9,7.9 4.1,0 6.8,-3.3 6.8,-7.8 0,-4.7 -2.8,-7.9 -6.9,-7.9 z"
- id="path4149"
- inkscape:connector-curvature="0"
- style="fill:#252525" />
- <path
- class="st1"
- d="m 135,29.4 h -2.6 V 10 L 135,9.5 v 4.1 c 1.3,-2.5 3.2,-4.1 5.7,-4.1 1.3,0 2.5,0.4 3.4,0.9 l -0.7,2.5 c -0.8,-0.5 -1.9,-0.8 -3,-0.8 -2,0 -3.9,1.5 -5.5,5 v 12.3 z"
- id="path4151"
- inkscape:connector-curvature="0"
- style="fill:#252525" />
- <path
- class="st1"
- d="m 154.4,29.9 c -5.8,0 -9.5,-4.2 -9.5,-10.2 0,-6.1 4,-10.3 9.5,-10.3 2.4,0 4.4,0.6 6.1,1.7 l -0.7,2.4 c -1.5,-1 -3.3,-1.6 -5.4,-1.6 -4.2,0 -6.8,3.1 -6.8,7.7 0,4.7 2.8,7.8 6.9,7.8 1.9,0 3.9,-0.6 5.4,-1.6 l 0.5,2.4 c -1.7,1.1 -3.8,1.7 -6,1.7 z"
- id="path4153"
- inkscape:connector-curvature="0"
- style="fill:#252525" />
- <path
- class="st1"
- d="M 176.7,29.4 V 16.9 c 0,-3.4 -1.4,-4.9 -4.1,-4.9 -2.2,0 -4.4,1.1 -6,2.8 V 29.5 H 164 V 0.9 l 2.6,-0.5 c 0,0 0,12.1 0,12.2 2,-2 4.6,-3.1 6.7,-3.1 3.8,0 6.1,2.4 6.1,6.6 v 13.3 z"
- id="path4155"
- inkscape:connector-curvature="0"
- style="fill:#252525" />
- </g>
-</g>
-<g
- id="g4169"
- transform="matrix(0.03835147,0,0,-0.03835147,57.507716,269.48684)"><g
- id="g12"
- transform="matrix(24.449263,0,0,24.449263,-1274.4445,5201.1662)"><path
- inkscape:connector-curvature="0"
- d="M 0,0 101.079,58.924 204.117,-0.001 V -117.847 L 102.062,-176.764 0,-117.845 Z"
- style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
- id="path14" /></g><g
- id="g16"
- transform="matrix(24.449263,0,0,24.449263,-1767.8935,634.97849)"
- style="fill:none;fill-opacity:1;stroke:#a0b4c8;stroke-opacity:1"><g
- id="g18"
- clip-path="url(#clipPath20)"
- transform="translate(6.1133073e-6,2.1524702e-6)"
- style="fill:none;fill-opacity:1;stroke:#a0b4c8;stroke-opacity:1"><g
- id="g24"
- transform="translate(165.1074,186.9204)"
- style="fill:none;fill-opacity:1;stroke:#a0b4c8;stroke-opacity:1"><path
- inkscape:connector-curvature="0"
- d="M -144.91425,-6.643053e-8 -43.83525,58.924 59.20275,-0.00100007 V -117.847 l -102.055,-58.917 -102.062,58.919 z"
- style="fill:none;fill-opacity:1;stroke:#a0b4c8;stroke-width:15.70647526;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
- id="path26" /></g></g></g><g
- id="g28"
- transform="matrix(24.449263,0,0,24.449263,1377.5908,3685.3439)"><path
- inkscape:connector-curvature="0"
- d="M 0,0 56.912,32.491 56.584,-32.844 0,-65.589 Z"
- style="fill:#2a6d9b;fill-opacity:1;fill-rule:nonzero;stroke:none"
- id="path30" /></g><g
- id="g32"
- transform="matrix(24.449263,0,0,24.449263,-177.89562,4723.2941)"><path
- inkscape:connector-curvature="0"
- d="M 0,0 57.105,33.143 115.157,0 57.358,-32.645 Z"
- style="fill:#c1c1c1;fill-opacity:1;fill-rule:nonzero;stroke:none"
- id="path34" /></g></g><g
- id="g4285"
- transform="matrix(5.7898777,0,0,5.7898777,-138.74361,-23.18425)"><text
- xml:space="preserve"
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:discretionary-ligatures;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#252525;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- x="103.84724"
- y="45.551811"
- id="text5094"><tspan
- sodipodi:role="line"
- id="tspan5092"
- x="103.84724"
- y="45.551811"
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:discretionary-ligatures;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#252525;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1">geometry</tspan></text>
-
-
-
-
-</g></svg>
\ No newline at end of file
diff --git a/docs/source/color.rst b/docs/source/color.rst
index 2a31c0700..0e00a3220 100644
--- a/docs/source/color.rst
+++ b/docs/source/color.rst
@@ -1,7 +1,7 @@
-torchgeometry.color
+kornia.color
-------------------
-.. currentmodule:: torchgeometry.color
+.. currentmodule:: kornia.color
The functions in this section perform various color space conversions.
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 54bc355e9..fb5c81d63 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -7,7 +7,7 @@ import sphinx_rtd_theme
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
-base_path = os.path.abspath(os.path.join(__file__, "..", "..", "..", "torchgeometry"))
+base_path = os.path.abspath(os.path.join(__file__, "..", "..", "..", "kornia"))
sys.path.append(base_path)
# -- General configuration ------------------------------------------------
@@ -60,12 +60,12 @@ author = u'Arraiy, Inc.'
# |version| and |release|, also used in various other places throughout the
# built documents.
-#version = 'master (' + torchgeometry.__version__ + ' )'
+#version = 'master (' + kornia.__version__ + ' )'
version = ''
if 'READTHEDOCS' not in os.environ:
# if developing locally, use pyro.__version__ as version
- from torchgeometry import __version__ # noqaE402
+ from kornia import __version__ # noqaE402
version = __version__
#release = 'master'
@@ -110,7 +110,7 @@ html_theme_options = {
'logo_only': True,
}
-html_logo = '_static/img/torchgeometry_logo.svg'
+html_logo = '_static/img/kornia_logo.svg'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
@@ -176,8 +176,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- (master_doc, 'torchgeometry', 'torchgeometry Documentation',
- author, 'torchgeometry', 'One line description of project.',
+ (master_doc, 'kornia', 'kornia Documentation',
+ author, 'kornia', 'One line description of project.',
'Miscellaneous'),
]
diff --git a/docs/source/contrib.rst b/docs/source/contrib.rst
index c9931994d..3deff654f 100644
--- a/docs/source/contrib.rst
+++ b/docs/source/contrib.rst
@@ -1,7 +1,7 @@
-torchgeometry.contrib
+kornia.contrib
=====================
-.. currentmodule:: torchgeometry.contrib
+.. currentmodule:: kornia.contrib
.. autofunction:: spatial_soft_argmax2d
.. autofunction:: extract_tensor_patches
diff --git a/docs/source/feature.rst b/docs/source/feature.rst
index 91a1958f5..46da1f63a 100644
--- a/docs/source/feature.rst
+++ b/docs/source/feature.rst
@@ -1,7 +1,7 @@
-torchgeometry.feature
+kornia.feature
=====================
-.. currentmodule:: torchgeometry.feature
+.. currentmodule:: kornia.feature
.. autofunction:: corner_harris
.. autofunction:: non_maxima_suppression2d
diff --git a/docs/source/filters.rst b/docs/source/filters.rst
index 427c45991..73395bd11 100644
--- a/docs/source/filters.rst
+++ b/docs/source/filters.rst
@@ -1,7 +1,7 @@
-torchgeometry.filters
+kornia.filters
---------------------
-.. currentmodule:: torchgeometry.filters
+.. currentmodule:: kornia.filters
The functions in this sections perform various image filtering operations.
diff --git a/docs/source/geometry.camera.rst b/docs/source/geometry.camera.rst
index c1e54fa8e..bb01376c9 100644
--- a/docs/source/geometry.camera.rst
+++ b/docs/source/geometry.camera.rst
@@ -1,7 +1,7 @@
-torchgeometry.geometry.camera
+kornia.geometry.camera
=============================
-.. currentmodule:: torchgeometry.geometry.camera
+.. currentmodule:: kornia.geometry.camera
.. toctree::
:maxdepth: 2
diff --git a/docs/source/geometry.conversions.rst b/docs/source/geometry.conversions.rst
index eaec327c8..403576fd9 100644
--- a/docs/source/geometry.conversions.rst
+++ b/docs/source/geometry.conversions.rst
@@ -1,7 +1,7 @@
-torchgeometry.geometry.conversions
+kornia.geometry.conversions
==================================
-.. currentmodule:: torchgeometry.geometry.conversions
+.. currentmodule:: kornia.geometry.conversions
.. autofunction:: rad2deg
.. autofunction:: deg2rad
diff --git a/docs/source/geometry.linalg.rst b/docs/source/geometry.linalg.rst
index 6cea3ad81..ed92adc17 100644
--- a/docs/source/geometry.linalg.rst
+++ b/docs/source/geometry.linalg.rst
@@ -1,7 +1,7 @@
-torchgeometry.geometry.linalg
+kornia.geometry.linalg
=============================
-.. currentmodule:: torchgeometry.geometry.linalg
+.. currentmodule:: kornia.geometry.linalg
.. autofunction:: relative_transformation
diff --git a/docs/source/geometry.rst b/docs/source/geometry.rst
index 89b63e096..69198d751 100644
--- a/docs/source/geometry.rst
+++ b/docs/source/geometry.rst
@@ -1,7 +1,7 @@
-torchgeometry.geometry
+kornia.geometry
======================
-.. currentmodule:: torchgeometry.geometry
+.. currentmodule:: kornia.geometry
.. toctree::
:maxdepth: 2
diff --git a/docs/source/geometry.transform.rst b/docs/source/geometry.transform.rst
index 90de04e36..d887aa160 100644
--- a/docs/source/geometry.transform.rst
+++ b/docs/source/geometry.transform.rst
@@ -1,7 +1,7 @@
-torchgeometry.geometry.transform
+kornia.geometry.transform
================================
-.. currentmodule:: torchgeometry.geometry.transform
+.. currentmodule:: kornia.geometry.transform
The functions in this section perform various geometrical transformations of 2D images.
diff --git a/docs/source/geometry.warp.rst b/docs/source/geometry.warp.rst
index 0a6df83fd..f620faa30 100644
--- a/docs/source/geometry.warp.rst
+++ b/docs/source/geometry.warp.rst
@@ -1,7 +1,7 @@
-torchgeometry.geometry.warp
+kornia.geometry.warp
===========================
-.. currentmodule:: torchgeometry.geometry.warp
+.. currentmodule:: kornia.geometry.warp
.. autoclass:: HomographyWarper
:members:
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 2451be781..3dff46428 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -1,6 +1,6 @@
-:github_url: https://github.com/arraiy/torchgeometry
+:github_url: https://github.com/arraiy/kornia
-torchgeometry
+kornia
=============
The *PyTorch Geometry* (TGM) package is a geometric computer vision library for `PyTorch <https://pytorch.org/>`_.
diff --git a/docs/source/losses.rst b/docs/source/losses.rst
index 1ff8d066e..e469aaf4b 100644
--- a/docs/source/losses.rst
+++ b/docs/source/losses.rst
@@ -1,7 +1,7 @@
-torchgeometry.losses
+kornia.losses
====================
-.. currentmodule:: torchgeometry.losses
+.. currentmodule:: kornia.losses
.. autofunction:: dice_loss
.. autofunction:: tversky_loss
diff --git a/docs/source/pinhole.rst b/docs/source/pinhole.rst
index 92684c6ee..e97d79d8d 100644
--- a/docs/source/pinhole.rst
+++ b/docs/source/pinhole.rst
@@ -1,7 +1,7 @@
Pinhole Camera
--------------
-.. currentmodule:: torchgeometry.geometry.camera
+.. currentmodule:: kornia.geometry.camera
In this module we have all the functions and data structures needed to describe the projection of a 3D scene space onto a 2D image plane.
diff --git a/docs/source/utils.metrics.rst b/docs/source/utils.metrics.rst
index 9ff8e95f9..4171c1e60 100644
--- a/docs/source/utils.metrics.rst
+++ b/docs/source/utils.metrics.rst
@@ -1,7 +1,7 @@
-torchgeometry.utils.metrics
+kornia.utils.metrics
===========================
-.. currentmodule:: torchgeometry.utils.metrics
+.. currentmodule:: kornia.utils.metrics
.. autofunction:: confusion_matrix
.. autofunction:: mean_iou
diff --git a/docs/source/utils.rst b/docs/source/utils.rst
index 6699410a5..9ae8b465b 100644
--- a/docs/source/utils.rst
+++ b/docs/source/utils.rst
@@ -1,7 +1,7 @@
-torchgeometry.utils
+kornia.utils
===================
-.. currentmodule:: torchgeometry.utils
+.. currentmodule:: kornia.utils
.. autofunction:: tensor_to_image
.. autofunction:: image_to_tensor
diff --git a/torchgeometry/__init__.py b/kornia/__init__.py
similarity index 55%
rename from torchgeometry/__init__.py
rename to kornia/__init__.py
index 5db1f45e6..4410dce8e 100644
--- a/torchgeometry/__init__.py
+++ b/kornia/__init__.py
@@ -1,22 +1,22 @@
-# Make sure that torchgeometry is running on Python 3.6.0 or later
+# Make sure that kornia is running on Python 3.6.0 or later
# (to avoid running into this bug: https://bugs.python.org/issue29246)
import sys
if sys.version_info < (3, 6, 0):
- raise RuntimeError("Pytorch Geometry requires Python 3.6.0 or later")
+ raise RuntimeError("Kornia requires Python 3.6.0 or later")
from .version import __version__
-from torchgeometry import color
-from torchgeometry import contrib
-from torchgeometry import feature
-from torchgeometry import filters
-from torchgeometry import geometry
-from torchgeometry import losses
-from torchgeometry import utils
+from kornia import color
+from kornia import contrib
+from kornia import feature
+from kornia import filters
+from kornia import geometry
+from kornia import losses
+from kornia import utils
# Exposes package functional to top level
-from torchgeometry.color import (
+from kornia.color import (
rgb_to_grayscale,
bgr_to_rgb,
rgb_to_bgr,
@@ -24,16 +24,16 @@ from torchgeometry.color import (
hsv_to_rgb,
normalize,
)
-from torchgeometry.contrib import (
+from kornia.contrib import (
spatial_soft_argmax2d,
extract_tensor_patches,
max_blur_pool2d,
)
-from torchgeometry.feature import (
+from kornia.feature import (
non_maxima_suppression2d,
corner_harris,
)
-from torchgeometry.filters import (
+from kornia.filters import (
get_gaussian_kernel,
get_gaussian_kernel2d,
get_laplacian_kernel,
@@ -45,16 +45,16 @@ from torchgeometry.filters import (
box_blur,
median_blur,
)
-from torchgeometry.losses import (
+from kornia.losses import (
ssim,
dice_loss,
tversky_loss,
inverse_depth_smoothness_loss,
)
-from torchgeometry.utils import (
+from kornia.utils import (
one_hot,
create_meshgrid,
tensor_to_image,
image_to_tensor,
)
-from torchgeometry.geometry import *
+from kornia.geometry import *
diff --git a/torchgeometry/color/__init__.py b/kornia/color/__init__.py
similarity index 100%
rename from torchgeometry/color/__init__.py
rename to kornia/color/__init__.py
diff --git a/torchgeometry/color/gray.py b/kornia/color/gray.py
similarity index 93%
rename from torchgeometry/color/gray.py
rename to kornia/color/gray.py
index 82c15f615..5667bca41 100644
--- a/torchgeometry/color/gray.py
+++ b/kornia/color/gray.py
@@ -20,7 +20,7 @@ class RgbToGrayscale(nn.Module):
Examples::
>>> input = torch.rand(2, 3, 4, 5)
- >>> gray = tgm.image.RgbToGrayscale()
+ >>> gray = kornia.image.RgbToGrayscale()
>>> output = gray(input) # 2x1x4x5
"""
@@ -34,7 +34,7 @@ class RgbToGrayscale(nn.Module):
def rgb_to_grayscale(input: torch.Tensor) -> torch.Tensor:
r"""Convert an RGB image to grayscale.
- See :class:`~torchgeometry.color.RgbToGrayscale` for details.
+ See :class:`~kornia.color.RgbToGrayscale` for details.
Args:
input (torch.Tensor): Image to be converted to grayscale.
diff --git a/torchgeometry/color/hsv.py b/kornia/color/hsv.py
similarity index 100%
rename from torchgeometry/color/hsv.py
rename to kornia/color/hsv.py
diff --git a/torchgeometry/color/normalize.py b/kornia/color/normalize.py
similarity index 97%
rename from torchgeometry/color/normalize.py
rename to kornia/color/normalize.py
index 870c3126b..02207b3a5 100644
--- a/torchgeometry/color/normalize.py
+++ b/kornia/color/normalize.py
@@ -35,7 +35,7 @@ def normalize(data: torch.Tensor, mean: torch.Tensor,
std: torch.Tensor) -> torch.Tensor:
r"""Normalise the image with channel-wise mean and standard deviation.
- See :class:`~torchgeometry.color.Normalize` for details.
+ See :class:`~kornia.color.Normalize` for details.
Args:
data (torch.Tensor): The image tensor to be normalised.
diff --git a/torchgeometry/color/rgb.py b/kornia/color/rgb.py
similarity index 94%
rename from torchgeometry/color/rgb.py
rename to kornia/color/rgb.py
index 7898f07f4..36a86ddd3 100644
--- a/torchgeometry/color/rgb.py
+++ b/kornia/color/rgb.py
@@ -29,7 +29,7 @@ class RgbToBgr(nn.Module):
def rgb_to_bgr(image: torch.Tensor) -> torch.Tensor:
r"""Convert a RGB image to BGR.
- See :class:`~torchgeometry.color.RgbToBgr` for details.
+ See :class:`~kornia.color.RgbToBgr` for details.
Args:
input (torch.Tensor): RGB Image to be converted to BGR.
@@ -68,7 +68,7 @@ class BgrToRgb(nn.Module):
def bgr_to_rgb(image: torch.Tensor) -> torch.Tensor:
r"""Convert a BGR image to RGB.
- See :class:`~torchgeometry.color.BgrToRgb` for details.
+ See :class:`~kornia.color.BgrToRgb` for details.
Args:
input (torch.Tensor): BGR Image to be converted to RGB.
diff --git a/torchgeometry/contrib/__init__.py b/kornia/contrib/__init__.py
similarity index 100%
rename from torchgeometry/contrib/__init__.py
rename to kornia/contrib/__init__.py
diff --git a/torchgeometry/contrib/extract_patches.py b/kornia/contrib/extract_patches.py
similarity index 97%
rename from torchgeometry/contrib/extract_patches.py
rename to kornia/contrib/extract_patches.py
index 0f124fe29..10d7619b6 100644
--- a/torchgeometry/contrib/extract_patches.py
+++ b/kornia/contrib/extract_patches.py
@@ -58,7 +58,7 @@ class ExtractTensorPatches(nn.Module):
Examples:
>>> input = torch.arange(9.).view(1, 1, 3, 3)
- >>> patches = tgm.contrib.extract_tensor_patches(input, (2, 3))
+ >>> patches = kornia.contrib.extract_tensor_patches(input, (2, 3))
>>> input
tensor([[[[0., 1., 2.],
[3., 4., 5.],
@@ -133,6 +133,6 @@ def extract_tensor_patches(
padding: Optional[Union[int, Tuple[int, int]]] = 0) -> torch.Tensor:
r"""Function that extract patches from tensors and stack them.
- See :class:`~torchgeometry.contrib.ExtractTensorPatches` for details.
+ See :class:`~kornia.contrib.ExtractTensorPatches` for details.
"""
return ExtractTensorPatches(window_size, stride, padding)(input)
diff --git a/torchgeometry/contrib/max_blur_pool.py b/kornia/contrib/max_blur_pool.py
similarity index 91%
rename from torchgeometry/contrib/max_blur_pool.py
rename to kornia/contrib/max_blur_pool.py
index d5d226da0..af2274a42 100644
--- a/torchgeometry/contrib/max_blur_pool.py
+++ b/kornia/contrib/max_blur_pool.py
@@ -4,7 +4,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.geometry.transform.pyramid import pyrdown
+from kornia.geometry.transform.pyramid import pyrdown
__all__ = [
"max_blur_pool2d",
@@ -36,7 +36,7 @@ class MaxBlurPool2d(nn.Module):
Examples:
>>> input = torch.rand(1, 4, 4, 8)
- >>> pool = tgm.contrib.MaxblurPool2d(kernel_size=3)
+ >>> pool = kornia.contrib.MaxblurPool2d(kernel_size=3)
>>> output = pool(input) # 1x4x2x4
"""
@@ -71,6 +71,6 @@ def max_blur_pool2d(input: torch.Tensor, kernel_size: int) -> torch.Tensor:
r"""Creates a module that computes pools and blurs and downsample a given
feature map.
- See :class:`~torchgeometry.contrib.MaxBlurPool2d` for details.
+ See :class:`~kornia.contrib.MaxBlurPool2d` for details.
"""
return MaxBlurPool2d(kernel_size)(input)
diff --git a/torchgeometry/contrib/spatial_soft_argmax2d.py b/kornia/contrib/spatial_soft_argmax2d.py
similarity index 96%
rename from torchgeometry/contrib/spatial_soft_argmax2d.py
rename to kornia/contrib/spatial_soft_argmax2d.py
index 7508d298a..279460a9e 100644
--- a/torchgeometry/contrib/spatial_soft_argmax2d.py
+++ b/kornia/contrib/spatial_soft_argmax2d.py
@@ -41,7 +41,7 @@ class SpatialSoftArgmax2d(nn.Module):
Examples::
>>> input = torch.rand(1, 4, 2, 3)
- >>> m = tgm.losses.SpatialSoftArgmax2d()
+ >>> m = kornia.losses.SpatialSoftArgmax2d()
>>> coords = m(input) # 1x4x2
>>> x_coord, y_coord = torch.chunk(coords, dim=-1, chunks=2)
"""
@@ -91,6 +91,6 @@ def spatial_soft_argmax2d(
normalized_coordinates: Optional[bool] = True) -> torch.Tensor:
r"""Function that computes the Spatial Soft-Argmax 2D of a given heatmap.
- See :class:`~torchgeometry.contrib.SpatialSoftArgmax2d` for details.
+ See :class:`~kornia.contrib.SpatialSoftArgmax2d` for details.
"""
return SpatialSoftArgmax2d(normalized_coordinates)(input)
diff --git a/torchgeometry/feature/__init__.py b/kornia/feature/__init__.py
similarity index 100%
rename from torchgeometry/feature/__init__.py
rename to kornia/feature/__init__.py
diff --git a/torchgeometry/feature/harris.py b/kornia/feature/harris.py
similarity index 93%
rename from torchgeometry/feature/harris.py
rename to kornia/feature/harris.py
index 95bb41487..66d70a0ac 100644
--- a/torchgeometry/feature/harris.py
+++ b/kornia/feature/harris.py
@@ -4,8 +4,8 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.feature.nms import non_maxima_suppression2d
-from torchgeometry.filters import spatial_gradient, gaussian_blur
+from kornia.feature.nms import non_maxima_suppression2d
+from kornia.filters import spatial_gradient, gaussian_blur
class CornerHarris(nn.Module):
@@ -49,7 +49,7 @@ class CornerHarris(nn.Module):
[0., 0., 0., 0., 0., 0., 0.],
]]]) # 1x1x7x7
>>> # compute the response map
- >>> output = tgm.feature.CornerHarris()(input)
+ >>> output = kornia.feature.CornerHarris()(input)
tensor([[[[0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 1., 0.],
[0., 0., 0., 0., 0., 0., 0.],
@@ -110,6 +110,6 @@ class CornerHarris(nn.Module):
def corner_harris(input: torch.Tensor, k: torch.Tensor) -> torch.Tensor:
r"""Computes the Harris corner detection.
- See :class:`~torchgeometry.feature.CornerHarris` for details.
+ See :class:`~kornia.feature.CornerHarris` for details.
"""
return CornerHarris(k)(input)
diff --git a/torchgeometry/feature/nms.py b/kornia/feature/nms.py
similarity index 95%
rename from torchgeometry/feature/nms.py
rename to kornia/feature/nms.py
index e52063c5d..06c909595 100644
--- a/torchgeometry/feature/nms.py
+++ b/kornia/feature/nms.py
@@ -47,6 +47,6 @@ def non_maxima_suppression2d(
input: torch.Tensor, kernel_size: Tuple[int, int]) -> torch.Tensor:
r"""Applies non maxima suppression to filter.
- See :class:`~torchgeometry.feature.NonMaximaSuppression2d` for details.
+ See :class:`~kornia.feature.NonMaximaSuppression2d` for details.
"""
return NonMaximaSuppression2d(kernel_size)(input)
diff --git a/torchgeometry/filters/__init__.py b/kornia/filters/__init__.py
similarity index 100%
rename from torchgeometry/filters/__init__.py
rename to kornia/filters/__init__.py
diff --git a/torchgeometry/filters/blur.py b/kornia/filters/blur.py
similarity index 96%
rename from torchgeometry/filters/blur.py
rename to kornia/filters/blur.py
index 083ccaea2..fd5a91972 100644
--- a/torchgeometry/filters/blur.py
+++ b/kornia/filters/blur.py
@@ -46,7 +46,7 @@ class BoxBlur(nn.Module):
Example:
>>> input = torch.rand(2, 4, 5, 7)
- >>> blur = tgm.filters.BoxBlur((3, 3))
+ >>> blur = kornia.filters.BoxBlur((3, 3))
>>> output = blur(input) # 2x4x5x7
"""
@@ -76,6 +76,6 @@ class BoxBlur(nn.Module):
def box_blur(input: torch.Tensor, kernel_size: Tuple[int, int]) -> torch.Tensor:
r"""Blurs an image using the box filter.
- See :class:`~torchgeometry.filters.BoxBlur` for details.
+ See :class:`~kornia.filters.BoxBlur` for details.
"""
return BoxBlur(kernel_size)(input)
diff --git a/torchgeometry/filters/gaussian.py b/kornia/filters/gaussian.py
similarity index 93%
rename from torchgeometry/filters/gaussian.py
rename to kornia/filters/gaussian.py
index aa9dc478f..9bd99285c 100644
--- a/torchgeometry/filters/gaussian.py
+++ b/kornia/filters/gaussian.py
@@ -28,10 +28,10 @@ def get_gaussian_kernel(kernel_size: int, sigma: float) -> torch.Tensor:
Examples::
- >>> tgm.image.get_gaussian_kernel(3, 2.5)
+ >>> kornia.image.get_gaussian_kernel(3, 2.5)
tensor([0.3243, 0.3513, 0.3243])
- >>> tgm.image.get_gaussian_kernel(5, 1.5)
+ >>> kornia.image.get_gaussian_kernel(5, 1.5)
tensor([0.1201, 0.2339, 0.2921, 0.2339, 0.1201])
"""
if not isinstance(kernel_size, int) or kernel_size % 2 == 0 or \
@@ -60,12 +60,12 @@ def get_gaussian_kernel2d(kernel_size: Tuple[int, int],
Examples::
- >>> tgm.image.get_gaussian_kernel2d((3, 3), (1.5, 1.5))
+ >>> kornia.image.get_gaussian_kernel2d((3, 3), (1.5, 1.5))
tensor([[0.0947, 0.1183, 0.0947],
[0.1183, 0.1478, 0.1183],
[0.0947, 0.1183, 0.0947]])
- >>> tgm.image.get_gaussian_kernel2d((3, 5), (1.5, 1.5))
+ >>> kornia.image.get_gaussian_kernel2d((3, 5), (1.5, 1.5))
tensor([[0.0370, 0.0720, 0.0899, 0.0720, 0.0370],
[0.0462, 0.0899, 0.1123, 0.0899, 0.0462],
[0.0370, 0.0720, 0.0899, 0.0720, 0.0370]])
@@ -105,7 +105,7 @@ class GaussianBlur(nn.Module):
Examples::
>>> input = torch.rand(2, 4, 5, 5)
- >>> gauss = tgm.filters.GaussianBlur((3, 3), (1.5, 1.5))
+ >>> gauss = kornia.filters.GaussianBlur((3, 3), (1.5, 1.5))
>>> output = gauss(input) # 2x4x5x5
"""
@@ -153,6 +153,6 @@ def gaussian_blur(input: torch.Tensor,
float]) -> torch.Tensor:
r"""Function that blurs a tensor using a Gaussian filter.
- See :class:`~torchgeometry.filters.GaussianBlur` for details.
+ See :class:`~kornia.filters.GaussianBlur` for details.
"""
return GaussianBlur(kernel_size, sigma)(input)
diff --git a/torchgeometry/filters/laplacian.py b/kornia/filters/laplacian.py
similarity index 93%
rename from torchgeometry/filters/laplacian.py
rename to kornia/filters/laplacian.py
index 4d13ef963..bd253b176 100644
--- a/torchgeometry/filters/laplacian.py
+++ b/kornia/filters/laplacian.py
@@ -29,10 +29,10 @@ def get_laplacian_kernel(kernel_size: int) -> torch.Tensor:
- Output: math:`(\text{kernel_size})`
Examples::
- >>> tgm.image.get_laplacian_kernel(3)
+ >>> kornia.image.get_laplacian_kernel(3)
tensor([ 1., -2., 1.])
- >>> tgm.image.get_laplacian_kernel(5)
+ >>> kornia.image.get_laplacian_kernel(5)
tensor([ 1., 1., -4., 1., 1.])
"""
@@ -58,12 +58,12 @@ def get_laplacian_kernel2d(kernel_size: int) -> torch.Tensor:
Examples::
- >>> tgm.image.get_laplacian_kernel2d(3)
+ >>> kornia.image.get_laplacian_kernel2d(3)
tensor([[ 1., 1., 1.],
[ 1., -8., 1.],
[ 1., 1., 1.]])
- >>> tgm.image.get_laplacian_kernel2d(5)
+ >>> kornia.image.get_laplacian_kernel2d(5)
tensor([[ 1., 1., 1., 1., 1.],
[ 1., 1., 1., 1., 1.],
[ 1., 1., -24., 1., 1.],
@@ -102,7 +102,7 @@ class Laplacian(nn.Module):
Examples::
>>> input = torch.rand(2, 4, 5, 5)
- >>> laplace = tgm.filters.Laplacian(5)
+ >>> laplace = kornia.filters.Laplacian(5)
>>> output = laplace(input) # 2x4x5x5
"""
@@ -152,6 +152,6 @@ class Laplacian(nn.Module):
def laplacian(src: torch.Tensor, kernel_size: int) -> torch.Tensor:
r"""Function that returns a tensor using a Laplacian filter.
- See :class:`~torchgeometry.filters.Laplacian` for details.
+ See :class:`~kornia.filters.Laplacian` for details.
"""
return Laplacian(kernel_size)(src)
diff --git a/torchgeometry/filters/median.py b/kornia/filters/median.py
similarity index 95%
rename from torchgeometry/filters/median.py
rename to kornia/filters/median.py
index f6f7394e0..f44b99bfa 100644
--- a/torchgeometry/filters/median.py
+++ b/kornia/filters/median.py
@@ -37,7 +37,7 @@ class MedianBlur(nn.Module):
Example:
>>> input = torch.rand(2, 4, 5, 7)
- >>> blur = tgm.filters.MedianBlur((3, 3))
+ >>> blur = kornia.filters.MedianBlur((3, 3))
>>> output = blur(input) # 2x4x5x7
"""
@@ -75,6 +75,6 @@ def median_blur(input: torch.Tensor,
kernel_size: Tuple[int, int]) -> torch.Tensor:
r"""Blurs an image using the median filter.
- See :class:`~torchgeometry.filters.MedianBlur` for details.
+ See :class:`~kornia.filters.MedianBlur` for details.
"""
return MedianBlur(kernel_size)(input)
diff --git a/torchgeometry/filters/sobel.py b/kornia/filters/sobel.py
similarity index 92%
rename from torchgeometry/filters/sobel.py
rename to kornia/filters/sobel.py
index 48f2f5cb6..21ea10684 100644
--- a/torchgeometry/filters/sobel.py
+++ b/kornia/filters/sobel.py
@@ -25,7 +25,7 @@ class SpatialGradient(nn.Module):
Examples:
>>> input = torch.rand(1, 3, 4, 4)
- >>> output = tgm.filters.SpatialGradient()(input) # 1x3x2x4x4
+ >>> output = kornia.filters.SpatialGradient()(input) # 1x3x2x4x4
"""
def __init__(self) -> None:
@@ -67,7 +67,7 @@ class Sobel(nn.Module):
Examples:
>>> input = torch.rand(1, 3, 4, 4)
- >>> output = tgm.filters.Sobel()(input) # 1x3x4x4
+ >>> output = kornia.filters.Sobel()(input) # 1x3x4x4
"""
def __init__(self) -> None:
@@ -99,7 +99,7 @@ def spatial_gradient(input: torch.Tensor) -> torch.Tensor:
r"""Computes the first order image derivative in both x and y using a Sobel
operator.
- See :class:`~torchgeometry.filters.SpatialGradient` for details.
+ See :class:`~kornia.filters.SpatialGradient` for details.
"""
return SpatialGradient()(input)
@@ -107,6 +107,6 @@ def spatial_gradient(input: torch.Tensor) -> torch.Tensor:
def sobel(input: torch.Tensor) -> torch.Tensor:
r"""Computes the Sobel operator and returns the magnitude per channel.
- See :class:`~torchgeometry.filters.Sobel` for details.
+ See :class:`~kornia.filters.Sobel` for details.
"""
return Sobel()(input)
diff --git a/kornia/geometry/__init__.py b/kornia/geometry/__init__.py
new file mode 100644
index 000000000..bcec13427
--- /dev/null
+++ b/kornia/geometry/__init__.py
@@ -0,0 +1,5 @@
+from kornia.geometry.camera import *
+from kornia.geometry.conversions import *
+from kornia.geometry.linalg import *
+from kornia.geometry.transform import *
+from kornia.geometry.warp import *
diff --git a/torchgeometry/geometry/camera/__init__.py b/kornia/geometry/camera/__init__.py
similarity index 100%
rename from torchgeometry/geometry/camera/__init__.py
rename to kornia/geometry/camera/__init__.py
diff --git a/torchgeometry/geometry/camera/pinhole.py b/kornia/geometry/camera/pinhole.py
similarity index 96%
rename from torchgeometry/geometry/camera/pinhole.py
rename to kornia/geometry/camera/pinhole.py
index 767ab018e..44c9c718e 100644
--- a/torchgeometry/geometry/camera/pinhole.py
+++ b/kornia/geometry/camera/pinhole.py
@@ -4,9 +4,9 @@ import warnings
import torch
import torch.nn as nn
-from torchgeometry.geometry.conversions import rtvec_to_pose
-from torchgeometry.geometry.linalg import transform_points
-from torchgeometry.geometry.linalg import inverse_transformation
+from kornia.geometry.conversions import rtvec_to_pose
+from kornia.geometry.linalg import transform_points
+from kornia.geometry.linalg import inverse_transformation
class PinholeCamera:
@@ -317,7 +317,7 @@ class PinholeCamera:
class PinholeCamerasList(PinholeCamera):
r"""Class that represents a list of pinhole cameras.
- The class inherits from :class:`~torchgeometry.PinholeCamera` meaning that
+ The class inherits from :class:`~kornia.PinholeCamera` meaning that
it will keep the same class properties but with an extra dimension.
.. note::
@@ -380,7 +380,7 @@ def pinhole_matrix(pinholes, eps=1e-6):
.. note::
This method is going to be deprecated in version 0.2 in favour of
- :attr:`torchgeometry.PinholeCamera.camera_matrix`.
+ :attr:`kornia.PinholeCamera.camera_matrix`.
Args:
pinholes (Tensor): tensor of pinhole models.
@@ -394,7 +394,7 @@ def pinhole_matrix(pinholes, eps=1e-6):
Example:
>>> pinhole = torch.rand(1, 12) # Nx12
- >>> pinhole_matrix = tgm.pinhole_matrix(pinhole) # Nx4x4
+ >>> pinhole_matrix = kornia.pinhole_matrix(pinhole) # Nx4x4
"""
# warnings.warn("pinhole_matrix will be deprecated in version 0.2, "
# "use PinholeCamera.camera_matrix instead",
@@ -418,7 +418,7 @@ def inverse_pinhole_matrix(pinhole, eps=1e-6):
.. note::
This method is going to be deprecated in version 0.2 in favour of
- :attr:`torchgeometry.PinholeCamera.intrinsics_inverse()`.
+ :attr:`kornia.PinholeCamera.intrinsics_inverse()`.
Args:
pinholes (Tensor): tensor with pinhole models.
@@ -432,7 +432,7 @@ def inverse_pinhole_matrix(pinhole, eps=1e-6):
Example:
>>> pinhole = torch.rand(1, 12) # Nx12
- >>> pinhole_matrix_inv = tgm.inverse_pinhole_matrix(pinhole) # Nx4x4
+ >>> pinhole_matrix_inv = kornia.inverse_pinhole_matrix(pinhole) # Nx4x4
"""
# warnings.warn("inverse_pinhole_matrix will be deprecated in version 0.2, "
# "use PinholeCamera.intrinsics_inverse() instead",
@@ -456,7 +456,7 @@ def scale_pinhole(pinholes, scale):
.. note::
This method is going to be deprecated in version 0.2 in favour of
- :attr:`torchgeometry.PinholeCamera.scale()`.
+ :attr:`kornia.PinholeCamera.scale()`.
Args:
pinholes (Tensor): tensor with the pinhole model.
@@ -472,7 +472,7 @@ def scale_pinhole(pinholes, scale):
Example:
>>> pinhole_i = torch.rand(1, 12) # Nx12
>>> scales = 2.0 * torch.ones(1) # N
- >>> pinhole_i_scaled = tgm.scale_pinhole(pinhole_i) # Nx12
+ >>> pinhole_i_scaled = kornia.scale_pinhole(pinhole_i) # Nx12
"""
# warnings.warn("scale_pinhole will be deprecated in version 0.2, "
# "use PinholeCamera.scale() instead",
@@ -535,7 +535,7 @@ def homography_i_H_ref(pinhole_i, pinhole_ref):
Example:
>>> pinhole_i = torch.rand(1, 12) # Nx12
>>> pinhole_ref = torch.rand(1, 12) # Nx12
- >>> i_H_ref = tgm.homography_i_H_ref(pinhole_i, pinhole_ref) # Nx4x4
+ >>> i_H_ref = kornia.homography_i_H_ref(pinhole_i, pinhole_ref) # Nx4x4
"""
assert len(
pinhole_i.shape) == 2 and pinhole_i.shape[1] == 12, pinhole.shape
@@ -639,7 +639,7 @@ def cam2pixel(
Example:
>>> pinhole = torch.rand(1, 12) # Nx12
- >>> transform = tgm.PinholeMatrix()
+ >>> transform = kornia.PinholeMatrix()
>>> pinhole_matrix = transform(pinhole) # Nx4x4
"""
@@ -665,7 +665,7 @@ class InversePinholeMatrix(nn.Module):
Example:
>>> pinhole = torch.rand(1, 12) # Nx12
- >>> transform = tgm.InversePinholeMatrix()
+ >>> transform = kornia.InversePinholeMatrix()
>>> pinhole_matrix_inv = transform(pinhole) # Nx4x4
"""
diff --git a/torchgeometry/geometry/conversions.py b/kornia/geometry/conversions.py
similarity index 95%
rename from torchgeometry/geometry/conversions.py
rename to kornia/geometry/conversions.py
index 7a6100baf..2b13b7d6a 100644
--- a/torchgeometry/geometry/conversions.py
+++ b/kornia/geometry/conversions.py
@@ -34,8 +34,8 @@ def rad2deg(tensor: torch.Tensor) -> torch.Tensor:
torch.Tensor: Tensor with same shape as input.
Example:
- >>> input = tgm.pi * torch.rand(1, 3, 3)
- >>> output = tgm.rad2deg(input)
+ >>> input = kornia.pi * torch.rand(1, 3, 3)
+ >>> output = kornia.rad2deg(input)
"""
if not torch.is_tensor(tensor):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
@@ -56,7 +56,7 @@ def deg2rad(tensor: torch.Tensor) -> torch.Tensor:
Examples::
>>> input = 360. * torch.rand(1, 3, 3)
- >>> output = tgm.deg2rad(input)
+ >>> output = kornia.deg2rad(input)
"""
if not torch.is_tensor(tensor):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
@@ -71,7 +71,7 @@ def convert_points_from_homogeneous(points: torch.Tensor) -> torch.Tensor:
Examples::
>>> input = torch.rand(2, 4, 3) # BxNx3
- >>> output = tgm.convert_points_from_homogeneous(input) # BxNx2
+ >>> output = kornia.convert_points_from_homogeneous(input) # BxNx2
"""
if not torch.is_tensor(points):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
@@ -93,7 +93,7 @@ def convert_points_to_homogeneous(points: torch.Tensor) -> torch.Tensor:
Examples::
>>> input = torch.rand(2, 4, 3) # BxNx3
- >>> output = tgm.convert_points_to_homogeneous(input) # BxNx4
+ >>> output = kornia.convert_points_to_homogeneous(input) # BxNx4
"""
if not torch.is_tensor(points):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
@@ -120,7 +120,7 @@ def angle_axis_to_rotation_matrix(angle_axis: torch.Tensor) -> torch.Tensor:
Example:
>>> input = torch.rand(1, 3) # Nx3
- >>> output = tgm.angle_axis_to_rotation_matrix(input) # Nx4x4
+ >>> output = kornia.angle_axis_to_rotation_matrix(input) # Nx4x4
"""
def _compute_rotation_matrix(angle_axis, theta2, eps=1e-6):
@@ -196,7 +196,7 @@ def rtvec_to_pose(rtvec: torch.Tensor) -> torch.Tensor:
Example:
>>> input = torch.rand(3, 6) # Nx6
- >>> output = tgm.rtvec_to_pose(input) # Nx4x4
+ >>> output = kornia.rtvec_to_pose(input) # Nx4x4
"""
assert rtvec.shape[-1] == 6, 'rtvec=[rx, ry, rz, tx, ty, tz]'
pose: torch.Tensor = angle_axis_to_rotation_matrix(rtvec[..., :3])
@@ -220,7 +220,7 @@ def rotation_matrix_to_angle_axis(
Example:
>>> input = torch.rand(2, 3, 4) # Nx4x4
- >>> output = tgm.rotation_matrix_to_angle_axis(input) # Nx3
+ >>> output = kornia.rotation_matrix_to_angle_axis(input) # Nx3
"""
# todo add check that matrix is a valid rotation matrix
quaternion: torch.Tensor = rotation_matrix_to_quaternion(rotation_matrix)
@@ -246,7 +246,7 @@ def rotation_matrix_to_quaternion(
Example:
>>> input = torch.rand(4, 3, 4) # Nx3x4
- >>> output = tgm.rotation_matrix_to_quaternion(input) # Nx4
+ >>> output = kornia.rotation_matrix_to_quaternion(input) # Nx4
"""
if not torch.is_tensor(rotation_matrix):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
@@ -329,7 +329,7 @@ def quaternion_to_angle_axis(quaternion: torch.Tensor) -> torch.Tensor:
Example:
>>> quaternion = torch.rand(2, 4) # Nx4
- >>> angle_axis = tgm.quaternion_to_angle_axis(quaternion) # Nx3
+ >>> angle_axis = kornia.quaternion_to_angle_axis(quaternion) # Nx3
"""
if not torch.is_tensor(quaternion):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
@@ -383,7 +383,7 @@ def angle_axis_to_quaternion(angle_axis: torch.Tensor) -> torch.Tensor:
Example:
>>> angle_axis = torch.rand(2, 4) # Nx4
- >>> quaternion = tgm.angle_axis_to_quaternion(angle_axis) # Nx3
+ >>> quaternion = kornia.angle_axis_to_quaternion(angle_axis) # Nx3
"""
if not torch.is_tensor(angle_axis):
raise TypeError("Input type is not a torch.Tensor. Got {}".format(
diff --git a/torchgeometry/geometry/linalg.py b/kornia/geometry/linalg.py
similarity index 94%
rename from torchgeometry/geometry/linalg.py
rename to kornia/geometry/linalg.py
index 36dc65a83..3b5ca432b 100644
--- a/torchgeometry/geometry/linalg.py
+++ b/kornia/geometry/linalg.py
@@ -3,8 +3,8 @@ from typing import Optional
import torch
import torch.nn as nn
-from torchgeometry.geometry.conversions import convert_points_to_homogeneous
-from torchgeometry.geometry.conversions import convert_points_from_homogeneous
+from kornia.geometry.conversions import convert_points_to_homogeneous
+from kornia.geometry.conversions import convert_points_from_homogeneous
__all__ = [
@@ -41,7 +41,7 @@ def compose_transformations(
Example::
>>> trans_01 = torch.eye(4) # 4x4
>>> trans_12 = torch.eye(4) # 4x4
- >>> trans_02 = tgm.compose_transformations(trans_01, trans_12) # 4x4
+ >>> trans_02 = kornia.compose_transformations(trans_01, trans_12) # 4x4
"""
if not torch.is_tensor(trans_01):
@@ -100,7 +100,7 @@ def inverse_transformation(trans_12):
Example:
>>> trans_12 = torch.rand(1, 4, 4) # Nx4x4
- >>> trans_21 = tgm.inverse_transformation(trans_12) # Nx4x4
+ >>> trans_21 = kornia.inverse_transformation(trans_12) # Nx4x4
"""
if not torch.is_tensor(trans_12):
raise TypeError("Input type is not a torch.Tensor. Got {}"
@@ -152,7 +152,7 @@ def relative_transformation(
Example::
>>> trans_01 = torch.eye(4) # 4x4
>>> trans_02 = torch.eye(4) # 4x4
- >>> trans_12 = tgm.relative_transformation(trans_01, trans_02) # 4x4
+ >>> trans_12 = kornia.relative_transformation(trans_01, trans_02) # 4x4
"""
if not torch.is_tensor(trans_01):
raise TypeError("Input trans_01 type is not a torch.Tensor. Got {}"
@@ -192,7 +192,7 @@ def transform_points(trans_01: torch.Tensor,
>>> points_1 = torch.rand(2, 4, 3) # BxNx3
>>> trans_01 = torch.eye(4).view(1, 4, 4) # Bx4x4
- >>> points_0 = tgm.transform_points(trans_01, points_1) # BxNx3
+ >>> points_0 = kornia.transform_points(trans_01, points_1) # BxNx3
"""
if not torch.is_tensor(trans_01) or not torch.is_tensor(points_1):
raise TypeError("Input type is not a torch.Tensor")
@@ -236,7 +236,7 @@ def transform_points(trans_01: torch.Tensor,
Examples:
>>> input = torch.rand(2, 4, 3) # BxNx3
>>> transform = torch.eye(4).view(1, 4, 4) # Bx4x4
- >>> transform_op = tgm.TransformPoints(transform)
+ >>> transform_op = kornia.TransformPoints(transform)
>>> output = transform_op(input) # BxNx3
"""
@@ -263,7 +263,7 @@ class InversePose(nn.Module):
Example:
>>> pose = torch.rand(1, 4, 4) # Nx4x4
- >>> transform = tgm.InversePose()
+ >>> transform = kornia.InversePose()
>>> pose_inv = transform(pose) # Nx4x4
"""
diff --git a/kornia/geometry/transform/__init__.py b/kornia/geometry/transform/__init__.py
new file mode 100644
index 000000000..56fc76096
--- /dev/null
+++ b/kornia/geometry/transform/__init__.py
@@ -0,0 +1,4 @@
+from kornia.geometry.transform.crop import *
+from kornia.geometry.transform.imgwarp import *
+from kornia.geometry.transform.pyramid import *
+from kornia.geometry.transform.affwarp import *
diff --git a/torchgeometry/geometry/transform/affwarp.py b/kornia/geometry/transform/affwarp.py
similarity index 97%
rename from torchgeometry/geometry/transform/affwarp.py
rename to kornia/geometry/transform/affwarp.py
index 553f8ba18..8e51f7641 100644
--- a/torchgeometry/geometry/transform/affwarp.py
+++ b/kornia/geometry/transform/affwarp.py
@@ -3,7 +3,7 @@ from typing import Union
import torch
import torch.nn as nn
-from torchgeometry.geometry.transform.imgwarp import (
+from kornia.geometry.transform.imgwarp import (
warp_affine, get_rotation_matrix2d,
)
@@ -113,7 +113,7 @@ def rotate(tensor: torch.Tensor, angle: torch.Tensor,
center: Union[None, torch.Tensor] = None) -> torch.Tensor:
r"""Rotate the image anti-clockwise about the centre.
- See :class:`~torchgeometry.Rotate` for details.
+ See :class:`~kornia.Rotate` for details.
"""
if not torch.is_tensor(tensor):
raise TypeError("Input tensor type is not a torch.Tensor. Got {}"
@@ -145,7 +145,7 @@ def rotate(tensor: torch.Tensor, angle: torch.Tensor,
def translate(tensor: torch.Tensor, translation: torch.Tensor) -> torch.Tensor:
r"""Translate the tensor in pixel units.
- See :class:`~torchgeometry.Translate` for details.
+ See :class:`~kornia.Translate` for details.
"""
if not torch.is_tensor(tensor):
raise TypeError("Input tensor type is not a torch.Tensor. Got {}"
@@ -168,7 +168,7 @@ def scale(tensor: torch.Tensor, scale_factor: torch.Tensor,
center: Union[None, torch.Tensor] = None) -> torch.Tensor:
r"""Scales the input image.
- See :class:`~torchgeometry.Scale` for details.
+ See :class:`~kornia.Scale` for details.
"""
if not torch.is_tensor(tensor):
raise TypeError("Input tensor type is not a torch.Tensor. Got {}"
@@ -194,7 +194,7 @@ def scale(tensor: torch.Tensor, scale_factor: torch.Tensor,
def shear(tensor: torch.Tensor, shear: torch.Tensor) -> torch.Tensor:
r"""Shear the tensor.
- See :class:`~torchgeometry.Shear` for details.
+ See :class:`~kornia.Shear` for details.
"""
if not torch.is_tensor(tensor):
raise TypeError("Input tensor type is not a torch.Tensor. Got {}"
diff --git a/torchgeometry/geometry/transform/crop.py b/kornia/geometry/transform/crop.py
similarity index 97%
rename from torchgeometry/geometry/transform/crop.py
rename to kornia/geometry/transform/crop.py
index 19c2680fc..1094512a3 100644
--- a/torchgeometry/geometry/transform/crop.py
+++ b/kornia/geometry/transform/crop.py
@@ -2,7 +2,7 @@ from typing import Tuple
import torch
-from torchgeometry.geometry.transform.imgwarp import (
+from kornia.geometry.transform.imgwarp import (
warp_perspective, get_perspective_transform
)
@@ -42,7 +42,7 @@ def crop_and_resize(tensor: torch.Tensor, boxes: torch.Tensor,
[2., 1.],
[2., 2.],
]]) # 1x4x2
- >>> tgm.crop_and_resize(input, boxes, (2, 2))
+ >>> kornia.crop_and_resize(input, boxes, (2, 2))
tensor([[[ 6.0000, 7.0000],
[ 10.0000, 11.0000]]])
"""
@@ -118,7 +118,7 @@ def center_crop(tensor: torch.Tensor, size: Tuple[int, int]) -> torch.Tensor:
[9., 10., 11., 12.],
[13., 14., 15., 16.],
]])
- >>> tgm.center_crop(input, (2, 4))
+ >>> kornia.center_crop(input, (2, 4))
tensor([[[ 5.0000, 6.0000, 7.0000, 8.0000],
[ 9.0000, 10.0000, 11.0000, 12.0000]]])
"""
diff --git a/torchgeometry/geometry/transform/imgwarp.py b/kornia/geometry/transform/imgwarp.py
similarity index 97%
rename from torchgeometry/geometry/transform/imgwarp.py
rename to kornia/geometry/transform/imgwarp.py
index 3f399431f..2d49ae52b 100644
--- a/torchgeometry/geometry/transform/imgwarp.py
+++ b/kornia/geometry/transform/imgwarp.py
@@ -3,9 +3,9 @@ from typing import Tuple, Optional
import torch
import torch.nn.functional as F
-from torchgeometry.geometry.warp.homography_warper import homography_warp
+from kornia.geometry.warp.homography_warper import homography_warp
# TODO: move to utils or conversions
-from torchgeometry.geometry.conversions import (
+from kornia.geometry.conversions import (
deg2rad, normalize_pixel_coordinates
)
@@ -89,7 +89,7 @@ def warp_perspective(src, M, dsize, flags='bilinear', border_mode=None,
- Output: :math:`(B, C, H, W)`
.. note::
- See a working example `here <https://github.com/arraiy/torchgeometry/
+ See a working example `here <https://github.com/arraiy/kornia/
blob/master/examples/warp_perspective.ipynb>`_.
"""
if not torch.is_tensor(src):
@@ -140,7 +140,7 @@ def warp_affine(src: torch.Tensor,
.. note::
See a working example `here <https://github.com/arraiyopensource/
- torchgeometry/blob/master/docs/source/warp_affine.ipynb>`__.
+ kornia/blob/master/docs/source/warp_affine.ipynb>`__.
"""
if not torch.is_tensor(src):
raise TypeError("Input src type is not a torch.Tensor. Got {}"
@@ -311,7 +311,7 @@ def get_rotation_matrix2d(
>>> center = torch.zeros(1, 2)
>>> scale = torch.ones(1)
>>> angle = 45. * torch.ones(1)
- >>> M = tgm.get_rotation_matrix2d(center, angle, scale)
+ >>> M = kornia.get_rotation_matrix2d(center, angle, scale)
tensor([[[ 0.7071, 0.7071, 0.0000],
[-0.7071, 0.7071, 0.0000]]])
"""
@@ -379,10 +379,10 @@ def remap(tensor: torch.Tensor, map_x: torch.Tensor,
torch.Tensor: the warped tensor.
Example:
- >>> grid = tgm.utils.create_meshgrid(2, 2, False) # 1x2x2x2
+ >>> grid = kornia.utils.create_meshgrid(2, 2, False) # 1x2x2x2
>>> grid += 1 # apply offset in both directions
>>> input = torch.ones(1, 1, 2, 2)
- >>> tgm.remap(input, grid[..., 0], grid[..., 1]) # 1x1x2x2
+ >>> kornia.remap(input, grid[..., 0], grid[..., 1]) # 1x1x2x2
tensor([[[[1., 0.],
[0., 0.]]]])
diff --git a/torchgeometry/geometry/transform/pyramid.py b/kornia/geometry/transform/pyramid.py
similarity index 93%
rename from torchgeometry/geometry/transform/pyramid.py
rename to kornia/geometry/transform/pyramid.py
index 66005777a..34c04992d 100644
--- a/torchgeometry/geometry/transform/pyramid.py
+++ b/kornia/geometry/transform/pyramid.py
@@ -36,7 +36,7 @@ class PyrDown(nn.Module):
Examples:
>>> input = torch.rand(1, 2, 4, 4)
- >>> output = tgm.transform.PyrDown()(input) # 1x2x2x2
+ >>> output = kornia.transform.PyrDown()(input) # 1x2x2x2
"""
def __init__(self) -> None:
@@ -79,7 +79,7 @@ class PyrUp(nn.Module):
Examples:
>>> input = torch.rand(1, 2, 4, 4)
- >>> output = tgm.transform.PyrUp()(input) # 1x2x8x8
+ >>> output = kornia.transform.PyrUp()(input) # 1x2x8x8
"""
def __init__(self):
@@ -114,7 +114,7 @@ class PyrUp(nn.Module):
def pyrdown(input: torch.Tensor) -> torch.Tensor:
r"""Blurs a tensor and downsamples it.
- See :class:`~torchgeometry.transform.PyrDown` for details.
+ See :class:`~kornia.transform.PyrDown` for details.
"""
return PyrDown()(input)
@@ -122,6 +122,6 @@ def pyrdown(input: torch.Tensor) -> torch.Tensor:
def pyrup(input: torch.Tensor) -> torch.Tensor:
r"""Upsamples a tensor and then blurs it.
- See :class:`~torchgeometry.transform.PyrUp` for details.
+ See :class:`~kornia.transform.PyrUp` for details.
"""
return PyrUp()(input)
diff --git a/kornia/geometry/warp/__init__.py b/kornia/geometry/warp/__init__.py
new file mode 100644
index 000000000..530e82625
--- /dev/null
+++ b/kornia/geometry/warp/__init__.py
@@ -0,0 +1,2 @@
+from kornia.geometry.warp.homography_warper import *
+from kornia.geometry.warp.depth_warper import *
diff --git a/torchgeometry/geometry/warp/depth_warper.py b/kornia/geometry/warp/depth_warper.py
similarity index 90%
rename from torchgeometry/geometry/warp/depth_warper.py
rename to kornia/geometry/warp/depth_warper.py
index 8f3bf05eb..2a2036a5a 100644
--- a/torchgeometry/geometry/warp/depth_warper.py
+++ b/kornia/geometry/warp/depth_warper.py
@@ -3,13 +3,13 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.geometry.linalg import transform_points
-from torchgeometry.geometry.linalg import relative_transformation
-from torchgeometry.geometry.conversions import convert_points_to_homogeneous
-from torchgeometry.geometry.conversions import normalize_pixel_coordinates
-from torchgeometry.geometry.camera import PinholeCamera
-from torchgeometry.geometry.camera import cam2pixel, pixel2cam
-from torchgeometry.utils import create_meshgrid
+from kornia.geometry.linalg import transform_points
+from kornia.geometry.linalg import relative_transformation
+from kornia.geometry.conversions import convert_points_to_homogeneous
+from kornia.geometry.conversions import normalize_pixel_coordinates
+from kornia.geometry.camera import PinholeCamera
+from kornia.geometry.camera import cam2pixel, pixel2cam
+from kornia.utils import create_meshgrid
__all__ = [
@@ -178,10 +178,10 @@ class DepthWarper(nn.Module):
Example:
>>> # pinholes camera models
- >>> pinhole_dst = tgm.PinholeCamera(...)
- >>> pinhole_src = tgm.PinholeCamera(...)
+ >>> pinhole_dst = kornia.PinholeCamera(...)
+ >>> pinhole_src = kornia.PinholeCamera(...)
>>> # create the depth warper, compute the projection matrix
- >>> warper = tgm.DepthWarper(pinhole_dst, height, width)
+ >>> warper = kornia.DepthWarper(pinhole_dst, height, width)
>>> warper.compute_projection_matrix(pinhole_src)
>>> # warp the destionation frame to reference by depth
>>> depth_src = torch.ones(1, 1, 32, 32) # Nx1xHxW
@@ -202,16 +202,16 @@ def depth_warp(pinhole_dst: PinholeCamera,
r"""Function that warps a tensor from destination frame to reference
given the depth in the reference frame.
- See :class:`~torchgeometry.geometry.warp.DepthWarper` for details.
+ See :class:`~kornia.geometry.warp.DepthWarper` for details.
Example:
>>> # pinholes camera models
- >>> pinhole_dst = tgm.PinholeCamera(...)
- >>> pinhole_src = tgm.PinholeCamera(...)
+ >>> pinhole_dst = kornia.PinholeCamera(...)
+ >>> pinhole_src = kornia.PinholeCamera(...)
>>> # warp the destionation frame to reference by depth
>>> depth_src = torch.ones(1, 1, 32, 32) # Nx1xHxW
>>> image_dst = torch.rand(1, 3, 32, 32) # NxCxHxW
- >>> image_src = tgm.depth_warp(pinhole_dst, pinhole_src,
+ >>> image_src = kornia.depth_warp(pinhole_dst, pinhole_src,
>>> depth_src, image_dst, height, width) # NxCxHxW
"""
warper = DepthWarper(pinhole_dst, height, width)
diff --git a/torchgeometry/geometry/warp/homography_warper.py b/kornia/geometry/warp/homography_warper.py
similarity index 94%
rename from torchgeometry/geometry/warp/homography_warper.py
rename to kornia/geometry/warp/homography_warper.py
index 5cbea71a4..19a365be0 100644
--- a/torchgeometry/geometry/warp/homography_warper.py
+++ b/kornia/geometry/warp/homography_warper.py
@@ -4,8 +4,8 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.utils import create_meshgrid
-from torchgeometry.geometry.linalg import transform_points
+from kornia.utils import create_meshgrid
+from kornia.geometry.linalg import transform_points
__all__ = [
@@ -99,7 +99,7 @@ class HomographyWarper(nn.Module):
Example:
>>> input = torch.rand(1, 3, 32, 32)
>>> homography = torch.eye(3).view(1, 3, 3)
- >>> warper = tgm.HomographyWarper(32, 32)
+ >>> warper = kornia.HomographyWarper(32, 32)
>>> output = warper(input, homography) # NxCxHxW
"""
if not dst_homo_src.device == patch_src.device:
@@ -120,7 +120,7 @@ def homography_warp(patch_src: torch.Tensor,
padding_mode: Optional[str] = 'zeros') -> torch.Tensor:
r"""Function that warps image patchs or tensors by homographies.
- See :class:`~torchgeometry.geometry.warp.HomographyWarper` for details.
+ See :class:`~kornia.geometry.warp.HomographyWarper` for details.
Args:
patch_src (torch.Tensor): The image or tensor to warp. Should be from
@@ -140,7 +140,7 @@ def homography_warp(patch_src: torch.Tensor,
Example:
>>> input = torch.rand(1, 3, 32, 32)
>>> homography = torch.eye(3).view(1, 3, 3)
- >>> output = tgm.homography_warp(input, homography, (32, 32)) # NxCxHxW
+ >>> output = kornia.homography_warp(input, homography, (32, 32))
"""
height, width = dsize
warper = HomographyWarper(height, width, mode, padding_mode)
diff --git a/torchgeometry/losses/__init__.py b/kornia/losses/__init__.py
similarity index 100%
rename from torchgeometry/losses/__init__.py
rename to kornia/losses/__init__.py
diff --git a/torchgeometry/losses/depth_smooth.py b/kornia/losses/depth_smooth.py
similarity index 96%
rename from torchgeometry/losses/depth_smooth.py
rename to kornia/losses/depth_smooth.py
index 3b7e9c108..871814e89 100644
--- a/torchgeometry/losses/depth_smooth.py
+++ b/kornia/losses/depth_smooth.py
@@ -25,7 +25,7 @@ class InverseDepthSmoothnessLoss(nn.Module):
>>> idepth = torch.rand(1, 1, 4, 5)
>>> image = torch.rand(1, 3, 4, 5)
- >>> smooth = tgm.losses.DepthSmoothnessLoss()
+ >>> smooth = kornia.losses.DepthSmoothnessLoss()
>>> loss = smooth(idepth, image)
"""
@@ -97,6 +97,6 @@ def inverse_depth_smoothness_loss(
image: torch.Tensor) -> torch.Tensor:
r"""Computes image-aware inverse depth smoothness loss.
- See :class:`~torchgeometry.losses.InvDepthSmoothnessLoss` for details.
+ See :class:`~kornia.losses.InvDepthSmoothnessLoss` for details.
"""
return InverseDepthSmoothnessLoss()(idepth, image)
diff --git a/torchgeometry/losses/dice.py b/kornia/losses/dice.py
similarity index 95%
rename from torchgeometry/losses/dice.py
rename to kornia/losses/dice.py
index df8c9c742..01bc7d015 100644
--- a/torchgeometry/losses/dice.py
+++ b/kornia/losses/dice.py
@@ -4,7 +4,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.utils import one_hot
+from kornia.utils import one_hot
# based on:
@@ -38,7 +38,7 @@ class DiceLoss(nn.Module):
Examples:
>>> N = 5 # num_classes
- >>> loss = tgm.losses.DiceLoss()
+ >>> loss = kornia.losses.DiceLoss()
>>> input = torch.randn(1, N, 3, 5, requires_grad=True)
>>> target = torch.empty(1, 3, 5, dtype=torch.long).random_(N)
>>> output = loss(input, target)
@@ -92,6 +92,6 @@ def dice_loss(
target: torch.Tensor) -> torch.Tensor:
r"""Function that computes SΓΈrensen-Dice Coefficient loss.
- See :class:`~torchgeometry.losses.DiceLoss` for details.
+ See :class:`~kornia.losses.DiceLoss` for details.
"""
return DiceLoss()(input, target)
diff --git a/torchgeometry/losses/focal.py b/kornia/losses/focal.py
similarity index 95%
rename from torchgeometry/losses/focal.py
rename to kornia/losses/focal.py
index 19a522082..361b29132 100644
--- a/torchgeometry/losses/focal.py
+++ b/kornia/losses/focal.py
@@ -4,7 +4,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.utils import one_hot
+from kornia.utils import one_hot
# based on:
@@ -38,7 +38,8 @@ class FocalLoss(nn.Module):
Examples:
>>> N = 5 # num_classes
- >>> loss = tgm.losses.FocalLoss(alpha=0.5, gamma=2.0, reduction='mean')
+ >>> args = {"alpha": 0.5, "gamma": 2.0, "reduction": 'mean'}
+ >>> loss = kornia.losses.FocalLoss(*args)
>>> input = torch.randn(1, N, 3, 5, requires_grad=True)
>>> target = torch.empty(1, 3, 5, dtype=torch.long).random_(N)
>>> output = loss(input, target)
@@ -111,6 +112,6 @@ def focal_loss(
reduction: Optional[str] = 'none') -> torch.Tensor:
r"""Function that computes Focal loss.
- See :class:`~torchgeometry.losses.FocalLoss` for details.
+ See :class:`~kornia.losses.FocalLoss` for details.
"""
return FocalLoss(alpha, gamma, reduction)(input, target)
diff --git a/torchgeometry/losses/ssim.py b/kornia/losses/ssim.py
similarity index 97%
rename from torchgeometry/losses/ssim.py
rename to kornia/losses/ssim.py
index 5ee006977..4a19d2726 100644
--- a/torchgeometry/losses/ssim.py
+++ b/kornia/losses/ssim.py
@@ -4,7 +4,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.filters import get_gaussian_kernel2d
+from kornia.filters import get_gaussian_kernel2d
class SSIM(nn.Module):
@@ -51,7 +51,7 @@ class SSIM(nn.Module):
>>> input1 = torch.rand(1, 4, 5, 5)
>>> input2 = torch.rand(1, 4, 5, 5)
- >>> ssim = tgm.losses.SSIM(5, reduction='none')
+ >>> ssim = kornia.losses.SSIM(5, reduction='none')
>>> loss = ssim(input1, input2) # 1x4x5x5
"""
@@ -155,6 +155,6 @@ def ssim(
r"""Function that measures the Structural Similarity (SSIM) index between
each element in the input `x` and target `y`.
- See :class:`~torchgeometry.losses.SSIM` for details.
+ See :class:`~kornia.losses.SSIM` for details.
"""
return SSIM(window_size, reduction, max_val)(img1, img2)
diff --git a/torchgeometry/losses/tversky.py b/kornia/losses/tversky.py
similarity index 95%
rename from torchgeometry/losses/tversky.py
rename to kornia/losses/tversky.py
index f0de47618..2f1d246b6 100644
--- a/torchgeometry/losses/tversky.py
+++ b/kornia/losses/tversky.py
@@ -4,7 +4,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
-from torchgeometry.utils import one_hot
+from kornia.utils import one_hot
# based on:
# https://github.com/kevinzakka/pytorch-goodies/blob/master/losses.py
@@ -38,7 +38,7 @@ class TverskyLoss(nn.Module):
Examples:
>>> N = 5 # num_classes
- >>> loss = tgm.losses.TverskyLoss(alpha=0.5, beta=0.5)
+ >>> loss = kornia.losses.TverskyLoss(alpha=0.5, beta=0.5)
>>> input = torch.randn(1, N, 3, 5, requires_grad=True)
>>> target = torch.empty(1, 3, 5, dtype=torch.long).random_(N)
>>> output = loss(input, target)
@@ -102,6 +102,6 @@ def tversky_loss(
beta: float) -> torch.Tensor:
r"""Function that computes Tversky loss.
- See :class:`~torchgeometry.losses.TverskyLoss` for details.
+ See :class:`~kornia.losses.TverskyLoss` for details.
"""
return TverskyLoss(alpha, beta)(input, target)
diff --git a/torchgeometry/utils/__init__.py b/kornia/utils/__init__.py
similarity index 83%
rename from torchgeometry/utils/__init__.py
rename to kornia/utils/__init__.py
index d8b971891..79be95c17 100644
--- a/torchgeometry/utils/__init__.py
+++ b/kornia/utils/__init__.py
@@ -2,7 +2,7 @@ from .one_hot import one_hot
from .grid import create_meshgrid
from .image import tensor_to_image, image_to_tensor
-from torchgeometry.utils.metrics import *
+from kornia.utils.metrics import *
__all__ = [
"one_hot",
diff --git a/torchgeometry/utils/grid.py b/kornia/utils/grid.py
similarity index 100%
rename from torchgeometry/utils/grid.py
rename to kornia/utils/grid.py
diff --git a/torchgeometry/utils/image.py b/kornia/utils/image.py
similarity index 100%
rename from torchgeometry/utils/image.py
rename to kornia/utils/image.py
diff --git a/torchgeometry/utils/metrics/__init__.py b/kornia/utils/metrics/__init__.py
similarity index 100%
rename from torchgeometry/utils/metrics/__init__.py
rename to kornia/utils/metrics/__init__.py
diff --git a/torchgeometry/utils/metrics/confusion_matrix.py b/kornia/utils/metrics/confusion_matrix.py
similarity index 100%
rename from torchgeometry/utils/metrics/confusion_matrix.py
rename to kornia/utils/metrics/confusion_matrix.py
diff --git a/torchgeometry/utils/metrics/mean_iou.py b/kornia/utils/metrics/mean_iou.py
similarity index 97%
rename from torchgeometry/utils/metrics/mean_iou.py
rename to kornia/utils/metrics/mean_iou.py
index 54f26cd43..ae89816fe 100644
--- a/torchgeometry/utils/metrics/mean_iou.py
+++ b/kornia/utils/metrics/mean_iou.py
@@ -1,7 +1,7 @@
from typing import Optional
import torch
-from torchgeometry.utils.metrics import confusion_matrix
+from kornia.utils.metrics import confusion_matrix
def mean_iou(
diff --git a/torchgeometry/utils/one_hot.py b/kornia/utils/one_hot.py
similarity index 97%
rename from torchgeometry/utils/one_hot.py
rename to kornia/utils/one_hot.py
index 50cfb1c09..c2ba6acf5 100644
--- a/torchgeometry/utils/one_hot.py
+++ b/kornia/utils/one_hot.py
@@ -27,7 +27,7 @@ def one_hot(labels: torch.Tensor,
Examples::
>>> labels = torch.LongTensor([[[0, 1], [2, 0]]])
- >>> tgm.losses.one_hot(labels, num_classes=3)
+ >>> kornia.losses.one_hot(labels, num_classes=3)
tensor([[[[1., 0.],
[0., 1.]],
[[0., 1.],
diff --git a/kornia/version.py b/kornia/version.py
new file mode 100644
index 000000000..10939f01b
--- /dev/null
+++ b/kornia/version.py
@@ -0,0 +1 @@
+__version__ = '0.1.2'
diff --git a/mypy_files.txt b/mypy_files.txt
index 62c5189bd..5d00ca48d 100644
--- a/mypy_files.txt
+++ b/mypy_files.txt
@@ -1,33 +1,33 @@
-torchgeometry/color/gray.py
-torchgeometry/color/hsv.py
-torchgeometry/color/rgb.py
-torchgeometry/color/normalize.py
-torchgeometry/contrib/spatial_soft_argmax2d.py
-torchgeometry/contrib/extract_patches.py
-torchgeometry/contrib/max_blur_pool.py
-torchgeometry/feature/harris.py
-torchgeometry/feature/nms.py
-torchgeometry/filters/blur.py
-torchgeometry/filters/gaussian.py
-torchgeometry/filters/laplacian.py
-torchgeometry/filters/median.py
-torchgeometry/filters/sobel.py
-torchgeometry/geometry/conversions.py
-torchgeometry/geometry/linalg.py
-torchgeometry/geometry/camera/pinhole.py
-torchgeometry/geometry/transform/affwarp.py
-torchgeometry/geometry/transform/imgwarp.py
-torchgeometry/geometry/transform/crop.py
-torchgeometry/geometry/transform/pyramid.py
-torchgeometry/geometry/warp/homography_warper.py
-torchgeometry/geometry/warp/depth_warper.py
-torchgeometry/losses/ssim.py
-torchgeometry/losses/dice.py
-torchgeometry/losses/focal.py
-torchgeometry/losses/tversky.py
-torchgeometry/losses/depth_smooth.py
-torchgeometry/utils/grid.py
-torchgeometry/utils/image.py
-torchgeometry/utils/one_hot.py
-torchgeometry/utils/metrics/confusion_matrix.py
-torchgeometry/utils/metrics/mean_iou.py
+kornia/color/gray.py
+kornia/color/hsv.py
+kornia/color/rgb.py
+kornia/color/normalize.py
+kornia/contrib/spatial_soft_argmax2d.py
+kornia/contrib/extract_patches.py
+kornia/contrib/max_blur_pool.py
+kornia/feature/harris.py
+kornia/feature/nms.py
+kornia/filters/blur.py
+kornia/filters/gaussian.py
+kornia/filters/laplacian.py
+kornia/filters/median.py
+kornia/filters/sobel.py
+kornia/geometry/conversions.py
+kornia/geometry/linalg.py
+kornia/geometry/camera/pinhole.py
+kornia/geometry/transform/affwarp.py
+kornia/geometry/transform/imgwarp.py
+kornia/geometry/transform/crop.py
+kornia/geometry/transform/pyramid.py
+kornia/geometry/warp/homography_warper.py
+kornia/geometry/warp/depth_warper.py
+kornia/losses/ssim.py
+kornia/losses/dice.py
+kornia/losses/focal.py
+kornia/losses/tversky.py
+kornia/losses/depth_smooth.py
+kornia/utils/grid.py
+kornia/utils/image.py
+kornia/utils/one_hot.py
+kornia/utils/metrics/confusion_matrix.py
+kornia/utils/metrics/mean_iou.py
diff --git a/setup.py b/setup.py
index 1809f9729..da97e92b3 100644
--- a/setup.py
+++ b/setup.py
@@ -1,11 +1,5 @@
-# Welcome to the PyTorch Geometry setup.py.
+# Welcome to the Kornia setup.py.
#
-# Environment variables for feature toggles:
-#
-# PYTORCH_BUILD_VERSION
-# PYTORCH_BUILD_NUMBER
-# specify the version of PyTorch, rather than the hard-coded version
-# in this file; used when we're building binaries for distribution
from __future__ import print_function
from setuptools import setup, find_packages
@@ -21,15 +15,15 @@ cwd = os.path.dirname(os.path.abspath(__file__))
# Version, create_version_file, and package_name
#
# Example for release (0.1.2):
-# TORCHGEOMETRY_BUILD_VERSION=0.1.2 \
-# TORCHGEOMETRY_BUILD_NUMBER=1 python setup.py install
+# KORNIA_BUILD_VERSION=0.1.2 \
+# KORNIA_BUILD_NUMBER=1 python setup.py install
################################################################################
-package_name = os.getenv('TORCHGEOMETRY_PACKAGE_NAME', 'torchgeometry')
+package_name = os.getenv('KORNIA_PACKAGE_NAME', 'kornia')
version = '0.1.2' # NOTE: modify this variable each time we do a release
-if os.getenv('TORCHGEOMETRY_BUILD_VERSION'):
- assert os.getenv('TORCHGEOMETRY_BUILD_NUMBER') is not None
- build_number = int(os.getenv('TORCHGEOMETRY_BUILD_NUMBER'))
- version = os.getenv('TORCHGEOMETRY_BUILD_VERSION')
+if os.getenv('KORNIA_BUILD_VERSION'):
+ assert os.getenv('KORNIA_BUILD_NUMBER') is not None
+ build_number = int(os.getenv('KORNIA_BUILD_NUMBER'))
+ version = os.getenv('KORNIA_BUILD_VERSION')
if build_number > 1:
version += '.post' + str(build_number)
else:
@@ -44,7 +38,7 @@ print("Building wheel {}-{}".format(package_name, version))
# all the work we need to do _before_ setup runs
def build_deps():
print('-- Building version ' + version)
- version_path = os.path.join(cwd, 'torchgeometry', 'version.py')
+ version_path = os.path.join(cwd, 'kornia', 'version.py')
with open(version_path, 'w') as f:
f.write("__version__ = '{}'\n".format(version))
@@ -74,9 +68,9 @@ if __name__ == '__main__':
name=package_name,
version=version,
author='Edgar Riba',
- author_email='[email protected]',
- url='https://github.com/arraiyopensource/torchgeometry',
- description='differential geometric computer vision for deep learning',
+ author_email='[email protected]',
+ url='https://github.com/arraiyopensource/kornia',
+ description='differentiable computer vision for deep learning',
long_description=long_description,
license='BSD',
python_requires='>=3.6',
diff --git a/test/color/test_gray.py b/test/color/test_gray.py
index 2406518a4..efcd52b95 100644
--- a/test/color/test_gray.py
+++ b/test/color/test_gray.py
@@ -4,8 +4,8 @@ from torch.autograd import gradcheck
from torch.testing import assert_allclose
from common import device_type
-import torchgeometry as K
-import torchgeometry.color as color
+import kornia as K
+import kornia.color as color
import utils
diff --git a/test/color/test_hsv.py b/test/color/test_hsv.py
index 21c6dd84f..2c83bc62b 100644
--- a/test/color/test_hsv.py
+++ b/test/color/test_hsv.py
@@ -4,7 +4,7 @@ from torch.autograd import gradcheck
from torch.testing import assert_allclose
from common import device_type
-import torchgeometry.color as color
+import kornia.color as color
import utils
diff --git a/test/color/test_normalize.py b/test/color/test_normalize.py
index 4abe62bfc..76c028fe7 100644
--- a/test/color/test_normalize.py
+++ b/test/color/test_normalize.py
@@ -4,7 +4,7 @@ from torch.autograd import gradcheck
from torch.testing import assert_allclose
from common import device_type
-import torchgeometry.color as color
+import kornia.color as color
import utils
diff --git a/test/color/test_rgb.py b/test/color/test_rgb.py
index 08868831d..b0663a96a 100644
--- a/test/color/test_rgb.py
+++ b/test/color/test_rgb.py
@@ -4,7 +4,7 @@ from torch.autograd import gradcheck
from torch.testing import assert_allclose
from common import device_type
-import torchgeometry.color as color
+import kornia.color as color
import utils
diff --git a/test/feature/test_harris.py b/test/feature/test_harris.py
index 1b01d670d..b383a65a6 100644
--- a/test/feature/test_harris.py
+++ b/test/feature/test_harris.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.testing import assert_allclose
from torch.autograd import gradcheck
@@ -11,12 +11,12 @@ import utils # test utils
class TestCornerHarris:
def test_shape(self):
inp = torch.ones(1, 3, 4, 4)
- sobel = tgm.feature.CornerHarris(k=0.04)
+ sobel = kornia.feature.CornerHarris(k=0.04)
assert sobel(inp).shape == (1, 3, 4, 4)
def test_shape_batch(self):
inp = torch.zeros(2, 6, 4, 4)
- sobel = tgm.feature.CornerHarris(k=0.04)
+ sobel = kornia.feature.CornerHarris(k=0.04)
assert sobel(inp).shape == (2, 6, 4, 4)
def test_corners(self):
@@ -40,7 +40,7 @@ class TestCornerHarris:
[0., 0., 0., 0., 0., 0., 0.],
]]])
- scores = tgm.feature.corner_harris(inp, k=0.04)
+ scores = kornia.feature.corner_harris(inp, k=0.04)
assert_allclose(scores, expected)
def test_corners_batch(self):
@@ -80,7 +80,7 @@ class TestCornerHarris:
[0., 0., 0., 0., 0., 0., 0.],
]])
- scores = tgm.feature.corner_harris(inp, k=0.04)
+ scores = kornia.feature.corner_harris(inp, k=0.04)
assert_allclose(scores, expected)
def test_gradcheck(self):
@@ -88,15 +88,15 @@ class TestCornerHarris:
batch_size, channels, height, width = 1, 2, 5, 4
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- assert gradcheck(tgm.feature.corner_harris, (img, k),
+ assert gradcheck(kornia.feature.corner_harris, (img, k),
raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input, k):
- return tgm.feature.corner_harris(input, k)
+ return kornia.feature.corner_harris(input, k)
k = torch.tensor(0.04)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img, k)
- expected = tgm.feature.corner_harris(img, k)
+ expected = kornia.feature.corner_harris(img, k)
assert_allclose(actual, expected)
diff --git a/test/filters/test_blur.py b/test/filters/test_blur.py
index f483b5041..55412a13c 100644
--- a/test/filters/test_blur.py
+++ b/test/filters/test_blur.py
@@ -2,7 +2,7 @@ import pytest
from typing import Tuple
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.testing import assert_allclose
from torch.autograd import gradcheck
@@ -12,12 +12,12 @@ import utils # test utils
class TestBoxBlur:
def test_shape(self):
inp = torch.zeros(1, 3, 4, 4)
- blur = tgm.filters.BoxBlur((3, 3))
+ blur = kornia.filters.BoxBlur((3, 3))
assert blur(inp).shape == (1, 3, 4, 4)
def test_shape_batch(self):
inp = torch.zeros(2, 6, 4, 4)
- blur = tgm.filters.BoxBlur((3, 3))
+ blur = kornia.filters.BoxBlur((3, 3))
assert blur(inp).shape == (2, 6, 4, 4)
def test_kernel_3x3(self):
@@ -30,7 +30,7 @@ class TestBoxBlur:
]]])
kernel_size = (3, 3)
- actual = tgm.filters.box_blur(inp, kernel_size)
+ actual = kornia.filters.box_blur(inp, kernel_size)
assert_allclose(actual[0, 0, 1, 1:4], torch.tensor(1.))
def test_kernel_5x5(self):
@@ -43,7 +43,7 @@ class TestBoxBlur:
]]])
kernel_size = (5, 5)
- actual = tgm.filters.box_blur(inp, kernel_size)
+ actual = kornia.filters.box_blur(inp, kernel_size)
assert_allclose(actual[0, 0, 1, 2], torch.tensor(1.))
def test_kernel_5x5_batch(self):
@@ -57,23 +57,23 @@ class TestBoxBlur:
]]]).repeat(batch_size, 1, 1, 1)
kernel_size = (5, 5)
- actual = tgm.filters.box_blur(inp, kernel_size)
+ actual = kornia.filters.box_blur(inp, kernel_size)
assert_allclose(actual[0, 0, 1, 2], torch.tensor(1.))
def test_gradcheck(self):
batch_size, channels, height, width = 1, 2, 5, 4
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- assert gradcheck(tgm.filters.box_blur, (img, (3, 3),),
+ assert gradcheck(kornia.filters.box_blur, (img, (3, 3),),
raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input: torch.Tensor,
kernel_size: Tuple[int, int]) -> torch.Tensor:
- return tgm.filters.box_blur(input, kernel_size)
+ return kornia.filters.box_blur(input, kernel_size)
kernel_size = (3, 3)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img, kernel_size)
- expected = tgm.filters.box_blur(img, kernel_size)
+ expected = kornia.filters.box_blur(img, kernel_size)
assert_allclose(actual, expected)
diff --git a/test/filters/test_filters.py b/test/filters/test_filters.py
index b7e67de9d..daa6d87d7 100644
--- a/test/filters/test_filters.py
+++ b/test/filters/test_filters.py
@@ -4,7 +4,7 @@ from torch.autograd import gradcheck
from torch.testing import assert_allclose
from common import device_type
-import torchgeometry.filters as filters
+import kornia.filters as filters
import utils
diff --git a/test/filters/test_median.py b/test/filters/test_median.py
index 24ddebb5a..ab3a5e08b 100644
--- a/test/filters/test_median.py
+++ b/test/filters/test_median.py
@@ -2,7 +2,7 @@ import pytest
from typing import Tuple
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.testing import assert_allclose
from torch.autograd import gradcheck
@@ -12,12 +12,12 @@ import utils # test utils
class TestMedianBlur:
def test_shape(self):
inp = torch.zeros(1, 3, 4, 4)
- median = tgm.filters.MedianBlur((3, 3))
+ median = kornia.filters.MedianBlur((3, 3))
assert median(inp).shape == (1, 3, 4, 4)
def test_shape_batch(self):
inp = torch.zeros(2, 6, 4, 4)
- blur = tgm.filters.BoxBlur((3, 3))
+ blur = kornia.filters.BoxBlur((3, 3))
assert blur(inp).shape == (2, 6, 4, 4)
def test_kernel_3x3(self):
@@ -36,7 +36,7 @@ class TestMedianBlur:
]]).repeat(2, 1, 1, 1)
kernel_size = (3, 3)
- actual = tgm.filters.median_blur(inp, kernel_size)
+ actual = kornia.filters.median_blur(inp, kernel_size)
assert_allclose(actual[0, 0, 2, 2], torch.tensor(3.))
assert_allclose(actual[0, 1, 1, 1], torch.tensor(14.))
@@ -44,16 +44,16 @@ class TestMedianBlur:
batch_size, channels, height, width = 1, 2, 5, 4
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- assert gradcheck(tgm.filters.median_blur, (img, (5, 3),),
+ assert gradcheck(kornia.filters.median_blur, (img, (5, 3),),
raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input: torch.Tensor,
kernel_size: Tuple[int, int]) -> torch.Tensor:
- return tgm.filters.median_blur(input, kernel_size)
+ return kornia.filters.median_blur(input, kernel_size)
kernel_size = (3, 5)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img, kernel_size)
- expected = tgm.filters.median_blur(img, kernel_size)
+ expected = kornia.filters.median_blur(img, kernel_size)
assert_allclose(actual, expected)
diff --git a/test/filters/test_sobel.py b/test/filters/test_sobel.py
index 070e97247..ef531a1e8 100644
--- a/test/filters/test_sobel.py
+++ b/test/filters/test_sobel.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.testing import assert_allclose
from torch.autograd import gradcheck
@@ -11,12 +11,12 @@ import utils # test utils
class TestSpatialGradient:
def test_shape(self):
inp = torch.zeros(1, 3, 4, 4)
- sobel = tgm.filters.SpatialGradient()
+ sobel = kornia.filters.SpatialGradient()
assert sobel(inp).shape == (1, 3, 2, 4, 4)
def test_shape_batch(self):
inp = torch.zeros(2, 6, 4, 4)
- sobel = tgm.filters.SpatialGradient()
+ sobel = kornia.filters.SpatialGradient()
assert sobel(inp).shape == (2, 6, 2, 4, 4)
def test_edges(self):
@@ -36,35 +36,35 @@ class TestSpatialGradient:
[-3., -4., -3.],
]]]])
- edges = tgm.filters.spatial_gradient(inp)
+ edges = kornia.filters.spatial_gradient(inp)
assert_allclose(edges, expected)
def test_gradcheck(self):
batch_size, channels, height, width = 1, 2, 5, 4
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- assert gradcheck(tgm.filters.spatial_gradient, (img,),
+ assert gradcheck(kornia.filters.spatial_gradient, (img,),
raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input):
- return tgm.filters.spatial_gradient(input)
+ return kornia.filters.spatial_gradient(input)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img)
- expected = tgm.filters.spatial_gradient(img)
+ expected = kornia.filters.spatial_gradient(img)
assert_allclose(actual, expected)
class TestSobel:
def test_shape(self):
inp = torch.zeros(1, 3, 4, 4)
- sobel = tgm.filters.Sobel()
+ sobel = kornia.filters.Sobel()
assert sobel(inp).shape == (1, 3, 4, 4)
def test_shape_batch(self):
inp = torch.zeros(3, 2, 4, 4)
- sobel = tgm.filters.Sobel()
+ sobel = kornia.filters.Sobel()
assert sobel(inp).shape == (3, 2, 4, 4)
def test_magnitude(self):
@@ -80,20 +80,20 @@ class TestSobel:
[4.2426, 4.00, 4.2426],
]]])
- edges = tgm.filters.sobel(inp)
+ edges = kornia.filters.sobel(inp)
assert_allclose(edges, expected)
def test_gradcheck(self):
batch_size, channels, height, width = 1, 2, 5, 4
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- assert gradcheck(tgm.filters.sobel, (img,), raise_exception=True)
+ assert gradcheck(kornia.filters.sobel, (img,), raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input):
- return tgm.filters.sobel(input)
+ return kornia.filters.sobel(input)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img)
- expected = tgm.filters.sobel(img)
+ expected = kornia.filters.sobel(img)
assert_allclose(actual, expected)
diff --git a/test/geometry/test_conversions.py b/test/geometry/test_conversions.py
index f8ff8120e..3ec83e395 100644
--- a/test/geometry/test_conversions.py
+++ b/test/geometry/test_conversions.py
@@ -2,7 +2,7 @@ import pytest
import numpy as np
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
from torch.testing import assert_allclose
@@ -18,33 +18,33 @@ class TestAngleAxisToQuaternion:
def test_smoke(self):
angle_axis = torch.zeros(3)
- quaternion = tgm.angle_axis_to_quaternion(angle_axis)
+ quaternion = kornia.angle_axis_to_quaternion(angle_axis)
assert quaternion.shape == (4,)
@pytest.mark.parametrize("batch_size", (1, 3, 8))
def test_smoke_batch(self, batch_size):
angle_axis = torch.zeros(batch_size, 3)
- quaternion = tgm.angle_axis_to_quaternion(angle_axis)
+ quaternion = kornia.angle_axis_to_quaternion(angle_axis)
assert quaternion.shape == (batch_size, 4)
def test_zero_angle(self):
angle_axis = torch.Tensor([0, 0, 0])
expected = torch.Tensor([1, 0, 0, 0])
- quaternion = tgm.angle_axis_to_quaternion(angle_axis)
+ quaternion = kornia.angle_axis_to_quaternion(angle_axis)
assert utils.check_equal_torch(quaternion, expected)
def test_small_angle(self):
theta = 1e-2
angle_axis = torch.Tensor([theta, 0, 0])
expected = torch.Tensor([np.cos(theta / 2), np.sin(theta / 2), 0, 0])
- quaternion = tgm.angle_axis_to_quaternion(angle_axis)
+ quaternion = kornia.angle_axis_to_quaternion(angle_axis)
assert utils.check_equal_torch(quaternion, expected)
def test_x_rotation(self):
half_sqrt2 = 0.5 * np.sqrt(2)
- angle_axis = torch.Tensor([tgm.pi / 2, 0, 0])
+ angle_axis = torch.Tensor([kornia.pi / 2, 0, 0])
expected = torch.Tensor([half_sqrt2, half_sqrt2, 0, 0])
- quaternion = tgm.angle_axis_to_quaternion(angle_axis)
+ quaternion = kornia.angle_axis_to_quaternion(angle_axis)
assert utils.check_equal_torch(quaternion, expected)
def test_gradcheck(self):
@@ -52,7 +52,7 @@ class TestAngleAxisToQuaternion:
angle_axis = torch.Tensor([0, 0, 0]) + eps
angle_axis = utils.tensor_to_gradcheck_var(angle_axis)
# evaluate function gradient
- assert gradcheck(tgm.angle_axis_to_quaternion, (angle_axis,),
+ assert gradcheck(kornia.angle_axis_to_quaternion, (angle_axis,),
raise_exception=True)
@@ -60,38 +60,38 @@ class TestQuaternionToAngleAxis:
def test_smoke(self):
quaternion = torch.zeros(4)
- angle_axis = tgm.quaternion_to_angle_axis(quaternion)
+ angle_axis = kornia.quaternion_to_angle_axis(quaternion)
assert angle_axis.shape == (3,)
@pytest.mark.parametrize("batch_size", (1, 3, 8))
def test_smoke_batch(self, batch_size):
quaternion = torch.zeros(batch_size, 4)
- angle_axis = tgm.quaternion_to_angle_axis(quaternion)
+ angle_axis = kornia.quaternion_to_angle_axis(quaternion)
assert angle_axis.shape == (batch_size, 3)
def test_unit_quaternion(self):
quaternion = torch.Tensor([1, 0, 0, 0])
expected = torch.Tensor([0, 0, 0])
- angle_axis = tgm.quaternion_to_angle_axis(quaternion)
+ angle_axis = kornia.quaternion_to_angle_axis(quaternion)
assert utils.check_equal_torch(angle_axis, expected)
def test_y_rotation(self):
quaternion = torch.Tensor([0, 0, 1, 0])
- expected = torch.Tensor([0, tgm.pi, 0])
- angle_axis = tgm.quaternion_to_angle_axis(quaternion)
+ expected = torch.Tensor([0, kornia.pi, 0])
+ angle_axis = kornia.quaternion_to_angle_axis(quaternion)
assert utils.check_equal_torch(angle_axis, expected)
def test_z_rotation(self):
quaternion = torch.Tensor([np.sqrt(3) / 2, 0, 0, 0.5])
- expected = torch.Tensor([0, 0, tgm.pi / 3])
- angle_axis = tgm.quaternion_to_angle_axis(quaternion)
+ expected = torch.Tensor([0, 0, kornia.pi / 3])
+ angle_axis = kornia.quaternion_to_angle_axis(quaternion)
assert utils.check_equal_torch(angle_axis, expected)
def test_small_angle(self):
theta = 1e-2
quaternion = torch.Tensor([np.cos(theta / 2), np.sin(theta / 2), 0, 0])
expected = torch.Tensor([theta, 0, 0])
- angle_axis = tgm.quaternion_to_angle_axis(quaternion)
+ angle_axis = kornia.quaternion_to_angle_axis(quaternion)
assert utils.check_equal_torch(angle_axis, expected)
def test_gradcheck(self):
@@ -99,30 +99,30 @@ class TestQuaternionToAngleAxis:
quaternion = torch.Tensor([1, 0, 0, 0]) + eps
quaternion = utils.tensor_to_gradcheck_var(quaternion)
# evaluate function gradient
- assert gradcheck(tgm.quaternion_to_angle_axis, (quaternion,),
+ assert gradcheck(kornia.quaternion_to_angle_axis, (quaternion,),
raise_exception=True)
def test_pi():
- assert pytest.approx(tgm.pi.item(), 3.141592)
+ assert pytest.approx(kornia.pi.item(), 3.141592)
@pytest.mark.parametrize("batch_shape", [
(2, 3), (1, 2, 3), (2, 3, 3), (5, 5, 3), ])
def test_rad2deg(batch_shape, device_type):
# generate input data
- x_rad = tgm.pi * torch.rand(batch_shape)
+ x_rad = kornia.pi * torch.rand(batch_shape)
x_rad = x_rad.to(torch.device(device_type))
# convert radians/degrees
- x_deg = tgm.rad2deg(x_rad)
- x_deg_to_rad = tgm.deg2rad(x_deg)
+ x_deg = kornia.rad2deg(x_rad)
+ x_deg_to_rad = kornia.deg2rad(x_deg)
# compute error
error = utils.compute_mse(x_rad, x_deg_to_rad)
# evaluate function gradient
- assert gradcheck(tgm.rad2deg, (utils.tensor_to_gradcheck_var(x_rad),),
+ assert gradcheck(kornia.rad2deg, (utils.tensor_to_gradcheck_var(x_rad),),
raise_exception=True)
@@ -134,14 +134,14 @@ def test_deg2rad(batch_shape, device_type):
x_deg = x_deg.to(torch.device(device_type))
# convert radians/degrees
- x_rad = tgm.deg2rad(x_deg)
- x_rad_to_deg = tgm.rad2deg(x_rad)
+ x_rad = kornia.deg2rad(x_deg)
+ x_rad_to_deg = kornia.rad2deg(x_rad)
# compute error
error = utils.compute_mse(x_deg, x_rad_to_deg)
assert pytest.approx(error.item(), 0.0)
- assert gradcheck(tgm.deg2rad, (utils.tensor_to_gradcheck_var(x_deg),),
+ assert gradcheck(kornia.deg2rad, (utils.tensor_to_gradcheck_var(x_deg),),
raise_exception=True)
@@ -153,14 +153,14 @@ def test_convert_points_to_homogeneous(batch_shape, device_type):
points = points.to(torch.device(device_type))
# to homogeneous
- points_h = tgm.convert_points_to_homogeneous(points)
+ points_h = kornia.convert_points_to_homogeneous(points)
assert points_h.shape[-2] == batch_shape[-2]
assert (points_h[..., -1] == torch.ones(points_h[..., -1].shape)).all()
# evaluate function gradient
points = utils.tensor_to_gradcheck_var(points) # to var
- assert gradcheck(tgm.convert_points_to_homogeneous, (points,),
+ assert gradcheck(kornia.convert_points_to_homogeneous, (points,),
raise_exception=True)
@@ -180,7 +180,7 @@ class TestConvertPointsFromHomogeneous:
]).to(torch.device(device_type))
# to euclidean
- points = tgm.convert_points_from_homogeneous(points_h)
+ points = kornia.convert_points_from_homogeneous(points_h)
assert_allclose(points, expected)
def test_convert_points_batch(self, device_type):
@@ -198,7 +198,7 @@ class TestConvertPointsFromHomogeneous:
]]).to(torch.device(device_type))
# to euclidean
- points = tgm.convert_points_from_homogeneous(points_h)
+ points = kornia.convert_points_from_homogeneous(points_h)
assert_allclose(points, expected)
@pytest.mark.parametrize("batch_shape", [
@@ -208,7 +208,7 @@ class TestConvertPointsFromHomogeneous:
# evaluate function gradient
points_h = utils.tensor_to_gradcheck_var(points_h) # to var
- assert gradcheck(tgm.convert_points_from_homogeneous, (points_h,),
+ assert gradcheck(kornia.convert_points_from_homogeneous, (points_h,),
raise_exception=True)
@@ -220,7 +220,7 @@ def test_angle_axis_to_rotation_matrix(batch_size, device_type):
eye_batch = utils.create_eye_batch(batch_size, 4).to(device)
# apply transform
- rotation_matrix = tgm.angle_axis_to_rotation_matrix(angle_axis)
+ rotation_matrix = kornia.angle_axis_to_rotation_matrix(angle_axis)
rotation_matrix_eye = torch.matmul(
rotation_matrix, rotation_matrix.transpose(1, 2))
@@ -228,7 +228,7 @@ def test_angle_axis_to_rotation_matrix(batch_size, device_type):
# evaluate function gradient
angle_axis = utils.tensor_to_gradcheck_var(angle_axis) # to var
- assert gradcheck(tgm.angle_axis_to_rotation_matrix, (angle_axis,),
+ assert gradcheck(kornia.angle_axis_to_rotation_matrix, (angle_axis,),
raise_exception=True)
@@ -239,7 +239,7 @@ def test_rtvec_to_pose_gradcheck(batch_size, device_type):
# evaluate function gradient
rtvec = utils.tensor_to_gradcheck_var(rtvec) # to var
- assert gradcheck(tgm.rtvec_to_pose, (rtvec,), raise_exception=True)
+ assert gradcheck(kornia.rtvec_to_pose, (rtvec,), raise_exception=True)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
@@ -249,7 +249,7 @@ def test_rotation_matrix_to_angle_axis_gradcheck(batch_size, device_type):
# evaluate function gradient
rmat = utils.tensor_to_gradcheck_var(rmat) # to var
- assert gradcheck(tgm.rotation_matrix_to_angle_axis,
+ assert gradcheck(kornia.rotation_matrix_to_angle_axis,
(rmat,), raise_exception=True)
@@ -267,4 +267,4 @@ def test_rotation_matrix_to_angle_axis(device_type):
rmat = torch.stack([rmat_2, rmat_1], dim=0).to(device)
rvec = torch.stack([rvec_2, rvec_1], dim=0).to(device)
- assert check_equal_torch(tgm.rotation_matrix_to_angle_axis(rmat), rvec)
+ assert check_equal_torch(kornia.rotation_matrix_to_angle_axis(rmat), rvec)
diff --git a/test/geometry/test_linalg.py b/test/geometry/test_linalg.py
index 99d4e050f..1969088f1 100644
--- a/test/geometry/test_linalg.py
+++ b/test/geometry/test_linalg.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
import utils # test utilities
@@ -59,11 +59,11 @@ class TestTransformPoints:
dst_homo_src = dst_homo_src.to(torch.device(device_type))
# transform the points from dst to ref
- points_dst = tgm.transform_points(dst_homo_src, points_src)
+ points_dst = kornia.transform_points(dst_homo_src, points_src)
# transform the points from ref to dst
src_homo_dst = torch.inverse(dst_homo_src)
- points_dst_to_src = tgm.transform_points(src_homo_dst, points_dst)
+ points_dst_to_src = kornia.transform_points(src_homo_dst, points_dst)
# projected should be equal as initial
error = utils.compute_mse(points_src, points_dst_to_src)
@@ -78,7 +78,7 @@ class TestTransformPoints:
# evaluate function gradient
points_src = utils.tensor_to_gradcheck_var(points_src) # to var
dst_homo_src = utils.tensor_to_gradcheck_var(dst_homo_src) # to var
- assert gradcheck(tgm.transform_points, (dst_homo_src, points_src,),
+ assert gradcheck(kornia.transform_points, (dst_homo_src, points_src,),
raise_exception=True)
@@ -90,7 +90,7 @@ class TestComposeTransforms:
trans_12 = identity_matrix(batch_size=1)[0]
trans_12[..., :3, -1] += offset # add offset to translation vector
- trans_02 = tgm.compose_transformations(trans_01, trans_12)
+ trans_02 = kornia.compose_transformations(trans_01, trans_12)
assert utils.check_equal_torch(trans_02, trans_12)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
@@ -100,7 +100,7 @@ class TestComposeTransforms:
trans_12 = identity_matrix(batch_size)
trans_12[..., :3, -1] += offset # add offset to translation vector
- trans_02 = tgm.compose_transformations(trans_01, trans_12)
+ trans_02 = kornia.compose_transformations(trans_01, trans_12)
assert utils.check_equal_torch(trans_02, trans_12)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
@@ -110,7 +110,7 @@ class TestComposeTransforms:
trans_01 = utils.tensor_to_gradcheck_var(trans_01) # to var
trans_12 = utils.tensor_to_gradcheck_var(trans_12) # to var
- assert gradcheck(tgm.compose_transformations, (trans_01, trans_12,),
+ assert gradcheck(kornia.compose_transformations, (trans_01, trans_12,),
raise_exception=True)
@@ -121,8 +121,8 @@ class TestInverseTransformation:
trans_01 = identity_matrix(batch_size=1)[0]
trans_01[..., :3, -1] += offset # add offset to translation vector
- trans_10 = tgm.inverse_transformation(trans_01)
- trans_01_hat = tgm.inverse_transformation(trans_10)
+ trans_10 = kornia.inverse_transformation(trans_01)
+ trans_01_hat = kornia.inverse_transformation(trans_10)
assert utils.check_equal_torch(trans_01, trans_01_hat)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
@@ -131,14 +131,14 @@ class TestInverseTransformation:
trans_01 = identity_matrix(batch_size)
trans_01[..., :3, -1] += offset # add offset to translation vector
- trans_10 = tgm.inverse_transformation(trans_01)
- trans_01_hat = tgm.inverse_transformation(trans_10)
+ trans_10 = kornia.inverse_transformation(trans_01)
+ trans_01_hat = kornia.inverse_transformation(trans_10)
assert utils.check_equal_torch(trans_01, trans_01_hat)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
def test_rotation_translation_Bx4x4(self, batch_size):
offset = 10
- x, y, z = 0, 0, tgm.pi
+ x, y, z = 0, 0, kornia.pi
ones = torch.ones(batch_size)
rmat_01 = euler_angles_to_rotation_matrix(x * ones, y * ones, z * ones)
@@ -146,15 +146,15 @@ class TestInverseTransformation:
trans_01[..., :3, -1] += offset # add offset to translation vector
trans_01[..., :3, :3] = rmat_01[..., :3, :3]
- trans_10 = tgm.inverse_transformation(trans_01)
- trans_01_hat = tgm.inverse_transformation(trans_10)
+ trans_10 = kornia.inverse_transformation(trans_01)
+ trans_01_hat = kornia.inverse_transformation(trans_10)
assert utils.check_equal_torch(trans_01, trans_01_hat)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
def test_gradcheck(self, batch_size):
trans_01 = identity_matrix(batch_size)
trans_01 = utils.tensor_to_gradcheck_var(trans_01) # to var
- assert gradcheck(tgm.inverse_transformation, (trans_01,),
+ assert gradcheck(kornia.inverse_transformation, (trans_01,),
raise_exception=True)
@@ -166,14 +166,14 @@ class TestRelativeTransformation:
trans_02 = identity_matrix(batch_size=1)[0]
trans_02[..., :3, -1] += offset # add offset to translation vector
- trans_12 = tgm.relative_transformation(trans_01, trans_02)
- trans_02_hat = tgm.compose_transformations(trans_01, trans_12)
+ trans_12 = kornia.relative_transformation(trans_01, trans_02)
+ trans_02_hat = kornia.compose_transformations(trans_01, trans_12)
assert utils.check_equal_torch(trans_02_hat, trans_02)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
def test_rotation_translation_Bx4x4(self, batch_size):
offset = 10.
- x, y, z = 0., 0., tgm.pi
+ x, y, z = 0., 0., kornia.pi
ones = torch.ones(batch_size)
rmat_02 = euler_angles_to_rotation_matrix(x * ones, y * ones, z * ones)
@@ -182,8 +182,8 @@ class TestRelativeTransformation:
trans_02[..., :3, -1] += offset # add offset to translation vector
trans_02[..., :3, :3] = rmat_02[..., :3, :3]
- trans_12 = tgm.relative_transformation(trans_01, trans_02)
- trans_02_hat = tgm.compose_transformations(trans_01, trans_12)
+ trans_12 = kornia.relative_transformation(trans_01, trans_02)
+ trans_02_hat = kornia.compose_transformations(trans_01, trans_12)
assert utils.check_equal_torch(trans_02_hat, trans_02)
@pytest.mark.parametrize("batch_size", [1, 2, 5])
@@ -193,5 +193,5 @@ class TestRelativeTransformation:
trans_01 = utils.tensor_to_gradcheck_var(trans_01) # to var
trans_02 = utils.tensor_to_gradcheck_var(trans_02) # to var
- assert gradcheck(tgm.relative_transformation, (trans_01, trans_02,),
+ assert gradcheck(kornia.relative_transformation, (trans_01, trans_02,),
raise_exception=True)
diff --git a/test/geometry/test_pinhole.py b/test/geometry/test_pinhole.py
index e0deaaae0..79868b3ce 100644
--- a/test/geometry/test_pinhole.py
+++ b/test/geometry/test_pinhole.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
from torch.testing import assert_allclose
@@ -30,8 +30,8 @@ class TestPinholeCamera:
extrinsics = torch.eye(4)[None]
height = torch.ones(1)
width = torch.ones(1)
- pinhole = tgm.PinholeCamera(intrinsics, extrinsics, height, width)
- assert isinstance(pinhole, tgm.PinholeCamera)
+ pinhole = kornia.PinholeCamera(intrinsics, extrinsics, height, width)
+ assert isinstance(pinhole, kornia.PinholeCamera)
def test_pinhole_camera_attributes(self):
batch_size = 1
@@ -44,7 +44,7 @@ class TestPinholeCamera:
height = torch.ones(batch_size) * height
width = torch.ones(batch_size) * width
- pinhole = tgm.PinholeCamera(intrinsics, extrinsics, height, width)
+ pinhole = kornia.PinholeCamera(intrinsics, extrinsics, height, width)
assert pinhole.batch_size == batch_size
assert pinhole.fx.item() == fx
@@ -72,7 +72,7 @@ class TestPinholeCamera:
height = torch.ones(batch_size) * height
width = torch.ones(batch_size) * width
- pinhole = tgm.PinholeCamera(intrinsics, extrinsics, height, width)
+ pinhole = kornia.PinholeCamera(intrinsics, extrinsics, height, width)
assert pinhole.tx.item() == tx
assert pinhole.ty.item() == ty
@@ -107,7 +107,7 @@ class TestPinholeCamera:
height = torch.ones(batch_size) * height
width = torch.ones(batch_size) * width
- pinhole = tgm.PinholeCamera(intrinsics, extrinsics, height, width)
+ pinhole = kornia.PinholeCamera(intrinsics, extrinsics, height, width)
assert pinhole.batch_size == batch_size
assert pinhole.fx.shape[0] == batch_size
@@ -137,7 +137,7 @@ class TestPinholeCamera:
width = torch.ones(batch_size) * width
scale_factor = torch.ones(batch_size) * scale_val
- pinhole = tgm.PinholeCamera(intrinsics, extrinsics, height, width)
+ pinhole = kornia.PinholeCamera(intrinsics, extrinsics, height, width)
pinhole_scale = pinhole.scale(scale_factor)
assert utils.check_equal_torch(
@@ -172,7 +172,7 @@ class TestPinholeCamera:
width = torch.ones(batch_size) * width
scale_factor = torch.ones(batch_size) * scale_val
- pinhole = tgm.PinholeCamera(intrinsics, extrinsics, height, width)
+ pinhole = kornia.PinholeCamera(intrinsics, extrinsics, height, width)
pinhole_scale = pinhole.clone()
pinhole_scale.scale_(scale_factor)
@@ -201,14 +201,14 @@ def test_scale_pinhole(batch_size, device_type):
pinholes = torch.rand(batch_size, 12).to(device)
scales = torch.rand(batch_size).to(device)
- pinholes_scale = tgm.scale_pinhole(pinholes, scales)
+ pinholes_scale = kornia.scale_pinhole(pinholes, scales)
assert utils.check_equal_torch(
pinholes_scale[..., :6] / scales.unsqueeze(-1), pinholes[..., :6])
# evaluate function gradient
pinholes = utils.tensor_to_gradcheck_var(pinholes) # to var
scales = utils.tensor_to_gradcheck_var(scales) # to var
- assert gradcheck(tgm.scale_pinhole, (pinholes, scales,),
+ assert gradcheck(kornia.scale_pinhole, (pinholes, scales,),
raise_exception=True)
@@ -227,7 +227,7 @@ def test_pinhole_matrix(batch_size, device_type):
fx, fy, cx, cy, image_height, image_width, rx, ry, rx, tx, ty, tz)
pinhole = pinhole.repeat(batch_size, 1).to(torch.device(device_type))
- pinhole_matrix = tgm.pinhole_matrix(pinhole)
+ pinhole_matrix = kornia.pinhole_matrix(pinhole)
ones = torch.ones(batch_size)
assert bool((pinhole_matrix[:, 0, 0] == fx * ones).all())
@@ -236,11 +236,11 @@ def test_pinhole_matrix(batch_size, device_type):
assert bool((pinhole_matrix[:, 1, 2] == cy * ones).all())
# functional
- assert tgm.PinholeMatrix()(pinhole).shape == (batch_size, 4, 4)
+ assert kornia.PinholeMatrix()(pinhole).shape == (batch_size, 4, 4)
# evaluate function gradient
pinhole = utils.tensor_to_gradcheck_var(pinhole) # to var
- assert gradcheck(tgm.pinhole_matrix, (pinhole,),
+ assert gradcheck(kornia.pinhole_matrix, (pinhole,),
raise_exception=True)
@@ -259,7 +259,7 @@ def test_inverse_pinhole_matrix(batch_size, device_type):
fx, fy, cx, cy, image_height, image_width, rx, ry, rx, tx, ty, tz)
pinhole = pinhole.repeat(batch_size, 1).to(torch.device(device_type))
- pinhole_matrix = tgm.inverse_pinhole_matrix(pinhole)
+ pinhole_matrix = kornia.inverse_pinhole_matrix(pinhole)
ones = torch.ones(batch_size)
assert utils.check_equal_torch(pinhole_matrix[:, 0, 0], (1. / fx) * ones)
@@ -270,11 +270,11 @@ def test_inverse_pinhole_matrix(batch_size, device_type):
pinhole_matrix[:, 1, 2], (-1. * cy / fx) * ones)
# functional
- assert tgm.InversePinholeMatrix()(pinhole).shape == (batch_size, 4, 4)
+ assert kornia.InversePinholeMatrix()(pinhole).shape == (batch_size, 4, 4)
# evaluate function gradient
pinhole = utils.tensor_to_gradcheck_var(pinhole) # to var
- assert gradcheck(tgm.pinhole_matrix, (pinhole,),
+ assert gradcheck(kornia.pinhole_matrix, (pinhole,),
raise_exception=True)
@@ -310,15 +310,15 @@ def test_homography_i_H_ref(batch_size, device_type):
pinhole_i = pinhole_i.repeat(batch_size, 1).to(device)
# compute homography from ref to i
- i_H_ref = tgm.homography_i_H_ref(pinhole_i, pinhole_ref) + eps
+ i_H_ref = kornia.homography_i_H_ref(pinhole_i, pinhole_ref) + eps
i_H_ref_inv = torch.inverse(i_H_ref)
# compute homography from i to ref
- ref_H_i = tgm.homography_i_H_ref(pinhole_ref, pinhole_i) + eps
+ ref_H_i = kornia.homography_i_H_ref(pinhole_ref, pinhole_i) + eps
assert utils.check_equal_torch(i_H_ref_inv, ref_H_i)
# evaluate function gradient
- assert gradcheck(tgm.homography_i_H_ref,
+ assert gradcheck(kornia.homography_i_H_ref,
(utils.tensor_to_gradcheck_var(pinhole_ref) + eps,
utils.tensor_to_gradcheck_var(pinhole_i) + eps,),
raise_exception=True)'''
@@ -327,11 +327,11 @@ def test_homography_i_H_ref(batch_size, device_type):
class TestNormalizePixelCoordinates:
def test_small(self):
height, width = 3, 4
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
- expected = tgm.utils.create_meshgrid(
+ expected = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=True)
- grid_norm = tgm.normalize_pixel_coordinates(
+ grid_norm = kornia.normalize_pixel_coordinates(
grid, height, width)
assert_allclose(grid_norm, expected)
@@ -339,13 +339,13 @@ class TestNormalizePixelCoordinates:
@torch.jit.script
def op_script(input: torch.Tensor, height: int,
width: int) -> torch.Tensor:
- return tgm.normalize_pixel_coordinates(input, height, width)
+ return kornia.normalize_pixel_coordinates(input, height, width)
height, width = 3, 4
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
actual = op_script(grid, height, width)
- expected = tgm.normalize_pixel_coordinates(
+ expected = kornia.normalize_pixel_coordinates(
grid, height, width)
assert_allclose(actual, expected)
@@ -353,10 +353,10 @@ class TestNormalizePixelCoordinates:
def test_jit_trace(self):
@torch.jit.script
def op_script(input, height, width):
- return tgm.normalize_pixel_coordinates(input, height, width)
+ return kornia.normalize_pixel_coordinates(input, height, width)
# 1. Trace op
height, width = 3, 4
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
op_traced = torch.jit.trace(
op_script,
@@ -364,13 +364,13 @@ class TestNormalizePixelCoordinates:
# 2. Generate new input
height, width = 2, 5
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False).repeat(2, 1, 1, 1)
# 3. Evaluate
actual = op_traced(
grid, torch.tensor(height), torch.tensor(width))
- expected = tgm.normalize_pixel_coordinates(
+ expected = kornia.normalize_pixel_coordinates(
grid, height, width)
assert_allclose(actual, expected)
diff --git a/test/geometry/transform/test_affine.py b/test/geometry/transform/test_affine.py
index b5587d5d6..8b2534712 100644
--- a/test/geometry/transform/test_affine.py
+++ b/test/geometry/transform/test_affine.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
from torch.testing import assert_allclose
@@ -26,7 +26,7 @@ class TestRotate:
]])
# prepare transformation
angle = torch.tensor([90.])
- transform = tgm.Rotate(angle)
+ transform = kornia.Rotate(angle)
assert_allclose(transform(inp), expected)
def test_angle90_batch2(self):
@@ -50,7 +50,7 @@ class TestRotate:
]]])
# prepare transformation
angle = torch.tensor([90., -90.])
- transform = tgm.Rotate(angle)
+ transform = kornia.Rotate(angle)
assert_allclose(transform(inp), expected)
def test_angle90_batch2_broadcast(self):
@@ -74,7 +74,7 @@ class TestRotate:
]]])
# prepare transformation
angle = torch.tensor([90.])
- transform = tgm.Rotate(angle)
+ transform = kornia.Rotate(angle)
assert_allclose(transform(inp), expected)
def test_gradcheck(self):
@@ -86,15 +86,15 @@ class TestRotate:
# evaluate function gradient
input = torch.rand(1, 2, 3, 4)
input = utils.tensor_to_gradcheck_var(input) # to var
- assert gradcheck(tgm.rotate, (input, angle,), raise_exception=True)
+ assert gradcheck(kornia.rotate, (input, angle,), raise_exception=True)
@pytest.mark.skip('Need deep look into it since crashes everywhere.')
def test_jit(self):
angle = torch.tensor([90.])
batch_size, channels, height, width = 2, 3, 64, 64
img = torch.ones(batch_size, channels, height, width)
- rot = tgm.Rotate(angle)
- rot_traced = torch.jit.trace(tgm.Rotate(angle), img)
+ rot = kornia.Rotate(angle)
+ rot_traced = torch.jit.trace(kornia.Rotate(angle), img)
assert_allclose(rot(img), rot_traced(img))
@@ -115,7 +115,7 @@ class TestTranslate:
]])
# prepare transformation
translation = torch.tensor([[1., 0.]])
- transform = tgm.Translate(translation)
+ transform = kornia.Translate(translation)
assert_allclose(transform(inp), expected)
def test_dxdy_batch(self):
@@ -139,7 +139,7 @@ class TestTranslate:
]]])
# prepare transformation
translation = torch.tensor([[1., 0.], [1., 1.]])
- transform = tgm.Translate(translation)
+ transform = kornia.Translate(translation)
assert_allclose(transform(inp), expected)
def test_dxdy_batch_broadcast(self):
@@ -163,7 +163,7 @@ class TestTranslate:
]]])
# prepare transformation
translation = torch.tensor([[1., 0.]])
- transform = tgm.Translate(translation)
+ transform = kornia.Translate(translation)
assert_allclose(transform(inp), expected)
def test_gradcheck(self):
@@ -175,7 +175,7 @@ class TestTranslate:
# evaluate function gradient
input = torch.rand(1, 2, 3, 4)
input = utils.tensor_to_gradcheck_var(input) # to var
- assert gradcheck(tgm.translate, (input, translation,),
+ assert gradcheck(kornia.translate, (input, translation,),
raise_exception=True)
@pytest.mark.skip('Need deep look into it since crashes everywhere.')
@@ -183,8 +183,8 @@ class TestTranslate:
translation = torch.tensor([[1., 0.]])
batch_size, channels, height, width = 2, 3, 64, 64
img = torch.ones(batch_size, channels, height, width)
- trans = tgm.Translate(translation)
- trans_traced = torch.jit.trace(tgm.Translate(translation), img)
+ trans = kornia.Translate(translation)
+ trans_traced = torch.jit.trace(kornia.Translate(translation), img)
assert_allclose(trans(img), trans_traced(img))
@@ -199,7 +199,7 @@ class TestScale:
]])
# prepare transformation
scale_factor = torch.tensor([2.])
- transform = tgm.Scale(scale_factor)
+ transform = kornia.Scale(scale_factor)
assert_allclose(transform(inp).sum().item(), 12.25)
def test_scale_factor_05(self):
@@ -218,7 +218,7 @@ class TestScale:
]])
# prepare transformation
scale_factor = torch.tensor([0.5])
- transform = tgm.Scale(scale_factor)
+ transform = kornia.Scale(scale_factor)
assert_allclose(transform(inp), expected)
def test_scale_factor_05_batch2(self):
@@ -237,7 +237,7 @@ class TestScale:
]])
# prepare transformation
scale_factor = torch.tensor([0.5, 0.5])
- transform = tgm.Scale(scale_factor)
+ transform = kornia.Scale(scale_factor)
assert_allclose(transform(inp), expected)
def test_scale_factor_05_batch2_broadcast(self):
@@ -256,7 +256,7 @@ class TestScale:
]])
# prepare transformation
scale_factor = torch.tensor([0.5])
- transform = tgm.Scale(scale_factor)
+ transform = kornia.Scale(scale_factor)
assert_allclose(transform(inp), expected)
def test_gradcheck(self):
@@ -268,7 +268,7 @@ class TestScale:
# evaluate function gradient
input = torch.rand(1, 2, 3, 4)
input = utils.tensor_to_gradcheck_var(input) # to var
- assert gradcheck(tgm.scale, (input, scale_factor,),
+ assert gradcheck(kornia.scale, (input, scale_factor,),
raise_exception=True)
@pytest.mark.skip('Need deep look into it since crashes everywhere.')
@@ -276,8 +276,8 @@ class TestScale:
scale_factor = torch.tensor([0.5])
batch_size, channels, height, width = 2, 3, 64, 64
img = torch.ones(batch_size, channels, height, width)
- trans = tgm.Scale(scale_factor)
- trans_traced = torch.jit.trace(tgm.Scale(scale_factor), img)
+ trans = kornia.Scale(scale_factor)
+ trans_traced = torch.jit.trace(kornia.Scale(scale_factor), img)
assert_allclose(trans(img), trans_traced(img))
@@ -299,7 +299,7 @@ class TestShear:
# prepare transformation
shear = torch.tensor([[0.5, 0.0]])
- transform = tgm.Shear(shear)
+ transform = kornia.Shear(shear)
assert_allclose(transform(inp), expected)
def test_shear_y(self):
@@ -319,7 +319,7 @@ class TestShear:
# prepare transformation
shear = torch.tensor([[0.0, 0.5]])
- transform = tgm.Shear(shear)
+ transform = kornia.Shear(shear)
assert_allclose(transform(inp), expected)
def test_shear_batch2(self):
@@ -345,7 +345,7 @@ class TestShear:
# prepare transformation
shear = torch.tensor([[0.5, 0.0], [0.0, 0.5]])
- transform = tgm.Shear(shear)
+ transform = kornia.Shear(shear)
assert_allclose(transform(inp), expected)
def test_shear_batch2_broadcast(self):
@@ -366,7 +366,7 @@ class TestShear:
# prepare transformation
shear = torch.tensor([[0.5, 0.0]])
- transform = tgm.Shear(shear)
+ transform = kornia.Shear(shear)
assert_allclose(transform(inp), expected)
def test_gradcheck(self):
@@ -378,13 +378,13 @@ class TestShear:
# evaluate function gradient
input = torch.rand(1, 2, 3, 4)
input = utils.tensor_to_gradcheck_var(input) # to var
- assert gradcheck(tgm.shear, (input, shear,), raise_exception=True)
+ assert gradcheck(kornia.shear, (input, shear,), raise_exception=True)
@pytest.mark.skip('Need deep look into it since crashes everywhere.')
def test_jit(self):
shear = torch.tensor([[0.5, 0.0]])
batch_size, channels, height, width = 2, 3, 64, 64
img = torch.ones(batch_size, channels, height, width)
- trans = tgm.Shear(shear)
- trans_traced = torch.jit.trace(tgm.Shear(shear), img)
+ trans = kornia.Shear(shear)
+ trans_traced = torch.jit.trace(kornia.Shear(shear), img)
assert_allclose(trans(img), trans_traced(img))
diff --git a/test/geometry/transform/test_crop.py b/test/geometry/transform/test_crop.py
index 4ef78ece3..aa87b08cb 100644
--- a/test/geometry/transform/test_crop.py
+++ b/test/geometry/transform/test_crop.py
@@ -3,7 +3,7 @@ from typing import Tuple
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.testing import assert_allclose
from torch.autograd import gradcheck
@@ -32,7 +32,7 @@ class TestCropAndResize:
[2., 2.],
]]) # 1x4x2
- patches = tgm.crop_and_resize(inp, boxes, (height, width))
+ patches = kornia.crop_and_resize(inp, boxes, (height, width))
assert_allclose(patches, expected)
def test_crop_batch(self):
@@ -69,7 +69,7 @@ class TestCropAndResize:
[3., 3.],
]]) # 2x4x2
- patches = tgm.crop_and_resize(inp, boxes, (height, width))
+ patches = kornia.crop_and_resize(inp, boxes, (height, width))
assert_allclose(patches, expected)
def test_crop_batch_broadcast(self):
@@ -101,7 +101,7 @@ class TestCropAndResize:
[2., 2.],
]]) # 1x4x2
- patches = tgm.crop_and_resize(inp, boxes, (height, width))
+ patches = kornia.crop_and_resize(inp, boxes, (height, width))
assert_allclose(patches, expected)
def test_gradcheck(self):
@@ -119,7 +119,7 @@ class TestCropAndResize:
boxes, requires_grad=False) # to var
crop_height, crop_width = 4, 2
- assert gradcheck(tgm.crop_and_resize,
+ assert gradcheck(kornia.crop_and_resize,
(img, boxes, (crop_height, crop_width),),
raise_exception=True)
@@ -128,7 +128,7 @@ class TestCropAndResize:
def op_script(input: torch.Tensor,
boxes: torch.Tensor,
size: Tuple[int, int]) -> torch.Tensor:
- return tgm.crop_and_resize(input, boxes, size)
+ return kornia.crop_and_resize(input, boxes, size)
img = torch.tensor([[
[1., 2., 3., 4.],
[5., 6., 7., 8.],
@@ -144,7 +144,7 @@ class TestCropAndResize:
crop_height, crop_width = 4, 2
actual = op_script(img, boxes, (crop_height, crop_width))
- expected = tgm.crop_and_resize(img, boxes, (crop_height, crop_width))
+ expected = kornia.crop_and_resize(img, boxes, (crop_height, crop_width))
assert_allclose(actual, expected)
@@ -163,7 +163,7 @@ class TestCenterCrop:
[9., 10., 11., 12.],
]])
- out_crop = tgm.center_crop(inp, (height, width))
+ out_crop = kornia.center_crop(inp, (height, width))
assert_allclose(out_crop, expected)
def test_center_crop_h4_w2(self):
@@ -182,7 +182,7 @@ class TestCenterCrop:
[14., 15.],
]])
- out_crop = tgm.center_crop(inp, (height, width))
+ out_crop = kornia.center_crop(inp, (height, width))
assert_allclose(out_crop, expected)
def test_center_crop_h4_w2_batch(self):
@@ -211,7 +211,7 @@ class TestCenterCrop:
[8., 12.],
]])
- out_crop = tgm.center_crop(inp, (height, width))
+ out_crop = kornia.center_crop(inp, (height, width))
assert_allclose(out_crop, expected)
def test_gradcheck(self):
@@ -220,27 +220,27 @@ class TestCenterCrop:
img = utils.tensor_to_gradcheck_var(img) # to var
crop_height, crop_width = 4, 2
- assert gradcheck(tgm.center_crop, (img, (crop_height, crop_width),),
+ assert gradcheck(kornia.center_crop, (img, (crop_height, crop_width),),
raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input: torch.Tensor,
size: Tuple[int, int]) -> torch.Tensor:
- return tgm.center_crop(input, size)
+ return kornia.center_crop(input, size)
batch_size, channels, height, width = 1, 2, 5, 4
img = torch.ones(batch_size, channels, height, width)
crop_height, crop_width = 4, 2
actual = op_script(img, (crop_height, crop_width))
- expected = tgm.center_crop(img, (crop_height, crop_width))
+ expected = kornia.center_crop(img, (crop_height, crop_width))
assert_allclose(actual, expected)
def test_jit_trace(self):
@torch.jit.script
def op_script(input: torch.Tensor,
size: Tuple[torch.Tensor, torch.Tensor]) -> torch.Tensor:
- return tgm.center_crop(input, size)
+ return kornia.center_crop(input, size)
# 1. Trace op
batch_size, channels, height, width = 1, 2, 5, 4
img = torch.ones(batch_size, channels, height, width)
@@ -258,5 +258,5 @@ class TestCenterCrop:
crop_height, crop_width = 2, 3
actual = op_trace(
img, (torch.tensor(crop_height), torch.tensor(crop_width)))
- expected = tgm.center_crop(img, (crop_height, crop_width))
+ expected = kornia.center_crop(img, (crop_height, crop_width))
assert_allclose(actual, expected)
diff --git a/test/geometry/transform/test_imgwarp.py b/test/geometry/transform/test_imgwarp.py
index e6c0b36cd..5df99d69c 100644
--- a/test/geometry/transform/test_imgwarp.py
+++ b/test/geometry/transform/test_imgwarp.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
from torch.testing import assert_allclose
@@ -13,7 +13,7 @@ from common import device_type
def test_warp_perspective_rotation(batch_shape, device_type):
# generate input data
batch_size, channels, height, width = batch_shape
- alpha = 0.5 * tgm.pi * torch.ones(batch_size) # 90 deg rotation
+ alpha = 0.5 * kornia.pi * torch.ones(batch_size) # 90 deg rotation
# create data patch
device = torch.device(device_type)
@@ -28,14 +28,14 @@ def test_warp_perspective_rotation(batch_shape, device_type):
# apply transformation and inverse
_, _, h, w = patch.shape
- patch_warped = tgm.warp_perspective(patch, M, dsize=(height, width))
- patch_warped_inv = tgm.warp_perspective(
+ patch_warped = kornia.warp_perspective(patch, M, dsize=(height, width))
+ patch_warped_inv = kornia.warp_perspective(
patch_warped, torch.inverse(M), dsize=(height, width))
# generate mask to compute error
mask = torch.ones_like(patch)
- mask_warped_inv = tgm.warp_perspective(
- tgm.warp_perspective(patch, M, dsize=(height, width)),
+ mask_warped_inv = kornia.warp_perspective(
+ kornia.warp_perspective(patch, M, dsize=(height, width)),
torch.inverse(M),
dsize=(height, width))
@@ -46,7 +46,7 @@ def test_warp_perspective_rotation(batch_shape, device_type):
patch = utils.tensor_to_gradcheck_var(patch) # to var
M = utils.tensor_to_gradcheck_var(M, requires_grad=False) # to var
assert gradcheck(
- tgm.warp_perspective, (patch, M, (
+ kornia.warp_perspective, (patch, M, (
height,
width,
)),
@@ -71,16 +71,16 @@ def test_get_perspective_transform(batch_size, device_type):
points_dst = points_src + norm
# compute transform from source to target
- dst_homo_src = tgm.get_perspective_transform(points_src, points_dst)
+ dst_homo_src = kornia.get_perspective_transform(points_src, points_dst)
assert utils.check_equal_torch(
- tgm.transform_points(dst_homo_src, points_src), points_dst)
+ kornia.transform_points(dst_homo_src, points_src), points_dst)
# compute gradient check
points_src = utils.tensor_to_gradcheck_var(points_src) # to var
points_dst = utils.tensor_to_gradcheck_var(points_dst) # to var
assert gradcheck(
- tgm.get_perspective_transform, (
+ kornia.get_perspective_transform, (
points_src,
points_dst,
),
@@ -99,7 +99,7 @@ def test_rotation_matrix2d(batch_size, device_type):
center = center_base
angle = 90. * angle_base
scale = scale_base
- M = tgm.get_rotation_matrix2d(center, angle, scale)
+ M = kornia.get_rotation_matrix2d(center, angle, scale)
for i in range(batch_size):
pytest.approx(M[i, 0, 0].item(), 0.0)
@@ -111,7 +111,7 @@ def test_rotation_matrix2d(batch_size, device_type):
center = center_base
angle = 90. * angle_base
scale = 2. * scale_base
- M = tgm.get_rotation_matrix2d(center, angle, scale)
+ M = kornia.get_rotation_matrix2d(center, angle, scale)
for i in range(batch_size):
pytest.approx(M[i, 0, 0].item(), 0.0)
@@ -123,7 +123,7 @@ def test_rotation_matrix2d(batch_size, device_type):
center = center_base
angle = 45. * angle_base
scale = scale_base
- M = tgm.get_rotation_matrix2d(center, angle, scale)
+ M = kornia.get_rotation_matrix2d(center, angle, scale)
for i in range(batch_size):
pytest.approx(M[i, 0, 0].item(), 0.7071)
@@ -136,7 +136,7 @@ def test_rotation_matrix2d(batch_size, device_type):
angle = utils.tensor_to_gradcheck_var(angle) # to var
scale = utils.tensor_to_gradcheck_var(scale) # to var
assert gradcheck(
- tgm.get_rotation_matrix2d, (center, angle, scale),
+ kornia.get_rotation_matrix2d, (center, angle, scale),
raise_exception=True)
@@ -168,9 +168,9 @@ class TestWarpPerspective:
]])
# compute transformation between points
- dst_trans_src = tgm.get_perspective_transform(points_src,
- points_dst).expand(
- batch_size, -1, -1)
+ dst_trans_src = kornia.get_perspective_transform(points_src,
+ points_dst).expand(
+ batch_size, -1, -1)
# warp tensor
patch = torch.FloatTensor([[[
@@ -187,8 +187,8 @@ class TestWarpPerspective:
]]])
# warp and assert
- patch_warped = tgm.warp_perspective(patch, dst_trans_src,
- (dst_h, dst_w))
+ patch_warped = kornia.warp_perspective(patch, dst_trans_src,
+ (dst_h, dst_w))
assert_allclose(patch_warped, expected)
def test_crop_center_resize(self, device_type):
@@ -215,7 +215,7 @@ class TestWarpPerspective:
]])
# compute transformation between points
- dst_trans_src = tgm.get_perspective_transform(points_src, points_dst)
+ dst_trans_src = kornia.get_perspective_transform(points_src, points_dst)
# warp tensor
patch = torch.FloatTensor([[[
@@ -233,8 +233,8 @@ class TestWarpPerspective:
]]])
# warp and assert
- patch_warped = tgm.warp_perspective(patch, dst_trans_src,
- (dst_h, dst_w))
+ patch_warped = kornia.warp_perspective(patch, dst_trans_src,
+ (dst_h, dst_w))
assert_allclose(patch_warped, expected)
@@ -243,7 +243,7 @@ class TestWarpAffine:
batch_size, channels, height, width = 1, 2, 3, 4
aff_ab = torch.eye(2, 3)[None] # 1x2x3
img_b = torch.rand(batch_size, channels, height, width)
- img_a = tgm.warp_affine(img_b, aff_ab, (height, width))
+ img_a = kornia.warp_affine(img_b, aff_ab, (height, width))
assert img_b.shape == img_a.shape
@pytest.mark.parametrize("batch_size", [1, 2, 5])
@@ -254,7 +254,7 @@ class TestWarpAffine:
aff_ab[..., -1] += offset
img_b = torch.arange(float(height * width)).view(
1, channels, height, width).repeat(batch_size, 1, 1, 1)
- img_a = tgm.warp_affine(img_b, aff_ab, (height, width))
+ img_a = kornia.warp_affine(img_b, aff_ab, (height, width))
assert utils.check_equal_torch(img_b[..., :2, :3], img_a[..., 1:, 1:])
def test_gradcheck(self):
@@ -265,7 +265,7 @@ class TestWarpAffine:
aff_ab, requires_grad=False) # to var
img_b = utils.tensor_to_gradcheck_var(img_b) # to var
assert gradcheck(
- tgm.warp_affine, (
+ kornia.warp_affine, (
img_b,
aff_ab,
(height, width),
@@ -277,9 +277,9 @@ class TestRemap:
def test_smoke(self):
height, width = 3, 4
input = torch.ones(1, 1, height, width)
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
- input_warped = tgm.remap(input, grid[..., 0], grid[..., 1])
+ input_warped = kornia.remap(input, grid[..., 0], grid[..., 1])
assert_allclose(input, input_warped)
def test_shift(self):
@@ -295,11 +295,11 @@ class TestRemap:
[0., 0., 0., 0.],
]]])
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid += 1. # apply shift in both x/y direction
- input_warped = tgm.remap(inp, grid[..., 0], grid[..., 1])
+ input_warped = kornia.remap(inp, grid[..., 0], grid[..., 1])
assert_allclose(input_warped, expected)
def test_shift_batch(self):
@@ -321,13 +321,13 @@ class TestRemap:
]]])
# generate a batch of grids
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid = grid.repeat(2, 1, 1, 1)
grid[0, ..., 0] += 1. # apply shift in the x direction
grid[1, ..., 1] += 1. # apply shift in the y direction
- input_warped = tgm.remap(inp, grid[..., 0], grid[..., 1])
+ input_warped = kornia.remap(inp, grid[..., 0], grid[..., 1])
assert_allclose(input_warped, expected)
def test_shift_batch_broadcast(self):
@@ -343,11 +343,11 @@ class TestRemap:
[0., 0., 0., 0.],
]]])
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid += 1. # apply shift in both x/y direction
- input_warped = tgm.remap(inp, grid[..., 0], grid[..., 1])
+ input_warped = kornia.remap(inp, grid[..., 0], grid[..., 1])
assert_allclose(input_warped, expected)
def test_gradcheck(self):
@@ -355,38 +355,38 @@ class TestRemap:
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid = utils.tensor_to_gradcheck_var(
grid, requires_grad=False) # to var
- assert gradcheck(tgm.remap, (img, grid[..., 0], grid[..., 1],),
+ assert gradcheck(kornia.remap, (img, grid[..., 0], grid[..., 1],),
raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input, map1, map2):
- return tgm.remap(input, map1, map2)
+ return kornia.remap(input, map1, map2)
batch_size, channels, height, width = 1, 1, 3, 4
img = torch.ones(batch_size, channels, height, width)
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid += 1. # apply some shift
input = (img, grid[..., 0], grid[..., 1],)
actual = op_script(*input)
- expected = tgm.remap(*input)
+ expected = kornia.remap(*input)
assert_allclose(actual, expected)
def test_jit_trace(self):
@torch.jit.script
def op_script(input, map1, map2):
- return tgm.remap(input, map1, map2)
+ return kornia.remap(input, map1, map2)
# 1. Trace op
batch_size, channels, height, width = 1, 1, 3, 4
img = torch.ones(batch_size, channels, height, width)
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid += 1. # apply some shift
input_tuple = (img, grid[..., 0], grid[..., 1])
@@ -395,21 +395,21 @@ class TestRemap:
# 2. Generate different input
batch_size, channels, height, width = 2, 2, 2, 5
img = torch.ones(batch_size, channels, height, width)
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid += 2. # apply some shift
# 3. Apply to different input
input_tuple = (img, grid[..., 0], grid[..., 1])
actual = op_script(*input_tuple)
- expected = tgm.remap(*input_tuple)
+ expected = kornia.remap(*input_tuple)
assert_allclose(actual, expected)
class TestInvertAffineTransform:
def test_smoke(self):
matrix = torch.eye(2, 3)
- matrix_inv = tgm.invert_affine_transform(matrix)
+ matrix_inv = kornia.invert_affine_transform(matrix)
assert_allclose(matrix, matrix_inv)
def test_rot90(self):
@@ -420,8 +420,8 @@ class TestInvertAffineTransform:
[0., -1., 0.],
[1., 0., 0.],
]])
- matrix = tgm.get_rotation_matrix2d(center, angle, scale)
- matrix_inv = tgm.invert_affine_transform(matrix)
+ matrix = kornia.get_rotation_matrix2d(center, angle, scale)
+ matrix_inv = kornia.invert_affine_transform(matrix)
assert_allclose(matrix_inv, expected)
def test_rot90_batch(self):
@@ -432,34 +432,34 @@ class TestInvertAffineTransform:
[0., -1., 0.],
[1., 0., 0.],
]])
- matrix = tgm.get_rotation_matrix2d(
+ matrix = kornia.get_rotation_matrix2d(
center, angle, scale).repeat(2, 1, 1)
- matrix_inv = tgm.invert_affine_transform(matrix)
+ matrix_inv = kornia.invert_affine_transform(matrix)
assert_allclose(matrix_inv, expected)
def test_gradcheck(self):
matrix = torch.eye(2, 3)
matrix = utils.tensor_to_gradcheck_var(matrix) # to var
- assert gradcheck(tgm.invert_affine_transform, (matrix,),
+ assert gradcheck(kornia.invert_affine_transform, (matrix,),
raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input):
- return tgm.invert_affine_transform(input)
+ return kornia.invert_affine_transform(input)
matrix = torch.eye(2, 3)
op_traced = torch.jit.trace(op_script, matrix)
actual = op_traced(matrix)
- expected = tgm.invert_affine_transform(matrix)
+ expected = kornia.invert_affine_transform(matrix)
assert_allclose(actual, expected)
def test_jit_trace(self):
@torch.jit.script
def op_script(input):
- return tgm.invert_affine_transform(input)
+ return kornia.invert_affine_transform(input)
matrix = torch.eye(2, 3)
matrix_2 = torch.eye(2, 3).repeat(2, 1, 1)
op_traced = torch.jit.trace(op_script, matrix)
actual = op_traced(matrix_2)
- expected = tgm.invert_affine_transform(matrix_2)
+ expected = kornia.invert_affine_transform(matrix_2)
assert_allclose(actual, expected)
diff --git a/test/geometry/transform/test_pyramid.py b/test/geometry/transform/test_pyramid.py
index e57fda7c5..e12bed39a 100644
--- a/test/geometry/transform/test_pyramid.py
+++ b/test/geometry/transform/test_pyramid.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.testing import assert_allclose
from torch.autograd import gradcheck
@@ -11,12 +11,12 @@ import utils # test utils
class TestPyrUp:
def test_shape(self):
inp = torch.zeros(1, 2, 4, 4)
- pyr = tgm.geometry.PyrUp()
+ pyr = kornia.geometry.PyrUp()
assert pyr(inp).shape == (1, 2, 8, 8)
def test_shape_batch(self):
inp = torch.zeros(2, 2, 4, 4)
- pyr = tgm.geometry.PyrUp()
+ pyr = kornia.geometry.PyrUp()
assert pyr(inp).shape == (2, 2, 8, 8)
def test_gradcheck(self):
@@ -24,27 +24,27 @@ class TestPyrUp:
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- assert gradcheck(tgm.geometry.pyrup, (img,), raise_exception=True)
+ assert gradcheck(kornia.geometry.pyrup, (img,), raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input):
- return tgm.geometry.pyrup(input)
+ return kornia.geometry.pyrup(input)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img)
- expected = tgm.geometry.pyrup(img)
+ expected = kornia.geometry.pyrup(img)
assert_allclose(actual, expected)
class TestPyrDown:
def test_shape(self):
inp = torch.zeros(1, 2, 4, 4)
- pyr = tgm.geometry.PyrDown()
+ pyr = kornia.geometry.PyrDown()
assert pyr(inp).shape == (1, 2, 2, 2)
def test_shape_batch(self):
inp = torch.zeros(2, 2, 4, 4)
- pyr = tgm.geometry.PyrDown()
+ pyr = kornia.geometry.PyrDown()
assert pyr(inp).shape == (2, 2, 2, 2)
def test_gradcheck(self):
@@ -52,13 +52,13 @@ class TestPyrDown:
img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
- assert gradcheck(tgm.geometry.pyrdown, (img,), raise_exception=True)
+ assert gradcheck(kornia.geometry.pyrdown, (img,), raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input):
- return tgm.geometry.pyrdown(input)
+ return kornia.geometry.pyrdown(input)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img)
- expected = tgm.geometry.pyrdown(img)
+ expected = kornia.geometry.pyrdown(img)
assert_allclose(actual, expected)
diff --git a/test/geometry/warp/test_depth_warper.py b/test/geometry/warp/test_depth_warper.py
index 4718a9987..1703dd6e1 100644
--- a/test/geometry/warp/test_depth_warper.py
+++ b/test/geometry/warp/test_depth_warper.py
@@ -1,11 +1,11 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
import utils # test utils
-from torchgeometry.geometry.conversions import normalize_pixel_coordinates
+from kornia.geometry.conversions import normalize_pixel_coordinates
class TestDepthWarper:
@@ -19,9 +19,9 @@ class TestDepthWarper:
tx, ty, tz = 0, 0, 0
# create pinhole cameras
- pinhole_src = tgm.PinholeCamera.from_parameters(
+ pinhole_src = kornia.PinholeCamera.from_parameters(
fx, fy, cx, cy, height, width, tx, ty, tz, batch_size)
- pinhole_dst = tgm.PinholeCamera.from_parameters(
+ pinhole_dst = kornia.PinholeCamera.from_parameters(
fx, fy, cx, cy, height, width, tx, ty, tz, batch_size)
return pinhole_src, pinhole_dst
@@ -32,7 +32,7 @@ class TestDepthWarper:
pinhole_dst.tx += 1. # apply offset to tx
# create warper
- warper = tgm.DepthWarper(pinhole_dst, height, width)
+ warper = kornia.DepthWarper(pinhole_dst, height, width)
assert warper._dst_proj_src is None
# initialize projection matrices
@@ -58,7 +58,7 @@ class TestDepthWarper:
depth_src = torch.ones(batch_size, 1, height, width)
# create warper, initialize projection matrices and warp grid
- warper = tgm.DepthWarper(pinhole_dst, height, width)
+ warper = kornia.DepthWarper(pinhole_dst, height, width)
warper.compute_projection_matrix(pinhole_src)
grid_warped = warper.warp_grid(depth_src)
@@ -86,7 +86,7 @@ class TestDepthWarper:
depth_src = torch.ones(batch_size, 1, height, width)
# create warper, initialize projection matrices and warp grid
- warper = tgm.DepthWarper(pinhole_dst, height, width)
+ warper = kornia.DepthWarper(pinhole_dst, height, width)
warper.compute_projection_matrix(pinhole_src)
grid_warped = warper.warp_grid(depth_src)
@@ -114,7 +114,7 @@ class TestDepthWarper:
depth_src = torch.ones(batch_size, 1, height, width)
# create warper, initialize projection matrices and warp grid
- warper = tgm.DepthWarper(pinhole_dst, height, width)
+ warper = kornia.DepthWarper(pinhole_dst, height, width)
warper.compute_projection_matrix(pinhole_src)
# create patch to warp
@@ -134,7 +134,7 @@ class TestDepthWarper:
pinhole_src, pinhole_dst = self._create_pinhole_pair(batch_size)
# create warper, initialize projection matrices and warp grid
- warper = tgm.DepthWarper(pinhole_dst, height, width)
+ warper = kornia.DepthWarper(pinhole_dst, height, width)
warper.compute_projection_matrix(pinhole_src)
# test compute_projection
@@ -147,7 +147,7 @@ class TestDepthWarper:
pinhole_src, pinhole_dst = self._create_pinhole_pair(batch_size)
# create warper, initialize projection matrices and warp grid
- warper = tgm.DepthWarper(pinhole_dst, height, width)
+ warper = kornia.DepthWarper(pinhole_dst, height, width)
warper.compute_projection_matrix(pinhole_src)
# test compute_subpixel_step
@@ -169,7 +169,7 @@ class TestDepthWarper:
img_dst = utils.tensor_to_gradcheck_var(img_dst) # to var
# evaluate function gradient
- assert gradcheck(tgm.depth_warp,
+ assert gradcheck(kornia.depth_warp,
(pinhole_dst,
pinhole_src,
depth_src,
diff --git a/test/geometry/warp/test_homography_warper.py b/test/geometry/warp/test_homography_warper.py
index b8fc9f457..069042e3c 100644
--- a/test/geometry/warp/test_homography_warper.py
+++ b/test/geometry/warp/test_homography_warper.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
import utils # test utils
@@ -20,7 +20,7 @@ class TestHomographyWarper:
dst_homo_src = utils.create_eye_batch(batch_size=1, eye_size=3)
# instantiate warper
- warper = tgm.HomographyWarper(height, width)
+ warper = kornia.HomographyWarper(height, width)
# warp from source to destination
patch_dst = warper(patch_src, dst_homo_src)
@@ -37,8 +37,8 @@ class TestHomographyWarper:
dst_homo_src[..., 0, 2] = offset # apply offset in x
# instantiate warper
- warper = tgm.HomographyWarper(height, width,
- normalized_coordinates=False)
+ warper = kornia.HomographyWarper(height, width,
+ normalized_coordinates=False)
flow = warper.warp_grid(dst_homo_src)
# the grid the src plus the offset should be equal to the flow
@@ -57,7 +57,7 @@ class TestHomographyWarper:
dst_homo_src = utils.create_eye_batch(batch_size, eye_size=3)
# instantiate warper warp from source to destination
- warper = tgm.HomographyWarper(height // 2, width // 2)
+ warper = kornia.HomographyWarper(height // 2, width // 2)
patch_dst = warper(patch_src, dst_homo_src)
# check the corners
@@ -81,7 +81,7 @@ class TestHomographyWarper:
dst_homo_src[..., 0, 2] = offset / (width - 1) # apply offset in x
# instantiate warper and from source to destination
- warper = tgm.HomographyWarper(height, width)
+ warper = kornia.HomographyWarper(height, width)
patch_dst = warper(patch_src, dst_homo_src)
assert utils.check_equal_torch(patch_src[..., 1:], patch_dst[..., :-1])
@@ -99,7 +99,7 @@ class TestHomographyWarper:
dst_homo_src[..., 1, 1] = 0.0
# instantiate warper and warp from source to destination
- warper = tgm.HomographyWarper(height, width)
+ warper = kornia.HomographyWarper(height, width)
patch_dst = warper(patch_src, dst_homo_src)
# check the corners
@@ -129,7 +129,7 @@ class TestHomographyWarper:
dst_homo_src = utils.create_eye_batch(batch_size, eye_size).to(device)
# instantiate warper
- warper = tgm.HomographyWarper(height, width)
+ warper = kornia.HomographyWarper(height, width)
for i in range(self.num_tests):
# generate homography noise
@@ -149,7 +149,7 @@ class TestHomographyWarper:
assert error.item() < self.threshold
# check functional api
- patch_dst_to_src_functional = tgm.homography_warp(
+ patch_dst_to_src_functional = kornia.homography_warp(
patch_dst, torch.inverse(dst_homo_src_i), (height, width))
assert utils.check_equal_torch(
@@ -173,7 +173,7 @@ class TestHomographyWarper:
dst_homo_src, requires_grad=False) # to var
# instantiate warper
- warper = tgm.HomographyWarper(height, width)
+ warper = kornia.HomographyWarper(height, width)
# evaluate function gradient
assert gradcheck(warper, (patch_src, dst_homo_src,),
diff --git a/test/integration/test_focal.py b/test/integration/test_focal.py
index f7d9e64b1..790b5724c 100644
--- a/test/integration/test_focal.py
+++ b/test/integration/test_focal.py
@@ -5,7 +5,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
-import torchgeometry as tgm
+import kornia as kornia
logger = logging.getLogger(__name__)
@@ -46,7 +46,7 @@ class TestIntegrationFocalLoss:
optimizer = optim.Adam(m.parameters(), lr=self.lr)
- criterion = tgm.losses.FocalLoss(
+ criterion = kornia.losses.FocalLoss(
alpha=self.alpha, gamma=self.gamma, reduction='mean')
# NOTE: uncomment to compare against vanilla cross entropy
# criterion = nn.CrossEntropyLoss()
diff --git a/test/integration/test_soft_argmax2d.py b/test/integration/test_soft_argmax2d.py
index 1bf158bce..d6a69e47c 100644
--- a/test/integration/test_soft_argmax2d.py
+++ b/test/integration/test_soft_argmax2d.py
@@ -5,7 +5,7 @@ import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
-import torchgeometry as tgm
+import kornia as kornia
logger = logging.getLogger(__name__)
@@ -42,7 +42,7 @@ class TestIntegrationSoftArgmax2d:
criterion = nn.MSELoss()
# spatial soft-argmax2d module
- soft_argmax2d = tgm.contrib.SpatialSoftArgmax2d(
+ soft_argmax2d = kornia.contrib.SpatialSoftArgmax2d(
normalized_coordinates=False)
# NOTE: check where this comes from
diff --git a/test/smoke_test.py b/test/smoke_test.py
index 52d90d01b..e11673c59 100644
--- a/test/smoke_test.py
+++ b/test/smoke_test.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry
+import kornia
@pytest.mark.parametrize("batch_size", [1, 2, 5])
diff --git a/test/test_contrib.py b/test/test_contrib.py
index 9940e138e..bde0730b4 100644
--- a/test/test_contrib.py
+++ b/test/test_contrib.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
from torch.testing import assert_allclose
@@ -11,39 +11,39 @@ import utils
class TestMaxBlurPool2d:
def test_shape(self):
input = torch.rand(1, 2, 4, 6)
- pool = tgm.contrib.MaxBlurPool2d(kernel_size=3)
+ pool = kornia.contrib.MaxBlurPool2d(kernel_size=3)
assert pool(input).shape == (1, 2, 2, 3)
def test_shape_batch(self):
input = torch.rand(3, 2, 6, 10)
- pool = tgm.contrib.MaxBlurPool2d(kernel_size=5)
+ pool = kornia.contrib.MaxBlurPool2d(kernel_size=5)
assert pool(input).shape == (3, 2, 3, 5)
def test_gradcheck(self):
input = torch.rand(2, 3, 4, 4)
input = utils.tensor_to_gradcheck_var(input) # to var
- assert gradcheck(tgm.contrib.max_blur_pool2d,
+ assert gradcheck(kornia.contrib.max_blur_pool2d,
(input, 3,), raise_exception=True)
def test_jit(self):
@torch.jit.script
def op_script(input: torch.Tensor, kernel_size: int) -> torch.Tensor:
- return tgm.contrib.max_blur_pool2d(input, kernel_size)
+ return kornia.contrib.max_blur_pool2d(input, kernel_size)
img = torch.rand(2, 3, 4, 5)
actual = op_script(img, kernel_size=3)
- expected = tgm.contrib.max_blur_pool2d(img, kernel_size=3)
+ expected = kornia.contrib.max_blur_pool2d(img, kernel_size=3)
assert_allclose(actual, expected)
class TestExtractTensorPatches:
def test_smoke(self):
input = torch.arange(16.).view(1, 1, 4, 4)
- m = tgm.contrib.ExtractTensorPatches(3)
+ m = kornia.contrib.ExtractTensorPatches(3)
assert m(input).shape == (1, 4, 1, 3, 3)
def test_b1_ch1_h4w4_ws3(self):
input = torch.arange(16.).view(1, 1, 4, 4)
- m = tgm.contrib.ExtractTensorPatches(3)
+ m = kornia.contrib.ExtractTensorPatches(3)
patches = m(input)
assert patches.shape == (1, 4, 1, 3, 3)
assert utils.check_equal_torch(input[0, :, :3, :3], patches[0, 0])
@@ -54,7 +54,7 @@ class TestExtractTensorPatches:
def test_b1_ch2_h4w4_ws3(self):
input = torch.arange(16.).view(1, 1, 4, 4)
input = input.expand(-1, 2, -1, -1) # copy all channels
- m = tgm.contrib.ExtractTensorPatches(3)
+ m = kornia.contrib.ExtractTensorPatches(3)
patches = m(input)
assert patches.shape == (1, 4, 2, 3, 3)
assert utils.check_equal_torch(input[0, :, :3, :3], patches[0, 0])
@@ -64,7 +64,7 @@ class TestExtractTensorPatches:
def test_b1_ch1_h4w4_ws2(self):
input = torch.arange(16.).view(1, 1, 4, 4)
- m = tgm.contrib.ExtractTensorPatches(2)
+ m = kornia.contrib.ExtractTensorPatches(2)
patches = m(input)
assert patches.shape == (1, 9, 1, 2, 2)
assert utils.check_equal_torch(input[0, :, 0:2, 1:3], patches[0, 1])
@@ -74,7 +74,7 @@ class TestExtractTensorPatches:
def test_b1_ch1_h4w4_ws2_stride2(self):
input = torch.arange(16.).view(1, 1, 4, 4)
- m = tgm.contrib.ExtractTensorPatches(2, stride=2)
+ m = kornia.contrib.ExtractTensorPatches(2, stride=2)
patches = m(input)
assert patches.shape == (1, 4, 1, 2, 2)
assert utils.check_equal_torch(input[0, :, 0:2, 0:2], patches[0, 0])
@@ -84,7 +84,7 @@ class TestExtractTensorPatches:
def test_b1_ch1_h4w4_ws2_stride21(self):
input = torch.arange(16.).view(1, 1, 4, 4)
- m = tgm.contrib.ExtractTensorPatches(2, stride=(2, 1))
+ m = kornia.contrib.ExtractTensorPatches(2, stride=(2, 1))
patches = m(input)
assert patches.shape == (1, 6, 1, 2, 2)
assert utils.check_equal_torch(input[0, :, 0:2, 1:3], patches[0, 1])
@@ -94,7 +94,7 @@ class TestExtractTensorPatches:
def test_b1_ch1_h3w3_ws2_stride1_padding1(self):
input = torch.arange(9.).view(1, 1, 3, 3)
- m = tgm.contrib.ExtractTensorPatches(2, stride=1, padding=1)
+ m = kornia.contrib.ExtractTensorPatches(2, stride=1, padding=1)
patches = m(input)
assert patches.shape == (1, 16, 1, 2, 2)
assert utils.check_equal_torch(input[0, :, 0:2, 0:2], patches[0, 5])
@@ -106,7 +106,7 @@ class TestExtractTensorPatches:
batch_size = 2
input = torch.arange(9.).view(1, 1, 3, 3)
input = input.expand(batch_size, -1, -1, -1)
- m = tgm.contrib.ExtractTensorPatches(2, stride=1, padding=1)
+ m = kornia.contrib.ExtractTensorPatches(2, stride=1, padding=1)
patches = m(input)
assert patches.shape == (batch_size, 16, 1, 2, 2)
for i in range(batch_size):
@@ -121,7 +121,7 @@ class TestExtractTensorPatches:
def test_b1_ch1_h3w3_ws23(self):
input = torch.arange(9.).view(1, 1, 3, 3)
- m = tgm.contrib.ExtractTensorPatches((2, 3))
+ m = kornia.contrib.ExtractTensorPatches((2, 3))
patches = m(input)
assert patches.shape == (1, 2, 1, 2, 3)
assert utils.check_equal_torch(input[0, :, 0:2, 0:3], patches[0, 0])
@@ -129,7 +129,7 @@ class TestExtractTensorPatches:
def test_b1_ch1_h3w4_ws23(self):
input = torch.arange(12.).view(1, 1, 3, 4)
- m = tgm.contrib.ExtractTensorPatches((2, 3))
+ m = kornia.contrib.ExtractTensorPatches((2, 3))
patches = m(input)
assert patches.shape == (1, 4, 1, 2, 3)
assert utils.check_equal_torch(input[0, :, 0:2, 0:3], patches[0, 0])
@@ -144,21 +144,21 @@ class TestExtractTensorPatches:
def test_gradcheck(self):
input = torch.rand(2, 3, 4, 4)
input = utils.tensor_to_gradcheck_var(input) # to var
- assert gradcheck(tgm.contrib.extract_tensor_patches,
+ assert gradcheck(kornia.contrib.extract_tensor_patches,
(input, 3,), raise_exception=True)
class TestSoftArgmax2d:
def _test_smoke(self):
input = torch.zeros(1, 1, 2, 3)
- m = tgm.contrib.SpatialSoftArgmax2d()
+ m = kornia.contrib.SpatialSoftArgmax2d()
assert m(input).shape == (1, 1, 2)
def _test_top_left(self):
input = torch.zeros(1, 1, 2, 3)
input[..., 0, 0] = 10.
- coord = tgm.contrib.spatial_soft_argmax2d(input, True)
+ coord = kornia.contrib.spatial_soft_argmax2d(input, True)
assert pytest.approx(coord[..., 0].item(), -1.0)
assert pytest.approx(coord[..., 1].item(), -1.0)
@@ -166,7 +166,7 @@ class TestSoftArgmax2d:
input = torch.zeros(1, 1, 2, 3)
input[..., 0, 0] = 10.
- coord = tgm.contrib.spatial_soft_argmax2d(input, False)
+ coord = kornia.contrib.spatial_soft_argmax2d(input, False)
assert pytest.approx(coord[..., 0].item(), 0.0)
assert pytest.approx(coord[..., 1].item(), 0.0)
@@ -174,7 +174,7 @@ class TestSoftArgmax2d:
input = torch.zeros(1, 1, 2, 3)
input[..., -1, 1] = 10.
- coord = tgm.contrib.spatial_soft_argmax2d(input, True)
+ coord = kornia.contrib.spatial_soft_argmax2d(input, True)
assert pytest.approx(coord[..., 0].item(), 1.0)
assert pytest.approx(coord[..., 1].item(), 1.0)
@@ -182,7 +182,7 @@ class TestSoftArgmax2d:
input = torch.zeros(1, 1, 2, 3)
input[..., -1, 1] = 10.
- coord = tgm.contrib.spatial_soft_argmax2d(input, False)
+ coord = kornia.contrib.spatial_soft_argmax2d(input, False)
assert pytest.approx(coord[..., 0].item(), 2.0)
assert pytest.approx(coord[..., 1].item(), 1.0)
@@ -193,7 +193,7 @@ class TestSoftArgmax2d:
input[1, 0, -1, 0] = 10. # bottom-left
input[1, 1, -1, -1] = 10. # bottom-right
- coord = tgm.contrib.spatial_soft_argmax2d(input)
+ coord = kornia.contrib.spatial_soft_argmax2d(input)
assert pytest.approx(coord[0, 0, 0].item(), -1.0) # top-left
assert pytest.approx(coord[0, 0, 1].item(), -1.0)
assert pytest.approx(coord[0, 1, 0].item(), 1.0) # top-right
@@ -210,7 +210,7 @@ class TestSoftArgmax2d:
def _test_gradcheck(self):
input = torch.rand(2, 3, 3, 2)
input = utils.tensor_to_gradcheck_var(input) # to var
- assert gradcheck(tgm.contrib.spatial_soft_argmax2d,
+ assert gradcheck(kornia.contrib.spatial_soft_argmax2d,
(input), raise_exception=True)
def test_run_all(self):
diff --git a/test/test_jit_tracing.py b/test/test_jit_tracing.py
index 8b652d27c..818a0597f 100644
--- a/test/test_jit_tracing.py
+++ b/test/test_jit_tracing.py
@@ -2,7 +2,7 @@ import pytest
from common import device_type
import torch
-import torchgeometry as tgm
+import kornia as kornia
import torch.nn as nn
@@ -14,9 +14,9 @@ class WarpPerspective(nn.Module):
self.output_height, self.output_width = output_size
def forward(self, x, M):
- x = tgm.warp_perspective(x, M,
- dsize=(self.output_height,
- self.output_width))
+ x = kornia.warp_perspective(x, M,
+ dsize=(self.output_height,
+ self.output_width))
return x
@@ -28,9 +28,9 @@ class WarpAffine(nn.Module):
self.output_height, self.output_width = output_size
def forward(self, x, M):
- x = tgm.warp_affine(x, M,
- dsize=(self.output_height,
- self.output_width))
+ x = kornia.warp_affine(x, M,
+ dsize=(self.output_height,
+ self.output_width))
return x
diff --git a/test/test_losses.py b/test/test_losses.py
index 2644bf445..4b9892e80 100644
--- a/test/test_losses.py
+++ b/test/test_losses.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
from torch.autograd import gradcheck
import utils
@@ -15,7 +15,7 @@ class TestFocalLoss:
labels = torch.rand(2, 3, 2) * num_classes
labels = labels.long()
- assert tgm.losses.focal_loss(
+ assert kornia.losses.focal_loss(
logits,
labels,
alpha=0.5,
@@ -31,7 +31,7 @@ class TestFocalLoss:
labels = torch.rand(2, 3, 2) * num_classes
labels = labels.long()
- assert tgm.losses.focal_loss(
+ assert kornia.losses.focal_loss(
logits,
labels,
alpha=0.5,
@@ -44,7 +44,7 @@ class TestFocalLoss:
labels = torch.rand(2, 3, 2) * num_classes
labels = labels.long()
- assert tgm.losses.focal_loss(
+ assert kornia.losses.focal_loss(
logits,
labels,
alpha=0.5,
@@ -63,7 +63,7 @@ class TestFocalLoss:
labels = labels.long()
logits = utils.tensor_to_gradcheck_var(logits) # to var
- assert gradcheck(tgm.losses.focal_loss,
+ assert gradcheck(kornia.losses.focal_loss,
(logits, labels, alpha, gamma), raise_exception=True)
def test_run_all(self):
@@ -80,7 +80,7 @@ class TestTverskyLoss:
labels = torch.rand(2, 3, 2) * num_classes
labels = labels.long()
- criterion = tgm.losses.TverskyLoss(alpha=0.5, beta=0.5)
+ criterion = kornia.losses.TverskyLoss(alpha=0.5, beta=0.5)
loss = criterion(logits, labels)
def _test_all_zeros(self):
@@ -91,7 +91,7 @@ class TestTverskyLoss:
logits[:, 2] = 1.0
labels = torch.zeros(2, 1, 2, dtype=torch.int64)
- criterion = tgm.losses.TverskyLoss(alpha=0.5, beta=0.5)
+ criterion = kornia.losses.TverskyLoss(alpha=0.5, beta=0.5)
loss = criterion(logits, labels)
assert pytest.approx(loss.item(), 0.0)
@@ -107,7 +107,7 @@ class TestTverskyLoss:
labels = labels.long()
logits = utils.tensor_to_gradcheck_var(logits) # to var
- assert gradcheck(tgm.losses.tversky_loss,
+ assert gradcheck(kornia.losses.tversky_loss,
(logits, labels, alpha, beta), raise_exception=True)
def test_run_all(self):
@@ -123,7 +123,7 @@ class TestDiceLoss:
labels = torch.rand(2, 3, 2) * num_classes
labels = labels.long()
- criterion = tgm.losses.DiceLoss()
+ criterion = kornia.losses.DiceLoss()
loss = criterion(logits, labels)
def _test_all_zeros(self):
@@ -134,7 +134,7 @@ class TestDiceLoss:
logits[:, 2] = 1.0
labels = torch.zeros(2, 1, 2, dtype=torch.int64)
- criterion = tgm.losses.DiceLoss()
+ criterion = kornia.losses.DiceLoss()
loss = criterion(logits, labels)
assert pytest.approx(loss.item(), 0.0)
@@ -149,7 +149,7 @@ class TestDiceLoss:
labels = labels.long()
logits = utils.tensor_to_gradcheck_var(logits) # to var
- assert gradcheck(tgm.losses.dice_loss,
+ assert gradcheck(kornia.losses.dice_loss,
(logits, labels,), raise_exception=True)
def test_run_all(self):
@@ -163,7 +163,7 @@ class TestDepthSmoothnessLoss:
image = self.image.clone()
depth = self.depth.clone()
- criterion = tgm.losses.InverseDepthSmoothnessLoss()
+ criterion = kornia.losses.InverseDepthSmoothnessLoss()
loss = criterion(depth, image)
# TODO: implement me
@@ -179,7 +179,7 @@ class TestDepthSmoothnessLoss:
depth = self.depth.clone()
depth = utils.tensor_to_gradcheck_var(depth) # to var
image = utils.tensor_to_gradcheck_var(image) # to var
- assert gradcheck(tgm.losses.inverse_depth_smoothness_loss,
+ assert gradcheck(kornia.losses.inverse_depth_smoothness_loss,
(depth, image,), raise_exception=True)
@pytest.mark.parametrize("batch_shape",
@@ -202,7 +202,7 @@ def test_ssim(batch_shape, device_type, window_size, reduction_type):
img1 = torch.rand(batch_shape).to(device)
img2 = torch.rand(batch_shape).to(device)
- ssim = tgm.losses.SSIM(window_size, reduction_type)
+ ssim = kornia.losses.SSIM(window_size, reduction_type)
ssim_loss_val = ssim(img1, img2)
if reduction_type == 'none':
@@ -215,7 +215,7 @@ def test_ssim(batch_shape, device_type, window_size, reduction_type):
# functional
assert utils.check_equal_torch(
- ssim_loss_val, tgm.losses.ssim(
+ ssim_loss_val, kornia.losses.ssim(
img1, img2, window_size, reduction_type))
# evaluate function gradient
diff --git a/test/utils/test_grid.py b/test/utils/test_grid.py
index bfe62c0de..c802baea6 100644
--- a/test/utils/test_grid.py
+++ b/test/utils/test_grid.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
import utils # test utils
@@ -11,7 +11,7 @@ def test_create_meshgrid():
normalized_coordinates = False
# create the meshgrid and verify shape
- grid = tgm.utils.create_meshgrid(
+ grid = kornia.utils.create_meshgrid(
height, width, normalized_coordinates)
assert grid.shape == (1, height, width, 2)
@@ -27,18 +27,18 @@ def test_normalize_pixel_grid():
height, width = 2, 4
# create points grid
- grid_norm = tgm.utils.create_meshgrid(
+ grid_norm = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=True)
grid_norm = torch.unsqueeze(grid_norm, dim=0)
- grid_pix = tgm.utils.create_meshgrid(
+ grid_pix = kornia.utils.create_meshgrid(
height, width, normalized_coordinates=False)
grid_pix = torch.unsqueeze(grid_pix, dim=0)
# grid from pixel space to normalized
- norm_trans_pix = tgm.normal_transform_pixel(height, width) # 1x3x3
+ norm_trans_pix = kornia.normal_transform_pixel(height, width) # 1x3x3
pix_trans_norm = torch.inverse(norm_trans_pix) # 1x3x3
# transform grids
- grid_pix_to_norm = tgm.transform_points(norm_trans_pix, grid_pix)
- grid_norm_to_pix = tgm.transform_points(pix_trans_norm, grid_norm)
+ grid_pix_to_norm = kornia.transform_points(norm_trans_pix, grid_pix)
+ grid_norm_to_pix = kornia.transform_points(pix_trans_norm, grid_norm)
assert utils.check_equal_torch(grid_pix, grid_norm_to_pix)
assert utils.check_equal_torch(grid_norm, grid_pix_to_norm)
diff --git a/test/utils/test_image.py b/test/utils/test_image.py
index da735bc26..91f93ea19 100644
--- a/test/utils/test_image.py
+++ b/test/utils/test_image.py
@@ -2,7 +2,7 @@ import pytest
import numpy as np
import torch
-import torchgeometry as tgm
+import kornia as kornia
import utils # test utils
@@ -11,7 +11,7 @@ import utils # test utils
[(4, 4), (1, 4, 4), (3, 4, 4), ])
def test_tensor_to_image(batch_shape):
tensor = torch.ones(batch_shape)
- image = tgm.utils.tensor_to_image(tensor)
+ image = kornia.utils.tensor_to_image(tensor)
assert image.shape[:2] == batch_shape[-2:]
assert isinstance(image, np.ndarray)
@@ -20,6 +20,6 @@ def test_tensor_to_image(batch_shape):
[(4, 4), (4, 4, 1), (4, 4, 3), ])
def test_image_to_tensor(batch_shape):
image = np.ones(batch_shape)
- tensor = tgm.utils.image_to_tensor(image)
+ tensor = kornia.utils.image_to_tensor(image)
assert tensor.shape[-2:] == batch_shape[:2]
assert isinstance(tensor, torch.Tensor)
diff --git a/test/utils/test_metrics.py b/test/utils/test_metrics.py
index 29acf82ea..d93376ac7 100644
--- a/test/utils/test_metrics.py
+++ b/test/utils/test_metrics.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
import utils
from common import device_type
@@ -16,7 +16,7 @@ class TestMeanIoU:
predicted = torch.tensor(
[[1, 1, 1, 1, 0, 0, 0, 0]])
- mean_iou = tgm.utils.metrics.mean_iou(predicted, actual, num_classes)
+ mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)
mean_iou_real = torch.tensor(
[[1.0, 1.0]], dtype=torch.float32)
assert mean_iou.shape == (batch_size, num_classes)
@@ -30,7 +30,7 @@ class TestMeanIoU:
predicted = torch.tensor(
[[1, 1, 1, 1, 0, 0, 0, 0]]).repeat(batch_size, 1)
- mean_iou = tgm.utils.metrics.mean_iou(predicted, actual, num_classes)
+ mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)
mean_iou_real = torch.tensor(
[[1.0, 1.0]], dtype=torch.float32)
assert mean_iou.shape == (batch_size, num_classes)
@@ -44,8 +44,8 @@ class TestMeanIoU:
predicted = torch.tensor(
[[1, 1, 1, 1, 0, 0, 0, 1]])
- mean_iou = tgm.utils.metrics.mean_iou(predicted, actual, num_classes)
- mean_iou = tgm.utils.metrics.mean_iou(predicted, actual, num_classes)
+ mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)
+ mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)
mean_iou_real = torch.tensor(
[[0.75, 0.80]], dtype=torch.float32)
assert mean_iou.shape == (batch_size, num_classes)
@@ -65,7 +65,7 @@ class TestMeanIoU:
[2, 2, 3, 3],
[2, 2, 3, 3]]])
- mean_iou = tgm.utils.metrics.mean_iou(predicted, actual, num_classes)
+ mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)
mean_iou_real = torch.tensor(
[[1.0, 1.0, 1.0, 1.0]], dtype=torch.float32)
assert mean_iou.shape == (batch_size, num_classes)
@@ -85,7 +85,7 @@ class TestMeanIoU:
[2, 2, 3, 3],
[2, 2, 3, 3]]])
- mean_iou = tgm.utils.metrics.mean_iou(predicted, actual, num_classes)
+ mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)
mean_iou_real = torch.tensor(
[[0.0, 1.0, 0.5, 0.5]], dtype=torch.float32)
assert mean_iou.shape == (batch_size, num_classes)
@@ -100,7 +100,7 @@ class TestConfusionMatrix:
predicted = torch.tensor(
[[1, 1, 1, 1, 0, 0, 0, 1]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[3, 1],
@@ -115,7 +115,7 @@ class TestConfusionMatrix:
predicted = torch.tensor(
[[1, 1, 1, 1, 0, 0, 0, 1]]).repeat(batch_size, 1)
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[3, 1],
@@ -129,7 +129,7 @@ class TestConfusionMatrix:
predicted = torch.tensor(
[[2, 1, 0, 0, 0, 0, 0, 1, 0, 2, 2, 1, 0, 0, 2, 2]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[4, 1, 2],
@@ -144,7 +144,7 @@ class TestConfusionMatrix:
predicted = torch.tensor(
[[3, 2, 1, 1, 1, 1, 1, 2, 1, 3, 3, 2, 1, 1, 3, 3]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[0, 0, 0, 0],
@@ -161,7 +161,7 @@ class TestConfusionMatrix:
predicted = torch.tensor(
[[2, 1, 0, 0, 0, 0, 0, 1, 0, 2, 2, 1, 0, 0, 2, 2]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes, normalized)
conf_mat_real = torch.tensor(
@@ -183,7 +183,7 @@ class TestConfusionMatrix:
[2, 2, 3, 3],
[2, 2, 3, 3]]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[4, 0, 0, 0],
@@ -205,7 +205,7 @@ class TestConfusionMatrix:
[2, 2, 1, 3],
[2, 2, 3, 3]]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[3, 0, 0, 1],
@@ -227,7 +227,7 @@ class TestConfusionMatrix:
[2, 2, 3, 3],
[2, 2, 3, 3]]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[0, 0, 0, 4],
@@ -249,7 +249,7 @@ class TestConfusionMatrix:
[2, 2, 3, 3],
[2, 2, 3, 3]]])
- conf_mat = tgm.utils.metrics.confusion_matrix(
+ conf_mat = kornia.utils.metrics.confusion_matrix(
predicted, actual, num_classes)
conf_mat_real = torch.tensor(
[[[0, 0, 4, 4],
diff --git a/test/utils/test_one_hot.py b/test/utils/test_one_hot.py
index 52d53d009..d66abcbca 100644
--- a/test/utils/test_one_hot.py
+++ b/test/utils/test_one_hot.py
@@ -1,7 +1,7 @@
import pytest
import torch
-import torchgeometry as tgm
+import kornia as kornia
import utils # test utils
@@ -16,7 +16,7 @@ class TestOneHot:
labels[1, 1, 0] = 3
# convert labels to one hot tensor
- one_hot = tgm.utils.one_hot(labels, num_classes)
+ one_hot = kornia.utils.one_hot(labels, num_classes)
assert pytest.approx(one_hot[0, labels[0, 0, 0], 0, 0].item(), 1.0)
assert pytest.approx(one_hot[0, labels[0, 1, 0], 1, 0].item(), 1.0)
diff --git a/torchgeometry/geometry/__init__.py b/torchgeometry/geometry/__init__.py
deleted file mode 100644
index 626641512..000000000
--- a/torchgeometry/geometry/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from torchgeometry.geometry.camera import *
-from torchgeometry.geometry.conversions import *
-from torchgeometry.geometry.linalg import *
-from torchgeometry.geometry.transform import *
-from torchgeometry.geometry.warp import *
diff --git a/torchgeometry/geometry/transform/__init__.py b/torchgeometry/geometry/transform/__init__.py
deleted file mode 100644
index 51ad7bff8..000000000
--- a/torchgeometry/geometry/transform/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from torchgeometry.geometry.transform.crop import *
-from torchgeometry.geometry.transform.imgwarp import *
-from torchgeometry.geometry.transform.pyramid import *
-from torchgeometry.geometry.transform.affwarp import *
diff --git a/torchgeometry/geometry/warp/__init__.py b/torchgeometry/geometry/warp/__init__.py
deleted file mode 100644
index bca220bca..000000000
--- a/torchgeometry/geometry/warp/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from torchgeometry.geometry.warp.homography_warper import *
-from torchgeometry.geometry.warp.depth_warper import *
diff --git a/verify.py b/verify.py
index e9248ee55..a470b1564 100644
--- a/verify.py
+++ b/verify.py
@@ -16,7 +16,7 @@ def main(checks):
print("Verifying with " + str(checks))
if "lint" in checks:
print("Linter (flake8):", flush=True)
- run("flake8 torchgeometry test examples", shell=True, check=True)
+ run("flake8 kornia test examples", shell=True, check=True)
print("lint checks passed")
if "mypy" in checks: