diff --git a/.github/workflows/pr_test_cpu.yml b/.github/workflows/pr_test_cpu.yml index 97a40393d2..c9ae18d8f5 100644 --- a/.github/workflows/pr_test_cpu.yml +++ b/.github/workflows/pr_test_cpu.yml @@ -20,7 +20,7 @@ jobs: os: ['Ubuntu-latest', 'Windows-latest'] pytorch-dtype: ['float32', 'float64'] - uses: kornia/workflows/.github/workflows/tests.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tests.yml@v1.10.1 with: os: ${{ matrix.os }} python-version: '["3.8", "3.12"]' @@ -28,7 +28,7 @@ jobs: pytorch-dtype: ${{ matrix.pytorch-dtype }} tests-cpu-macos: - uses: kornia/workflows/.github/workflows/tests.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tests.yml@v1.10.1 with: os: 'MacOS-latest' python-version: '["3.8", "3.12"]' @@ -36,16 +36,16 @@ jobs: coverage: - uses: kornia/workflows/.github/workflows/coverage.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/coverage.yml@v1.10.1 typing: - uses: kornia/workflows/.github/workflows/mypy.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/mypy.yml@v1.10.1 tutorials: - uses: kornia/workflows/.github/workflows/tutorials.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tutorials.yml@v1.10.1 docs: - uses: kornia/workflows/.github/workflows/docs.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/docs.yml@v1.10.1 with: python-version: "3.11" @@ -68,7 +68,7 @@ jobs: os: ['Ubuntu-latest', 'Windows-latest'] #, 'MacOS-latest'] add it when https://github.com/pytorch/pytorch/pull/89262 be merged pytorch-dtype: ['float32', 'float64'] - uses: kornia/workflows/.github/workflows/tests.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tests.yml@v1.10.1 with: os: ${{ matrix.os }} pytorch-version: '["nightly"]' diff --git a/.github/workflows/scheduled_test_cpu.yml b/.github/workflows/scheduled_test_cpu.yml index 18d037fd92..c774f6c493 100644 --- a/.github/workflows/scheduled_test_cpu.yml +++ b/.github/workflows/scheduled_test_cpu.yml @@ -18,7 +18,7 @@ jobs: # os: ['Ubuntu-latest', 'Windows-latest', 'MacOS-latest'] pytorch-dtype: ['float32', 'float64'] - uses: kornia/workflows/.github/workflows/tests.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tests.yml@v1.10.1 with: os: 'Ubuntu-latest' python-version: '["3.8", "3.9", "3.10", "3.11", "3.12"]' @@ -34,7 +34,7 @@ jobs: matrix: pytorch-dtype: ['float32', 'float64'] - uses: kornia/workflows/.github/workflows/tests.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tests.yml@v1.10.1 with: os: 'Windows-latest' python-version: '["3.12"]' @@ -47,21 +47,21 @@ jobs: matrix: pytorch-dtype: ['float32', 'float64'] - uses: kornia/workflows/.github/workflows/tests.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tests.yml@v1.10.1 with: os: 'MacOS-latest' pytorch-dtype: ${{ matrix.pytorch-dtype }} coverage: - uses: kornia/workflows/.github/workflows/coverage.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/coverage.yml@v1.10.1 typing: - uses: kornia/workflows/.github/workflows/mypy.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/mypy.yml@v1.10.1 tutorials: - uses: kornia/workflows/.github/workflows/tutorials.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/tutorials.yml@v1.10.1 docs: - uses: kornia/workflows/.github/workflows/docs.yml@v1.10.0 + uses: kornia/workflows/.github/workflows/docs.yml@v1.10.1 with: python-version: "3.11" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 855f1acb0f..ca5899fdee 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal +level of experience, education, socioeconomic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards diff --git a/README.md b/README.md index fbda2261ca..fb790b4026 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- +

--- @@ -8,90 +8,57 @@ English | [简体中文](README_zh-CN.md) -WebsiteDocs • -Try it Now • +Try it NowTutorialsExamplesBlogCommunity -[![PyPI python](https://img.shields.io/pypi/pyversions/kornia)](https://pypi.org/project/kornia) -[![pytorch](https://img.shields.io/badge/PyTorch_1.9.1+-ee4c2c?logo=pytorch&logoColor=white)](https://pytorch.org/get-started/locally/) -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENCE) - [![PyPI version](https://badge.fury.io/py/kornia.svg)](https://pypi.org/project/kornia) [![Downloads](https://static.pepy.tech/badge/kornia)](https://pepy.tech/project/kornia) [![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack&logoColor=white)](https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-2AQRi~X9Uu6PLMuUZdvfjA) [![Twitter](https://img.shields.io/twitter/follow/kornia_foss?style=social)](https://twitter.com/kornia_foss) - -[![tests-cpu](https://github.com/kornia/kornia/actions/workflows/scheduled_test_cpu.yml/badge.svg?event=schedule&&branch=main)](https://github.com/kornia/kornia/actions/workflows/scheduled_test_cpu.yml) -[![codecov](https://codecov.io/gh/kornia/kornia/branch/main/graph/badge.svg?token=FzCb7e0Bso)](https://codecov.io/gh/kornia/kornia) -[![Documentation Status](https://readthedocs.org/projects/kornia/badge/?version=latest)](https://kornia.readthedocs.io/en/latest/?badge=latest) -[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/kornia/kornia/main.svg)](https://results.pre-commit.ci/latest/github/kornia/kornia/main) - -Kornia - Computer vision library for deep learning | Product Hunt +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENCE)

-*Kornia* is a differentiable computer vision library for [PyTorch](https://pytorch.org). +**Kornia** is a differentiable computer vision library for [PyTorch](https://pytorch.org). It consists of a set of routines and differentiable modules to solve generic computer vision problems. At its core, the package uses *PyTorch* as its main backend both for efficiency and to take advantage of the reverse-mode auto-differentiation to define and compute the gradient of complex functions. -
- -
- - +Inspired by existing packages, this library is composed by a subset of packages containing operators that can be inserted within neural networks to train models to perform image transformations, epipolar geometry, depth estimation, and low-level image processing such as filtering and edge detection that operate directly on tensors. -## Overview +## Sponsorship -Inspired by existing packages, this library is composed by a subset of packages containing operators that can be inserted within neural networks to train models to perform image transformations, epipolar geometry, depth estimation, and low-level image processing such as filtering and edge detection that operate directly on tensors. +Kornia is an open-source project that is developed and maintained by volunteers. Whether you're using it for research or commercial purposes, consider sponsoring or collaborating with us. Your support will help ensure Kornia's growth and ongoing innovation. Reach out to us today and be a part of shaping the future of this exciting initiative! -At a granular level, Kornia is a library that consists of the following components: - -| **Component** | **Description** | -|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| -| [kornia](https://kornia.readthedocs.io/en/latest/index.html) | a Differentiable Computer Vision library, with strong GPU support | -| [kornia.augmentation](https://kornia.readthedocs.io/en/latest/augmentation.html) | a module to perform data augmentation in the GPU | -| [kornia.color](https://kornia.readthedocs.io/en/latest/color.html) | a set of routines to perform color space conversions | -| [kornia.contrib](https://kornia.readthedocs.io/en/latest/contrib.html) | a compilation of user contrib and experimental operators | -| [kornia.enhance](https://kornia.readthedocs.io/en/latest/enhance.html) | a module to perform normalization and intensity transformation | -| [kornia.feature](https://kornia.readthedocs.io/en/latest/feature.html) | a module to perform feature detection | -| [kornia.filters](https://kornia.readthedocs.io/en/latest/filters.html) | a module to perform image filtering and edge detection | -| [kornia.geometry](https://kornia.readthedocs.io/en/latest/geometry.html) | a geometric computer vision library to perform image transformations, 3D linear algebra and conversions using different camera models | -| [kornia.losses](https://kornia.readthedocs.io/en/latest/losses.html) | a stack of loss functions to solve different vision tasks | -| [kornia.morphology](https://kornia.readthedocs.io/en/latest/morphology.html) | a module to perform morphological operations | -| [kornia.utils](https://kornia.readthedocs.io/en/latest/utils.html) | image to tensor utilities and metrics for vision problems | + + + ## Installation -### From pip: +[![PyPI python](https://img.shields.io/pypi/pyversions/kornia)](https://pypi.org/project/kornia) +[![pytorch](https://img.shields.io/badge/PyTorch_1.9.1+-ee4c2c?logo=pytorch&logoColor=white)](https://pytorch.org/get-started/locally/) + +### From pip ```bash pip install kornia - pip install kornia[x] # to get the training API ! ```
Other installation options - #### From source: - - ```bash - python setup.py install - ``` - - #### From source with symbolic links: +#### From source with editable mode ```bash pip install -e . ``` - #### From source using pip: +#### From Github url (latest version) ```bash pip install git+https://github.com/kornia/kornia @@ -99,21 +66,6 @@ At a granular level, Kornia is a library that consists of the following componen
- -## Examples - -Run our Jupyter notebooks [tutorials](https://kornia.github.io/tutorials) to learn to use the library. - -
- - - -
- -:triangular_flag_on_post: **Updates** -- :white_check_mark: [Image Matching](https://kornia.readthedocs.io/en/latest/applications/image_matching.html) Integrated to [Huggingface Spaces](https://huggingface.co/spaces). See [Gradio Web Demo](https://huggingface.co/spaces/akhaliq/Kornia-LoFTR). -- :white_check_mark: [Face Detection](https://kornia.readthedocs.io/en/latest/applications/face_detection.html) Integrated to [Huggingface Spaces](https://huggingface.co/spaces). See [Gradio Web Demo](https://huggingface.co/spaces/frapochetti/blurry-faces). - ## Cite If you are using kornia in your research-related documents, it is recommended that you cite the paper. See more in [CITATION](./CITATION.md). @@ -129,17 +81,21 @@ If you are using kornia in your research-related documents, it is recommended th ``` ## 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 reading the [CONTRIBUTING](./CONTRIBUTING.md) notes. The participation in this open source project is subject to [Code of Conduct](./CODE_OF_CONDUCT.md). +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 reading the [CONTRIBUTING](./CONTRIBUTING.md) notes. The participation in this open source project is subject to [Code of Conduct](./CODE_OF_CONDUCT.md). ## Community + - **Forums:** discuss implementations, research, etc. [GitHub Forums](https://github.com/kornia/kornia/discussions) - **GitHub Issues:** bug reports, feature requests, install issues, RFCs, thoughts, etc. [OPEN](https://github.com/kornia/kornia/issues/new/choose) - **Slack:** Join our workspace to keep in touch with our core contributors and be part of our community. [JOIN HERE](https://join.slack.com/t/kornia/shared_invite/zt-csobk21g-2AQRi~X9Uu6PLMuUZdvfjA) -- For general information, please visit our website at www.kornia.org - + Made with [contrib.rocks](https://contrib.rocks). + +## License + +Kornia is released under the Apache 2.0 license. See the [LICENSE](./LICENSE) file for more information. diff --git a/docs/source/models/segment_anything.rst b/docs/source/models/segment_anything.rst index c2a2e6784d..ce5e6f6bec 100644 --- a/docs/source/models/segment_anything.rst +++ b/docs/source/models/segment_anything.rst @@ -263,7 +263,7 @@ This is a simple example, of how to directly use the SAM model loaded. We recomm image = image[None, ...] # Resize the image to have the maximum size 1024 on its largest side - inpt = resize(image, 1024, side='long') + data = resize(image, 1024, side='long') # Embed prompts -- ATTENTION: should match the coordinates after the resize of the image sparse_embeddings, dense_embeddings = sam_model.prompt_encoder(points=None, boxes=None, masks=None) @@ -273,16 +273,16 @@ This is a simple example, of how to directly use the SAM model loaded. We recomm pixel_std = torch.tensor(...) # Preprocess input - inpt = normalize(inpt, pixel_mean, pixel_std) + data = normalize(data, pixel_mean, pixel_std) padh = model_sam.image_encoder.img_size - h padw = model_sam.image_encoder.img_size - w - inpt = pad(inpt, (0, padw, 0, padh)) + data = pad(data, (0, padw, 0, padh)) #-------------------------------------------------------------------- # Option A: Manually calling each API #-------------------------------------------------------------------- low_res_logits, iou_predictions = sam_model.mask_decoder( - image_embeddings=sam_model.image_encoder(inpt), + image_embeddings=sam_model.image_encoder(data), image_pe=sam_model.prompt_encoder.get_dense_pe(), sparse_prompt_embeddings=sparse_embeddings, dense_prompt_embeddings=dense_embeddings, @@ -294,13 +294,13 @@ This is a simple example, of how to directly use the SAM model loaded. We recomm #-------------------------------------------------------------------- # Option B: Calling the model itself #-------------------------------------------------------------------- - prediction = sam_model(inpt[None, ...], [{}], multimask_output=True) + prediction = sam_model(data[None, ...], [{}], multimask_output=True) #-------------------------------------------------------------------- # Post processing #-------------------------------------------------------------------- # Upscale the masks to the original image resolution - input_size = (inpt.shape[-2], inpt.shape[-1]) + input_size = (data.shape[-2], data.shape[-1]) original_size = (image.shape[-2], image.shape[-1]) image_size_encoder = (model_sam.image_encoder.img_size, model_sam.image_encoder.img_size) prediction.original_res_logits(input_size, original_size, image_size_encoder) diff --git a/kornia/__init__.py b/kornia/__init__.py index 94a6769e93..84f22f2051 100644 --- a/kornia/__init__.py +++ b/kornia/__init__.py @@ -5,11 +5,32 @@ from . import grad_estimator # import the other modules for convenience -from . import augmentation, color, contrib, core, enhance, feature, io, losses, metrics, morphology, tracking, utils, x +from . import ( + augmentation, + color, + contrib, + core, + enhance, + feature, + io, + losses, + metrics, + morphology, + tracking, + utils, + x, +) # NOTE: we are going to expose to top level very few things from kornia.constants import pi -from kornia.utils import eye_like, vec_like, create_meshgrid, image_to_tensor, tensor_to_image, xla_is_available +from kornia.utils import ( + eye_like, + vec_like, + create_meshgrid, + image_to_tensor, + tensor_to_image, + xla_is_available, +) # Version variable -__version__ = "0.7.3-dev" +__version__ = "0.7.4-dev" diff --git a/kornia/filters/bilateral.py b/kornia/filters/bilateral.py index ef9a7af91c..d793e3a926 100644 --- a/kornia/filters/bilateral.py +++ b/kornia/filters/bilateral.py @@ -54,7 +54,7 @@ def _bilateral_blur( elif color_distance_type == "l2": color_distance_sq = diff.square().sum(1, keepdim=True) else: - raise ValueError("color_distance_type only acceps l1 or l2") + raise ValueError("color_distance_type only accepts l1 or l2") color_kernel = (-0.5 / sigma_color**2 * color_distance_sq).exp() # (B, 1, H, W, Ky x Kx) space_kernel = get_gaussian_kernel2d(kernel_size, sigma_space, device=input.device, dtype=input.dtype) diff --git a/kornia/geometry/epipolar/triangulation.py b/kornia/geometry/epipolar/triangulation.py index 5ae0eec0ef..e1f73b6b18 100644 --- a/kornia/geometry/epipolar/triangulation.py +++ b/kornia/geometry/epipolar/triangulation.py @@ -1,4 +1,4 @@ -"""Module with the functionalites for triangulation.""" +"""Module with the functionalities for triangulation.""" import torch diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 9f3928ab95..c016eea93b 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -1,6 +1,6 @@ coverage mypy -numpy +numpy<2 onnx pre-commit>=2 pytest==8.2.2 diff --git a/testing/geometry/create.py b/testing/geometry/create.py index 3de1d89560..a34012fc77 100644 --- a/testing/geometry/create.py +++ b/testing/geometry/create.py @@ -7,10 +7,10 @@ from kornia.utils.misc import eye_like -def create_random_homography(inpt: Tensor, eye_size: int, std_val: float = 1e-3) -> Tensor: +def create_random_homography(data: Tensor, eye_size: int, std_val: float = 1e-3) -> Tensor: """Create a batch of random homographies of shape Bx3x3.""" - std = zeros(inpt.shape[0], eye_size, eye_size, device=inpt.device, dtype=inpt.dtype) - eye = eye_like(eye_size, inpt) + std = zeros(data.shape[0], eye_size, eye_size, device=data.device, dtype=data.dtype) + eye = eye_like(eye_size, data) return eye + std.uniform_(-std_val, std_val) diff --git a/tests/contrib/models/test_sam.py b/tests/contrib/models/test_sam.py index b88c4b0984..8b77c79a8c 100644 --- a/tests/contrib/models/test_sam.py +++ b/tests/contrib/models/test_sam.py @@ -22,11 +22,11 @@ def test_smoke(self, device, model_type): assert isinstance(model, Sam) img_size = model.image_encoder.img_size - inpt = torch.randn(1, 3, img_size, img_size, device=device) + data = torch.randn(1, 3, img_size, img_size, device=device) keypoints = torch.randint(0, img_size, (1, 2, 2), device=device, dtype=torch.float) labels = torch.randint(0, 1, (1, 2), device=device, dtype=torch.float) - model(inpt, [{"points": (keypoints, labels)}], False) + model(data, [{"points": (keypoints, labels)}], False) @pytest.mark.slow @pytest.mark.parametrize("batch_size", [1, 3]) @@ -35,30 +35,30 @@ def test_smoke(self, device, model_type): def test_cardinality(self, device, batch_size, N, multimask_output): # SAM: don't supports float64 dtype = torch.float32 - inpt = torch.rand(1, 3, 77, 128, device=device, dtype=dtype) + data = torch.rand(1, 3, 77, 128, device=device, dtype=dtype) model = Sam.from_config(SamConfig("vit_b")) model = model.to(device=device, dtype=dtype) - inpt = _pad_rb(inpt, model.image_encoder.img_size) - keypoints = torch.randint(0, min(inpt.shape[-2:]), (batch_size, N, 2), device=device).to(dtype=dtype) + data = _pad_rb(data, model.image_encoder.img_size) + keypoints = torch.randint(0, min(data.shape[-2:]), (batch_size, N, 2), device=device).to(dtype=dtype) labels = torch.randint(0, 1, (batch_size, N), device=device).to(dtype=dtype) - out = model(inpt, [{"points": (keypoints, labels)}], multimask_output) + out = model(data, [{"points": (keypoints, labels)}], multimask_output) C = 3 if multimask_output else 1 - assert len(out) == inpt.size(0) + assert len(out) == data.size(0) assert out[0].logits.shape == (batch_size, C, 256, 256) def test_exception(self): model = Sam.from_config(SamConfig("mobile_sam")) with pytest.raises(TypeError) as errinfo: - inpt = torch.rand(3, 1, 2) - model(inpt, [], False) + data = torch.rand(3, 1, 2) + model(data, [], False) assert "shape must be [['B', '3', 'H', 'W']]. Got torch.Size([3, 1, 2])" in str(errinfo) with pytest.raises(Exception) as errinfo: - inpt = torch.rand(2, 3, 1, 2) - model(inpt, [{}], False) + data = torch.rand(2, 3, 1, 2) + model(data, [{}], False) assert "The number of images (`B`) should match with the length of prompts!" in str(errinfo) @pytest.mark.slow diff --git a/tests/contrib/models/test_tiny_vit.py b/tests/contrib/models/test_tiny_vit.py index a720c9a577..c9866613a5 100644 --- a/tests/contrib/models/test_tiny_vit.py +++ b/tests/contrib/models/test_tiny_vit.py @@ -13,9 +13,9 @@ class TestTinyViT(BaseTester): @pytest.mark.parametrize("img_size", [224, 256]) def test_smoke(self, device, dtype, img_size): model = TinyViT(img_size=img_size).to(device=device, dtype=dtype) - inpt = torch.randn(1, 3, img_size, img_size, device=device, dtype=dtype) + data = torch.randn(1, 3, img_size, img_size, device=device, dtype=dtype) - out = model(inpt) + out = model(data) assert isinstance(out, Tensor) @pytest.mark.slow @@ -23,9 +23,9 @@ def test_smoke(self, device, dtype, img_size): @pytest.mark.parametrize("batch_size", [1, 3]) def test_cardinality(self, device, dtype, batch_size, num_classes): model = TinyViT(num_classes=num_classes).to(device=device, dtype=dtype) - inpt = torch.rand(batch_size, 3, model.img_size, model.img_size, device=device, dtype=dtype) + data = torch.rand(batch_size, 3, model.img_size, model.img_size, device=device, dtype=dtype) - out = model(inpt) + out = model(data) assert out.shape == (batch_size, num_classes) @pytest.mark.skip("not implemented") @@ -64,7 +64,7 @@ def test_mobile_sam_backbone(self, device, dtype): img_size = 1024 batch_size = 1 model = TinyViT.from_config("5m", img_size=img_size, mobile_sam=True).to(device=device, dtype=dtype) - inpt = torch.randn(batch_size, 3, img_size, img_size, device=device, dtype=dtype) + data = torch.randn(batch_size, 3, img_size, img_size, device=device, dtype=dtype) - out = model(inpt) + out = model(data) assert out.shape == (batch_size, 256, img_size // 16, img_size // 16) diff --git a/tests/contrib/test_kmeans.py b/tests/contrib/test_kmeans.py index a9aa44d361..f3e2e6d35f 100644 --- a/tests/contrib/test_kmeans.py +++ b/tests/contrib/test_kmeans.py @@ -94,20 +94,20 @@ def test_module(self, device, dtype): kmeans.fit(x) centers = kmeans.cluster_centers - prediciton = kmeans.predict(torch.tensor([[-14, 16], [45, 12]], dtype=dtype, device=device)).tolist() + prediction = kmeans.predict(torch.tensor([[-14, 16], [45, 12]], dtype=dtype, device=device)).tolist() expected_centers = torch.tensor([[-13, 17], [15, -12], [35, 15]], dtype=dtype, device=device) - expected_prediciton = [0, 2] + expected_prediction = [0, 2] # sorting centers using dimension 0 as key so that they can be checked for equalness order = torch.argsort(centers[:, 0]).tolist() new_classes = {old_class: new_class for new_class, old_class in enumerate(order)} ordered_centers = centers[order] - oredered_prediciton = [new_classes[predicted_class] for predicted_class in prediciton] + oredered_prediction = [new_classes[predicted_class] for predicted_class in prediction] self.assert_close(ordered_centers, expected_centers, atol=2, rtol=0.1) - assert oredered_prediciton == expected_prediciton + assert oredered_prediction == expected_prediction def test_dynamo(self, device, dtype, torch_optimizer): x = TestKMeans._create_data(device, dtype) @@ -118,7 +118,7 @@ def test_dynamo(self, device, dtype, torch_optimizer): kmeans.fit(x) centers = kmeans.cluster_centers - prediciton = kmeans.predict(predict_param) + prediction = kmeans.predict(predict_param) kmeans_op = kornia.contrib.KMeans(*kmeans_params) kmeans_op.fit = torch_optimizer(kmeans_op.fit) @@ -127,7 +127,7 @@ def test_dynamo(self, device, dtype, torch_optimizer): kmeans_op.fit(x) centers_op = kmeans_op.cluster_centers - prediciton_op = kmeans_op.predict(predict_param) + prediction_op = kmeans_op.predict(predict_param) self.assert_close(centers, centers_op) - self.assert_close(prediciton, prediciton_op) + self.assert_close(prediction, prediction_op) diff --git a/tests/contrib/test_prompter.py b/tests/contrib/test_prompter.py index 6c3806e3a4..325a20dbd5 100644 --- a/tests/contrib/test_prompter.py +++ b/tests/contrib/test_prompter.py @@ -11,10 +11,10 @@ class TestVisualPrompter(BaseTester): @pytest.mark.slow def test_smoke(self, device, dtype): - inpt = torch.rand(3, 77, 128, device=device, dtype=dtype) + data = torch.rand(3, 77, 128, device=device, dtype=dtype) prompter = VisualPrompter(SamConfig("vit_b"), device, dtype) - prompter.set_image(inpt) + prompter.set_image(data) assert prompter.is_image_set prompter.reset_image() @@ -27,13 +27,13 @@ def test_smoke(self, device, dtype): def test_cardinality(self, device, batch_size, N, multimask_output): # SAM: don't supports float64 dtype = torch.float32 - inpt = torch.rand(3, 77, 128, device=device, dtype=dtype) + data = torch.rand(3, 77, 128, device=device, dtype=dtype) prompter = VisualPrompter(SamConfig("vit_b"), device, dtype) - keypoints = torch.randint(0, min(inpt.shape[-2:]), (batch_size, N, 2), device=device).to(dtype=dtype) + keypoints = torch.randint(0, min(data.shape[-2:]), (batch_size, N, 2), device=device).to(dtype=dtype) labels = torch.randint(0, 1, (batch_size, N), device=device).to(dtype=dtype) - prompter.set_image(inpt) + prompter.set_image(data) out = prompter.predict(keypoints, labels, multimask_output=multimask_output) @@ -44,11 +44,11 @@ def test_cardinality(self, device, batch_size, N, multimask_output): def test_exception(self): prompter = VisualPrompter(SamConfig("vit_b")) - inpt = torch.rand(1, 3, 1, 2) + data = torch.rand(1, 3, 1, 2) # Wrong shape for the image with pytest.raises(TypeError) as errinfo: - prompter.set_image(inpt, [], False) + prompter.set_image(data, [], False) assert "shape must be [['3', 'H', 'W']]. Got torch.Size([1, 3, 1, 2])" in str(errinfo) # predict without set an image @@ -58,21 +58,21 @@ def test_exception(self): # Valid masks with pytest.raises(TypeError) as errinfo: - prompter._valid_masks(inpt) + prompter._valid_masks(data) assert "shape must be [['K', '1', '256', '256']]. Got torch.Size([1, 3, 1, 2])" in str(errinfo) # Valid boxes with pytest.raises(TypeError) as errinfo: - prompter._valid_boxes(inpt) + prompter._valid_boxes(data) assert "shape must be [['K', '4']]. Got torch.Size([1, 3, 1, 2])" in str(errinfo) # Valid keypoints with pytest.raises(TypeError) as errinfo: - prompter._valid_keypoints(inpt, None) + prompter._valid_keypoints(data, None) assert "shape must be [['K', 'N', '2']]. Got torch.Size([1, 3, 1, 2])" in str(errinfo) with pytest.raises(TypeError) as errinfo: - prompter._valid_keypoints(torch.rand(1, 1, 2), inpt) + prompter._valid_keypoints(torch.rand(1, 1, 2), data) assert "shape must be [['K', 'N']]. Got torch.Size([1, 3, 1, 2])" in str(errinfo) with pytest.raises(Exception) as errinfo: @@ -90,18 +90,18 @@ def test_dynamo(self, device, torch_optimizer): dtype = torch.float32 batch_size = 1 N = 2 - inpt = torch.rand(3, 77, 128, device=device, dtype=dtype) - keypoints = torch.randint(0, min(inpt.shape[-2:]), (batch_size, N, 2), device=device, dtype=dtype) + data = torch.rand(3, 77, 128, device=device, dtype=dtype) + keypoints = torch.randint(0, min(data.shape[-2:]), (batch_size, N, 2), device=device, dtype=dtype) labels = torch.randint(0, 1, (batch_size, N), device=device, dtype=dtype) prompter = VisualPrompter(SamConfig("vit_b"), device, dtype) - prompter.set_image(inpt) + prompter.set_image(data) expected = prompter.predict(keypoints=keypoints, keypoints_labels=labels) prompter.reset_image() prompter.compile() - prompter.set_image(inpt) + prompter.set_image(data) actual = prompter.predict(keypoints=keypoints, keypoints_labels=labels) # TODO (joao): explore the reason for the discrepancy between cuda/cpu diff --git a/tests/enhance/test_equalization.py b/tests/enhance/test_equalization.py index 69d7996b56..e270d4b398 100644 --- a/tests/enhance/test_equalization.py +++ b/tests/enhance/test_equalization.py @@ -75,8 +75,8 @@ def test_gradcheck(self, device): bs, channels, height, width = 1, 1, 11, 11 inputs = torch.rand(bs, channels, height, width, device=device, dtype=torch.float64) - def grad_rot(inpt, a, b, c): - rot = rotate(inpt, torch.tensor(30.0, dtype=inpt.dtype, device=device)) + def grad_rot(data, a, b, c): + rot = rotate(data, torch.tensor(30.0, dtype=data.dtype, device=device)) return enhance.equalize_clahe(rot, a, b, c) self.gradcheck(grad_rot, (inputs, 40.0, (2, 2), True), nondet_tol=1e-4) diff --git a/tests/filters/test_bilateral.py b/tests/filters/test_bilateral.py index e644bddb5a..22c8bd5cb4 100644 --- a/tests/filters/test_bilateral.py +++ b/tests/filters/test_bilateral.py @@ -43,7 +43,7 @@ def test_exception(self): with pytest.raises(ValueError) as errinfo: bilateral_blur(torch.rand(1, 1, 5, 5), 3, 0.1, (1, 1), color_distance_type="l3") - assert "color_distance_type only acceps l1 or l2" in str(errinfo) + assert "color_distance_type only accepts l1 or l2" in str(errinfo) def test_noncontiguous(self, device, dtype): batch_size = 3 @@ -78,18 +78,18 @@ def test_module(self, shape, kernel_size, sigma_color, sigma_space, color_distan @pytest.mark.parametrize("kernel_size", [5, (5, 7)]) @pytest.mark.parametrize("color_distance_type", ["l1", "l2"]) def test_dynamo(self, kernel_size, color_distance_type, device, dtype, torch_optimizer): - inpt = torch.ones(2, 3, 8, 8, device=device, dtype=dtype) + data = torch.ones(2, 3, 8, 8, device=device, dtype=dtype) op = BilateralBlur(kernel_size, 1, (1, 1), color_distance_type=color_distance_type) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) sigma_color = torch.rand(1, device=device, dtype=dtype) sigma_space = torch.rand(1, 2, device=device, dtype=dtype) op = BilateralBlur(kernel_size, sigma_color, sigma_space, color_distance_type=color_distance_type) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) def test_opencv_grayscale(self, device, dtype): img = [[95, 130, 108, 228], [98, 142, 187, 166], [114, 166, 190, 141], [150, 83, 174, 216]] @@ -206,7 +206,7 @@ def test_exception(self): with pytest.raises(ValueError) as errinfo: joint_bilateral_blur(inp, guide, 3, 0.1, (1, 1), color_distance_type="l3") - assert "color_distance_type only acceps l1 or l2" in str(errinfo) + assert "color_distance_type only accepts l1 or l2" in str(errinfo) def test_noncontiguous(self, device, dtype): batch_size = 3 @@ -237,19 +237,19 @@ def test_module(self, device, dtype): @pytest.mark.parametrize("kernel_size", [5, (5, 7)]) @pytest.mark.parametrize("color_distance_type", ["l1", "l2"]) def test_dynamo(self, kernel_size, color_distance_type, device, dtype, torch_optimizer): - inpt = torch.rand(2, 3, 8, 8, device=device, dtype=dtype) + data = torch.rand(2, 3, 8, 8, device=device, dtype=dtype) guide = torch.rand(2, 3, 8, 8, device=device, dtype=dtype) op = JointBilateralBlur(kernel_size, 1, (1, 1), color_distance_type=color_distance_type) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt, guide), op_optimized(inpt, guide)) + self.assert_close(op(data, guide), op_optimized(data, guide)) sigma_color = torch.rand(1, device=device, dtype=dtype) sigma_space = torch.rand(1, 2, device=device, dtype=dtype) op = JointBilateralBlur(kernel_size, sigma_color, sigma_space, color_distance_type=color_distance_type) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt, guide), op_optimized(inpt, guide)) + self.assert_close(op(data, guide), op_optimized(data, guide)) def test_opencv_grayscale(self, device, dtype): img = [[95, 130, 108, 228], [98, 142, 187, 166], [114, 166, 190, 141], [150, 83, 174, 216]] diff --git a/tests/filters/test_blur.py b/tests/filters/test_blur.py index 755a308519..e5f0043b49 100644 --- a/tests/filters/test_blur.py +++ b/tests/filters/test_blur.py @@ -9,25 +9,25 @@ class TestBoxBlur(BaseTester): @pytest.mark.parametrize("kernel_size", [5, (3, 5)]) def test_smoke(self, kernel_size, device, dtype): - inpt = torch.rand(1, 1, 10, 10, device=device, dtype=dtype) + data = torch.rand(1, 1, 10, 10, device=device, dtype=dtype) bb = BoxBlur(kernel_size, "reflect") - actual = bb(inpt) + actual = bb(data) assert actual.shape == (1, 1, 10, 10) @pytest.mark.parametrize("kernel_size", [5, (3, 5)]) @pytest.mark.parametrize("batch_size", [1, 2]) def test_separable(self, batch_size, kernel_size, device, dtype): - inpt = torch.randn(batch_size, 3, 10, 10, device=device, dtype=dtype) - out1 = box_blur(inpt, kernel_size, separable=False) - out2 = box_blur(inpt, kernel_size, separable=True) + data = torch.randn(batch_size, 3, 10, 10, device=device, dtype=dtype) + out1 = box_blur(data, kernel_size, separable=False) + out2 = box_blur(data, kernel_size, separable=True) self.assert_close(out1, out2) def test_exception(self): - inpt = torch.rand(1, 1, 3, 3) + data = torch.rand(1, 1, 3, 3) with pytest.raises(Exception) as errinfo: - box_blur(inpt, (1,)) + box_blur(data, (1,)) assert "2D Kernel size should have a length of 2." in str(errinfo) @pytest.mark.parametrize("kernel_size", [(3, 3), 5, (5, 7)]) @@ -132,8 +132,8 @@ def test_module(self, kernel_size, batch_size, device, dtype): @pytest.mark.parametrize("kernel_size", [5, (5, 7)]) @pytest.mark.parametrize("batch_size", [1, 2]) def test_dynamo(self, batch_size, kernel_size, separable, device, dtype, torch_optimizer): - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = BoxBlur(kernel_size, separable=separable) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_blur_pool.py b/tests/filters/test_blur_pool.py index 6eb6cd5d70..608fb7eccd 100644 --- a/tests/filters/test_blur_pool.py +++ b/tests/filters/test_blur_pool.py @@ -17,8 +17,8 @@ class TestMaxBlurPool(BaseTester): @pytest.mark.parametrize("kernel_size", [3, (5, 5)]) @pytest.mark.parametrize("ceil_mode", [True, False]) def test_smoke(self, kernel_size, ceil_mode, device, dtype): - inpt = torch.rand(1, 1, 10, 10, device=device, dtype=dtype) - actual = MaxBlurPool2D(kernel_size, ceil_mode=ceil_mode)(inpt) + data = torch.rand(1, 1, 10, 10, device=device, dtype=dtype) + actual = MaxBlurPool2D(kernel_size, ceil_mode=ceil_mode)(data) assert actual.shape == (1, 1, 5, 5) @@ -26,14 +26,14 @@ def test_smoke(self, kernel_size, ceil_mode, device, dtype): @pytest.mark.parametrize("kernel_size", [3, (5, 5)]) @pytest.mark.parametrize("batch_size", [1, 2]) def test_cardinality(self, batch_size, kernel_size, ceil_mode, device, dtype): - inpt = torch.zeros(batch_size, 4, 4, 8, device=device, dtype=dtype) + data = torch.zeros(batch_size, 4, 4, 8, device=device, dtype=dtype) blur = MaxBlurPool2D(kernel_size, ceil_mode=ceil_mode) - assert blur(inpt).shape == (batch_size, 4, 2, 4) + assert blur(data).shape == (batch_size, 4, 2, 4) def test_exception(self): - inpt = torch.rand(1, 1, 3, 3) + data = torch.rand(1, 1, 3, 3) with pytest.raises(Exception) as errinfo: - MaxBlurPool2D((3, 5))(inpt) + MaxBlurPool2D((3, 5))(data) assert "Invalid kernel shape. Expect CxC_outxNxN" in str(errinfo) @pytest.mark.parametrize("batch_size", [1, 2]) @@ -64,19 +64,19 @@ def test_module(self, kernel_size, batch_size, device, dtype): @pytest.mark.parametrize("batch_size", [1, 2]) @pytest.mark.parametrize("ceil_mode", [True, False]) def test_dynamo(self, batch_size, kernel_size, ceil_mode, device, dtype, torch_optimizer): - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = MaxBlurPool2D(kernel_size, ceil_mode=ceil_mode) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) class TestBlurPool(BaseTester): @pytest.mark.parametrize("kernel_size", [3, (5, 5)]) @pytest.mark.parametrize("stride", [1, 2]) def test_smoke(self, kernel_size, stride, device, dtype): - inpt = torch.rand(1, 1, 10, 10, device=device, dtype=dtype) - actual = BlurPool2D(kernel_size, stride=stride)(inpt) + data = torch.rand(1, 1, 10, 10, device=device, dtype=dtype) + actual = BlurPool2D(kernel_size, stride=stride)(data) expected = (1, 1, int(10 / stride), int(10 / stride)) assert actual.shape == expected @@ -84,15 +84,15 @@ def test_smoke(self, kernel_size, stride, device, dtype): @pytest.mark.parametrize("batch_size", [1, 2]) @pytest.mark.parametrize("stride", [1, 2]) def test_cardinality(self, batch_size, kernel_size, stride, device, dtype): - inpt = torch.zeros(batch_size, 4, 4, 8, device=device, dtype=dtype) - actual = BlurPool2D(kernel_size, stride=stride)(inpt) + data = torch.zeros(batch_size, 4, 4, 8, device=device, dtype=dtype) + actual = BlurPool2D(kernel_size, stride=stride)(data) expected = (batch_size, 4, int(4 / stride), int(8 / stride)) assert actual.shape == expected def test_exception(self): - inpt = torch.rand(1, 1, 3, 3) + data = torch.rand(1, 1, 3, 3) with pytest.raises(Exception) as errinfo: - BlurPool2D((3, 5))(inpt) + BlurPool2D((3, 5))(data) assert "Invalid kernel shape. Expect CxC_(out, None)xNxN" in str(errinfo) @pytest.mark.parametrize("batch_size", [1, 2]) @@ -123,11 +123,11 @@ def test_module(self, batch_size, kernel_size, stride, device, dtype): @pytest.mark.parametrize("batch_size", [1, 2]) @pytest.mark.parametrize("stride", [1, 2]) def test_dynamo(self, batch_size, kernel_size, stride, device, dtype, torch_optimizer): - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = BlurPool2D(kernel_size, stride=stride) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) class TestEdgeAwareBlurPool(BaseTester): @@ -136,9 +136,9 @@ class TestEdgeAwareBlurPool(BaseTester): @pytest.mark.parametrize("edge_threshold", [1.25, 2.5]) @pytest.mark.parametrize("edge_dilation_kernel_size", [3, 5]) def test_smoke(self, kernel_size, batch_size, edge_threshold, edge_dilation_kernel_size, device, dtype): - inpt = torch.zeros(batch_size, 3, 8, 8, device=device, dtype=dtype) - actual = edge_aware_blur_pool2d(inpt, kernel_size, edge_threshold, edge_dilation_kernel_size) - assert actual.shape == inpt.shape + data = torch.zeros(batch_size, 3, 8, 8, device=device, dtype=dtype) + actual = edge_aware_blur_pool2d(data, kernel_size, edge_threshold, edge_dilation_kernel_size) + assert actual.shape == data.shape @pytest.mark.parametrize("kernel_size", [3, (5, 5)]) @pytest.mark.parametrize("batch_size", [1, 2]) @@ -149,12 +149,12 @@ def test_cardinality(self, kernel_size, batch_size, device, dtype): def test_exception(self): with pytest.raises(Exception) as errinfo: - inpt = torch.rand(1, 3, 3) - edge_aware_blur_pool2d(inpt, 3) + data = torch.rand(1, 3, 3) + edge_aware_blur_pool2d(data, 3) assert "shape must be [['B', 'C', 'H', 'W']]" in str(errinfo) with pytest.raises(Exception) as errinfo: - inpt = torch.rand(1, 1, 3, 3) - edge_aware_blur_pool2d(inpt, 3, edge_threshold=-1) + data = torch.rand(1, 1, 3, 3) + edge_aware_blur_pool2d(data, 3, edge_threshold=-1) assert "edge threshold should be positive, but got" in str(errinfo) @pytest.mark.parametrize("batch_size", [1, 2]) @@ -189,8 +189,8 @@ def test_smooth(self, device, dtype): @pytest.mark.parametrize("batch_size", [1, 2]) def test_dynamo(self, batch_size, kernel_size, device, dtype, torch_optimizer): op = edge_aware_blur_pool2d - inpt = torch.rand(batch_size, 3, 4, 5, device=device, dtype=dtype) + data = torch.rand(batch_size, 3, 4, 5, device=device, dtype=dtype) op = EdgeAwareBlurPool2D(kernel_size) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_canny.py b/tests/filters/test_canny.py index a9117a317d..92db5a63cc 100644 --- a/tests/filters/test_canny.py +++ b/tests/filters/test_canny.py @@ -305,12 +305,12 @@ def test_dynamo(self, batch_size, kernel_size, device, dtype, torch_optimizer): and (isinstance(kernel_size, int) or kernel_size[0] == kernel_size[1]) ): pytest.skip("Canny compiled failing into fp64 for kernel sizes where kx and ky are equals") - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = Canny(kernel_size=kernel_size) op_optimized = torch_optimizer(op) - expected_magnitude, expected_edges = op(inpt) - actual_magnitude, actual_edges = op_optimized(inpt) + expected_magnitude, expected_edges = op(data) + actual_magnitude, actual_edges = op_optimized(data) self.assert_close(actual_magnitude, expected_magnitude) self.assert_close(actual_edges, expected_edges) diff --git a/tests/filters/test_filters.py b/tests/filters/test_filters.py index 1eb97bcddf..77e669d50d 100644 --- a/tests/filters/test_filters.py +++ b/tests/filters/test_filters.py @@ -76,13 +76,13 @@ def test_conv(self, device, dtype): def test_exception(self): k = torch.ones(1, 1, 1) - inpt = torch.ones(1, 1, 1, 1) + data = torch.ones(1, 1, 1, 1) with pytest.raises(TypeError) as errinfo: filter2d(1, k) assert "Not a Tensor type." in str(errinfo) with pytest.raises(TypeError) as errinfo: - filter2d(inpt, 1) + filter2d(data, 1) assert "Not a Tensor type." in str(errinfo) with pytest.raises(TypeError) as errinfo: @@ -90,15 +90,15 @@ def test_exception(self): assert "shape must be [['B', 'C', 'H', 'W']]" in str(errinfo) with pytest.raises(TypeError) as errinfo: - filter2d(inpt, torch.ones(1)) + filter2d(data, torch.ones(1)) assert "shape must be [['B', 'H', 'W']]" in str(errinfo) with pytest.raises(Exception) as errinfo: - filter2d(inpt, k, border_type="a") + filter2d(data, k, border_type="a") assert "Invalid border, gotcha a. Ex" in str(errinfo) with pytest.raises(Exception) as errinfo: - filter2d(inpt, k, padding="a") + filter2d(data, k, padding="a") assert "Invalid padding mode, gotcha a. Ex" in str(errinfo) @pytest.mark.parametrize("padding", ["same", "valid"]) @@ -359,12 +359,12 @@ def test_module(self): ... @pytest.mark.parametrize("padding", ["same", "valid"]) def test_dynamo(self, normalized, padding, device, dtype, torch_optimizer): kernel = torch.rand(1, 3, 3, device=device, dtype=dtype) - inpt = torch.ones(2, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(2, 3, 10, 10, device=device, dtype=dtype) op = filter2d op_optimized = torch_optimizer(op) - expected = op(inpt, kernel, padding=padding, normalized=normalized) - actual = op_optimized(inpt, kernel, padding=padding, normalized=normalized) + expected = op(data, kernel, padding=padding, normalized=normalized) + actual = op_optimized(data, kernel, padding=padding, normalized=normalized) self.assert_close(actual, expected) @@ -377,27 +377,27 @@ def test_smoke(self, border_type, normalized, device, dtype): pytest.skip(reason="Reflect border is not implemented for 3D on torch < 1.9.1") kernel = torch.rand(1, 3, 3, 3, device=device, dtype=dtype) - inpt = torch.ones(1, 1, 6, 7, 8, device=device, dtype=dtype) - actual = filter3d(inpt, kernel, border_type, normalized) + data = torch.ones(1, 1, 6, 7, 8, device=device, dtype=dtype) + actual = filter3d(data, kernel, border_type, normalized) assert isinstance(actual, torch.Tensor) - assert actual.shape == inpt.shape + assert actual.shape == data.shape @pytest.mark.parametrize("batch_size", [2, 3, 6, 8]) def test_cardinality(self, batch_size, device, dtype): kernel = torch.rand(1, 3, 3, 3, device=device, dtype=dtype) - inpt = torch.ones(batch_size, 3, 6, 7, 8, device=device, dtype=dtype) - assert filter3d(inpt, kernel).shape == inpt.shape + data = torch.ones(batch_size, 3, 6, 7, 8, device=device, dtype=dtype) + assert filter3d(data, kernel).shape == data.shape def test_exception(self): k = torch.ones(1, 1, 1, 1) - inpt = torch.ones(1, 1, 1, 1, 1) + data = torch.ones(1, 1, 1, 1, 1) with pytest.raises(TypeError) as errinfo: filter3d(1, k) assert "Not a Tensor type." in str(errinfo) with pytest.raises(TypeError) as errinfo: - filter3d(inpt, 1) + filter3d(data, 1) assert "Not a Tensor type." in str(errinfo) with pytest.raises(TypeError) as errinfo: @@ -405,11 +405,11 @@ def test_exception(self): assert "shape must be [['B', 'C', 'D', 'H', 'W']]" in str(errinfo) with pytest.raises(TypeError) as errinfo: - filter3d(inpt, torch.ones(1)) + filter3d(data, torch.ones(1)) assert "shape must be [['B', 'D', 'H', 'W']]" in str(errinfo) with pytest.raises(Exception) as errinfo: - filter3d(inpt, k, border_type="a") + filter3d(data, k, border_type="a") assert "Invalid border, gotcha a. Ex" in str(errinfo) def test_mean_filter(self, device, dtype): @@ -715,12 +715,12 @@ def test_module(self): ... @pytest.mark.parametrize("normalized", [True, False]) def test_dynamo(self, normalized, device, dtype, torch_optimizer): kernel = torch.rand(1, 3, 3, 3, device=device, dtype=dtype) - inpt = torch.ones(2, 3, 4, 10, 10, device=device, dtype=dtype) + data = torch.ones(2, 3, 4, 10, 10, device=device, dtype=dtype) op = filter3d op_optimized = torch_optimizer(op) - expected = op(inpt, kernel, normalized=normalized) - actual = op_optimized(inpt, kernel, normalized=normalized) + expected = op(data, kernel, normalized=normalized) + actual = op_optimized(data, kernel, normalized=normalized) self.assert_close(actual, expected) @@ -756,11 +756,11 @@ def test_inference(self, device, dtype, data): @pytest.mark.skip(reason="DexiNed do not compile with dynamo.") def test_dynamo(self, device, dtype, torch_optimizer): # TODO: update the dexined to be possible to use with dynamo - inpt = torch.rand(2, 3, 32, 32, device=device, dtype=dtype) + data = torch.rand(2, 3, 32, 32, device=device, dtype=dtype) op = DexiNed(pretrained=True).to(device, dtype) op_optimized = torch_optimizer(op) - expected = op(inpt) - actual = op_optimized(inpt) + expected = op(data) + actual = op_optimized(data) self.assert_close(actual, expected) diff --git a/tests/filters/test_gaussian.py b/tests/filters/test_gaussian.py index da6f719796..827b7d2f84 100644 --- a/tests/filters/test_gaussian.py +++ b/tests/filters/test_gaussian.py @@ -199,15 +199,15 @@ class TestGaussianBlur2d(BaseTester): @pytest.mark.parametrize("separable", [False, True]) def test_smoke(self, shape, kernel_size, separable, device, dtype): B, C, H, W = shape - inpt = torch.rand(B, C, H, W, device=device, dtype=dtype) + data = torch.rand(B, C, H, W, device=device, dtype=dtype) sigma_tensor = torch.rand(B, 2, device=device, dtype=dtype) - actual_A = gaussian_blur2d(inpt, kernel_size, sigma_tensor, "reflect", separable) + actual_A = gaussian_blur2d(data, kernel_size, sigma_tensor, "reflect", separable) assert isinstance(actual_A, torch.Tensor) assert actual_A.shape == shape sigma = tuple(sigma_tensor[0, ...].cpu().numpy().tolist()) - actual_B = gaussian_blur2d(inpt, kernel_size, sigma, "reflect", separable) + actual_B = gaussian_blur2d(data, kernel_size, sigma, "reflect", separable) assert isinstance(actual_B, torch.Tensor) assert actual_B.shape == shape @@ -271,15 +271,15 @@ def test_module(self, kernel_size, sigma, device, dtype): @pytest.mark.parametrize("kernel_size", [3, (5, 5), (5, 7)]) @pytest.mark.parametrize("sigma", [(1.5, 2.1), (0.5, 0.5)]) def test_dynamo(self, kernel_size, sigma, device, dtype, torch_optimizer): - inpt = torch.ones(1, 3, 5, 5, device=device, dtype=dtype) + data = torch.ones(1, 3, 5, 5, device=device, dtype=dtype) op = GaussianBlur2d(kernel_size, sigma) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) sigma_tensor = torch.tensor([sigma], device=device, dtype=dtype) op = GaussianBlur2d(kernel_size, sigma_tensor) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_guided.py b/tests/filters/test_guided.py index 09da8afd97..1210d85c08 100644 --- a/tests/filters/test_guided.py +++ b/tests/filters/test_guided.py @@ -98,16 +98,16 @@ def test_module(self, shape, kernel_size, eps, subsample, device, dtype): @pytest.mark.parametrize("subsample", [1, 2]) def test_dynamo(self, kernel_size, subsample, device, dtype, torch_optimizer): guide = torch.ones(2, 3, 8, 8, device=device, dtype=dtype) - inpt = torch.ones(2, 3, 8, 8, device=device, dtype=dtype) + data = torch.ones(2, 3, 8, 8, device=device, dtype=dtype) op = GuidedBlur(kernel_size, 0.1, subsample=subsample) op_optimized = torch_optimizer(op) - self.assert_close(op(guide, inpt), op_optimized(guide, inpt)) + self.assert_close(op(guide, data), op_optimized(guide, data)) op = GuidedBlur(kernel_size, torch.tensor(0.1, device=device, dtype=dtype), subsample=subsample) op_optimized = torch_optimizer(op) - self.assert_close(op(guide, inpt), op_optimized(guide, inpt)) + self.assert_close(op(guide, data), op_optimized(guide, data)) def test_opencv_grayscale(self, device, dtype): guide = [[100, 130, 58, 36], [215, 142, 173, 166], [114, 150, 190, 60], [23, 83, 84, 216]] diff --git a/tests/filters/test_in_range.py b/tests/filters/test_in_range.py index a3819bfad6..6a47c01812 100644 --- a/tests/filters/test_in_range.py +++ b/tests/filters/test_in_range.py @@ -121,7 +121,7 @@ def test_module(self, input_shape, lower, upper, device, dtype): def test_dynamo(self, batch_size, device, dtype, torch_optimizer): if device == torch.device("cpu") and torch_version() in {"2.3.0", "2.3.1"}: pytest.skip("Failing to compile on CPU see pytorch/pytorch#126619") - inpt = torch.rand(batch_size, 3, 5, 5, device=device, dtype=dtype) + data = torch.rand(batch_size, 3, 5, 5, device=device, dtype=dtype) op = InRange(lower=(0.2, 0.2, 0.2), upper=(0.6, 0.6, 0.6), return_mask=True) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_laplacian.py b/tests/filters/test_laplacian.py index 20d1fde720..3f17fa1c39 100644 --- a/tests/filters/test_laplacian.py +++ b/tests/filters/test_laplacian.py @@ -54,8 +54,8 @@ class TestLaplacian(BaseTester): @pytest.mark.parametrize("kernel_size", [5, (11, 7), (3, 3)]) @pytest.mark.parametrize("normalized", [True, False]) def test_smoke(self, shape, kernel_size, normalized, device, dtype): - inpt = torch.rand(shape, device=device, dtype=dtype) - actual = laplacian(inpt, kernel_size, "reflect", normalized) + data = torch.rand(shape, device=device, dtype=dtype) + actual = laplacian(data, kernel_size, "reflect", normalized) assert isinstance(actual, torch.Tensor) assert actual.shape == shape @@ -97,8 +97,8 @@ def test_module(self, device, dtype): @pytest.mark.parametrize("kernel_size", [5, (5, 7)]) @pytest.mark.parametrize("batch_size", [1, 2]) def test_dynamo(self, batch_size, kernel_size, device, dtype, torch_optimizer): - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = Laplacian(kernel_size) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_median.py b/tests/filters/test_median.py index e1c3648c9f..10885e32c8 100644 --- a/tests/filters/test_median.py +++ b/tests/filters/test_median.py @@ -99,8 +99,8 @@ def test_module(self, device, dtype): @pytest.mark.parametrize("kernel_size", [5, (5, 7)]) @pytest.mark.parametrize("batch_size", [1, 2]) def test_dynamo(self, batch_size, kernel_size, device, dtype, torch_optimizer): - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = MedianBlur(kernel_size) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_motion.py b/tests/filters/test_motion.py index b3acba0036..a24ec0c6a4 100644 --- a/tests/filters/test_motion.py +++ b/tests/filters/test_motion.py @@ -22,12 +22,12 @@ class TestMotionBlur(BaseTester): @pytest.mark.parametrize("params_as_tensor", [True, False]) def test_smoke(self, shape, kernel_size, angle, direction, mode, params_as_tensor, device, dtype): B, C, H, W = shape - inpt = torch.rand(shape, device=device, dtype=dtype) + data = torch.rand(shape, device=device, dtype=dtype) if params_as_tensor is True: angle = torch.tensor([angle], device=device, dtype=dtype).repeat(B) direction = torch.tensor([direction], device=device, dtype=dtype).repeat(B) - actual = motion_blur(inpt, kernel_size, angle, direction, "constant", mode) + actual = motion_blur(data, kernel_size, angle, direction, "constant", mode) assert isinstance(actual, torch.Tensor) assert actual.shape == shape @@ -95,11 +95,11 @@ def test_module(self, device, dtype): @pytest.mark.parametrize("batch_size", [1, 2]) def test_dynamo(self, batch_size, device, dtype, torch_optimizer): # TODO: FIX op - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = MotionBlur(3, 36.0, 0.5) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) class TestMotionBlur3D(BaseTester): @@ -111,12 +111,12 @@ class TestMotionBlur3D(BaseTester): @pytest.mark.parametrize("params_as_tensor", [True, False]) def test_smoke(self, shape, kernel_size, angle, direction, mode, params_as_tensor, device, dtype): B, C, D, H, W = shape - inpt = torch.rand(shape, device=device, dtype=dtype) + data = torch.rand(shape, device=device, dtype=dtype) if params_as_tensor is True: angle = torch.tensor([angle], device=device, dtype=dtype).expand(B, 3) direction = torch.tensor([direction], device=device, dtype=dtype).repeat(B) - actual = motion_blur3d(inpt, kernel_size, angle, direction, "constant", mode) + actual = motion_blur3d(data, kernel_size, angle, direction, "constant", mode) assert isinstance(actual, torch.Tensor) assert actual.shape == shape @@ -184,8 +184,8 @@ def test_module(self, device, dtype): @pytest.mark.parametrize("batch_size", [1, 2]) def test_dynamo(self, batch_size, device, dtype, torch_optimizer): # TODO: Fix the operation to works after dynamo optimize - inpt = torch.ones(batch_size, 3, 1, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 1, 10, 10, device=device, dtype=dtype) op = MotionBlur3D(3, (0.0, 360.0, 150.0), 0.5) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_sobel.py b/tests/filters/test_sobel.py index a1b8568f74..90866b2d90 100644 --- a/tests/filters/test_sobel.py +++ b/tests/filters/test_sobel.py @@ -13,8 +13,8 @@ class TestSpatialGradient(BaseTester): @pytest.mark.parametrize("order", [1, 2]) @pytest.mark.parametrize("normalized", [True, False]) def test_smoke(self, batch_size, mode, order, normalized, device, dtype): - inpt = torch.zeros(batch_size, 3, 4, 4, device=device, dtype=dtype) - actual = SpatialGradient(mode, order, normalized)(inpt) + data = torch.zeros(batch_size, 3, 4, 4, device=device, dtype=dtype) + actual = SpatialGradient(mode, order, normalized)(data) assert isinstance(actual, torch.Tensor) @pytest.mark.parametrize("batch_size", [1, 2]) @@ -245,14 +245,14 @@ def test_module(self, device, dtype): @pytest.mark.parametrize("batch_size", [1, 2]) @pytest.mark.xfail(torch_version() in {"2.0.1"}, reason="random failing") def test_dynamo(self, batch_size, order, mode, device, dtype, torch_optimizer): - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) if order == 1 and dtype == torch.float64: # TODO: FIX order 1 spatial gradient with fp64 on dynamo pytest.xfail(reason="Order 1 on spatial gradient may be wrong computed for float64 on dynamo") op = SpatialGradient(mode, order) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) class TestSpatialGradient3d(BaseTester): @@ -260,8 +260,8 @@ class TestSpatialGradient3d(BaseTester): @pytest.mark.parametrize("mode", ["diff"]) # TODO: add support to 'sobel' @pytest.mark.parametrize("order", [1, 2]) def test_smoke(self, batch_size, mode, order, device, dtype): - inpt = torch.ones(batch_size, 3, 2, 7, 4, device=device, dtype=dtype) - actual = SpatialGradient3d(mode, order)(inpt) + data = torch.ones(batch_size, 3, 2, 7, 4, device=device, dtype=dtype) + actual = SpatialGradient3d(mode, order)(data) assert isinstance(actual, torch.Tensor) @pytest.mark.parametrize("batch_size", [1, 2]) @@ -411,11 +411,11 @@ def test_module(self, device, dtype): @pytest.mark.parametrize("mode", ["diff"]) @pytest.mark.parametrize("order", [1, 2]) def test_dynamo(self, mode, order, device, dtype, torch_optimizer): - inpt = torch.ones(1, 3, 1, 10, 10, device=device, dtype=dtype) + data = torch.ones(1, 3, 1, 10, 10, device=device, dtype=dtype) op = SpatialGradient3d(mode, order) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) class TestSobel(BaseTester): @@ -508,8 +508,8 @@ def test_dynamo(self, batch_size, device, dtype, torch_optimizer): if dtype == torch.float64: # TODO: investigate sobel for float64 with dynamo pytest.xfail(reason="The sobel results can be different after dynamo on fp64") - inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype) op = Sobel() op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/filters/test_unsharp_mask.py b/tests/filters/test_unsharp_mask.py index 462e32634d..a0cf821c7a 100644 --- a/tests/filters/test_unsharp_mask.py +++ b/tests/filters/test_unsharp_mask.py @@ -15,8 +15,8 @@ def test_smoke(self, shape, kernel_size, sigma, params_as_tensor, device, dtype) if params_as_tensor is True: sigma = torch.tensor([sigma], device=device, dtype=dtype).repeat(shape[0], 1) - inpt = torch.ones(shape, device=device, dtype=dtype) - actual = unsharp_mask(inpt, kernel_size, sigma, "replicate") + data = torch.ones(shape, device=device, dtype=dtype) + actual = unsharp_mask(data, kernel_size, sigma, "replicate") assert isinstance(actual, torch.Tensor) assert actual.shape == shape @@ -25,8 +25,8 @@ def test_cardinality(self, shape, device, dtype): kernel_size = (5, 7) sigma = (1.5, 2.1) - inpt = torch.ones(shape, device=device, dtype=dtype) - actual = unsharp_mask(inpt, kernel_size, sigma, "replicate") + data = torch.ones(shape, device=device, dtype=dtype) + actual = unsharp_mask(data, kernel_size, sigma, "replicate") assert actual.shape == shape @pytest.mark.skip(reason="nothing to test") @@ -34,11 +34,11 @@ def test_exception(self): ... def test_noncontiguous(self, device, dtype): batch_size = 3 - inpt = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1) + data = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1) kernel_size = (3, 3) sigma = (1.5, 2.1) - actual = unsharp_mask(inpt, kernel_size, sigma, "replicate") + actual = unsharp_mask(data, kernel_size, sigma, "replicate") assert actual.is_contiguous() def test_gradcheck(self, device): @@ -48,8 +48,8 @@ def test_gradcheck(self, device): sigma = (1.5, 2.1) # evaluate function gradient - inpt = torch.rand(shape, device=device, dtype=torch.float64) - self.gradcheck(unsharp_mask, (inpt, kernel_size, sigma, "replicate")) + data = torch.rand(shape, device=device, dtype=torch.float64) + self.gradcheck(unsharp_mask, (data, kernel_size, sigma, "replicate")) def test_module(self, device, dtype): params = [(3, 3), (1.5, 1.5)] @@ -65,8 +65,8 @@ def test_dynamo(self, sigma, params_as_tensor, device, dtype, torch_optimizer): if params_as_tensor is True: sigma = torch.tensor([sigma], device=device, dtype=dtype) - inpt = torch.ones(1, 3, 10, 10, device=device, dtype=dtype) + data = torch.ones(1, 3, 10, 10, device=device, dtype=dtype) op = UnsharpMask(3, sigma) op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) diff --git a/tests/geometry/subpix/test_dsnt.py b/tests/geometry/subpix/test_dsnt.py index f2bdce3c2a..d33b5a8267 100644 --- a/tests/geometry/subpix/test_dsnt.py +++ b/tests/geometry/subpix/test_dsnt.py @@ -84,8 +84,8 @@ def test_forward(self, example): @pytest.mark.skip("After the op be optimized the results are not the same") def test_dynamo(self, dtype, device, torch_optimizer): - inpt = torch.tensor([[[[0.0, 0.0, 1.0], [0.0, 0.0, 0.0]]]], device=device, dtype=dtype) + data = torch.tensor([[[[0.0, 0.0, 1.0], [0.0, 0.0, 0.0]]]], device=device, dtype=dtype) op = kornia.geometry.subpix.spatial_expectation2d op_optimized = torch_optimizer(op) - assert_close(op(inpt, True), op_optimized(inpt, True)) + assert_close(op(data, True), op_optimized(data, True)) diff --git a/tests/geometry/subpix/test_spatial_softargmax.py b/tests/geometry/subpix/test_spatial_softargmax.py index 8be792ae29..707e961749 100644 --- a/tests/geometry/subpix/test_spatial_softargmax.py +++ b/tests/geometry/subpix/test_spatial_softargmax.py @@ -153,11 +153,11 @@ def test_end_to_end(self, device, dtype): loss.backward() def test_dynamo(self, device, dtype, torch_optimizer): - inpt = torch.rand((2, 3, 7, 7), dtype=dtype, device=device) + data = torch.rand((2, 3, 7, 7), dtype=dtype, device=device) op = kornia.geometry.subpix.spatial_soft_argmax2d op_optimized = torch_optimizer(op) - self.assert_close(op(inpt), op_optimized(inpt)) + self.assert_close(op(data), op_optimized(data)) class TestConvSoftArgmax2d(BaseTester): diff --git a/tests/grad_estimator/test_ste.py b/tests/grad_estimator/test_ste.py index 8437380d6d..f9690210f8 100644 --- a/tests/grad_estimator/test_ste.py +++ b/tests/grad_estimator/test_ste.py @@ -12,26 +12,26 @@ def test_smoke(self): StraightThroughEstimator(K.Normalize(0.5, 0.5)) def test_function(self, device, dtype): - inpt = torch.randn(4, requires_grad=True, device=device, dtype=dtype) - output = torch.sign(inpt) + data = torch.randn(4, requires_grad=True, device=device, dtype=dtype) + output = torch.sign(data) loss = output.mean() loss.backward() - assert_close(inpt.grad, torch.tensor([0.0, 0.0, 0.0, 0.0], device=device, dtype=dtype)) + assert_close(data.grad, torch.tensor([0.0, 0.0, 0.0, 0.0], device=device, dtype=dtype)) - out_est = STEFunction.apply(inpt, output, F.hardtanh) + out_est = STEFunction.apply(data, output, F.hardtanh) loss = out_est.mean() loss.backward() - assert_close(inpt.grad, torch.tensor([0.2500, 0.2500, 0.2500, 0.2500], device=device, dtype=dtype)) + assert_close(data.grad, torch.tensor([0.2500, 0.2500, 0.2500, 0.2500], device=device, dtype=dtype)) - out_est = STEFunction.apply(inpt, output, None) + out_est = STEFunction.apply(data, output, None) loss = out_est.mean() loss.backward() - assert_close(inpt.grad, torch.tensor([0.5000, 0.5000, 0.5000, 0.5000], device=device, dtype=dtype)) + assert_close(data.grad, torch.tensor([0.5000, 0.5000, 0.5000, 0.5000], device=device, dtype=dtype)) def test_module(self, device, dtype): - inpt = torch.randn(1, 1, 4, 4, requires_grad=True, device=device, dtype=dtype) + data = torch.randn(1, 1, 4, 4, requires_grad=True, device=device, dtype=dtype) estimator = StraightThroughEstimator(K.RandomPosterize(3, p=1.0), grad_fn=F.hardtanh) - out = estimator(inpt) + out = estimator(data) loss = out.mean() loss.backward() o = torch.tensor( @@ -48,7 +48,7 @@ def test_module(self, device, dtype): device=device, dtype=dtype, ) - assert_close(inpt.grad, o) + assert_close(data.grad, o) @pytest.mark.skip("Function.apply is not supported in Torchscript rightnow.") def test_jit(self, device, dtype): diff --git a/tests/performance/test_imgwarp_speed.py b/tests/performance/test_imgwarp_speed.py index 7fc58c9390..74ed38bbc8 100644 --- a/tests/performance/test_imgwarp_speed.py +++ b/tests/performance/test_imgwarp_speed.py @@ -18,11 +18,11 @@ def test_performance_speed(device, dtype): for input_shape in shapes: for PS in PSs: BS = input_shape[0] - inpt = torch.rand(input_shape).to(device) + data = torch.rand(input_shape).to(device) As = torch.eye(3).unsqueeze(0).repeat(BS, 1, 1)[:, :2, :].to(device) As += 0.1 * torch.rand(As.size()).to(device) torch.cuda.synchronize(device) t = time() - _ = kornia.warp_affine(inpt, As, (PS, PS)) + _ = kornia.warp_affine(data, As, (PS, PS)) print(f"inp={input_shape}, PS={PS}, dev={device}, {time() - t}, sec") torch.cuda.synchronize(device) diff --git a/tests/performance/test_project_points_speed.py b/tests/performance/test_project_points_speed.py index 53cb0896e8..69ea5891fc 100644 --- a/tests/performance/test_project_points_speed.py +++ b/tests/performance/test_project_points_speed.py @@ -17,10 +17,10 @@ def test_performance_speed(device, dtype): print("Benchmarking project_points") for input_shape in points_shapes: - inpt = torch.rand(input_shape).to(device) + data = torch.rand(input_shape).to(device) pose = torch.rand((1, 4, 4)).to(device) torch.cuda.synchronize(device) t = time() - kornia.geometry.transform_points(pose, inpt) + kornia.geometry.transform_points(pose, data) torch.cuda.synchronize(device) print(f"inp={input_shape}, dev={device}, {time() - t}, sec")