Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Ci: fix old torch install (#2763)

João Gustavo A. Amorim5ef95d8ea1c1
diff --git a/.github/workflows/pr_test_cpu.yml b/.github/workflows/pr_test_cpu.yml
index 938390547..e1a9745dc 100644
--- a/.github/workflows/pr_test_cpu.yml
+++ b/.github/workflows/pr_test_cpu.yml
@@ -25,7 +25,7 @@ jobs:
- os: 'MacOS-latest'
pytorch-dtype: 'float64'
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
with:
os: ${{ matrix.os }}
python-version: '["3.8", "3.11"]'
@@ -33,16 +33,16 @@ jobs:
pytorch-dtype: ${{ matrix.pytorch-dtype }}
coverage:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
typing:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
tutorials:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
docs:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
collector:
needs: [coverage, tests-cpu, tutorials, typing, docs]
@@ -63,7 +63,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/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
with:
os: ${{ matrix.os }}
pytorch-version: '["nightly"]'
diff --git a/.github/workflows/scheduled_test_cpu.yml b/.github/workflows/scheduled_test_cpu.yml
index 33554d39b..6af238a22 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/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
with:
os: 'Ubuntu-latest'
python-version: '["3.8", "3.9", "3.10", "3.11"]'
@@ -34,7 +34,7 @@ jobs:
matrix:
pytorch-dtype: ['float32', 'float64']
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
with:
os: 'Windows-latest'
python-version: '["3.11"]'
@@ -47,19 +47,19 @@ jobs:
matrix:
pytorch-dtype: ['float32', 'float64']
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
with:
os: 'MacOS-latest'
pytorch-dtype: ${{ matrix.pytorch-dtype }}
coverage:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
typing:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
tutorials:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
docs:
- uses: kornia/workflows/.github/workflows/[email protected]
+ uses: kornia/workflows/.github/workflows/[email protected]
diff --git a/kornia/contrib/models/rt_detr/architecture/hybrid_encoder.py b/kornia/contrib/models/rt_detr/architecture/hybrid_encoder.py
index 3e61aad10..eb00ea8de 100644
--- a/kornia/contrib/models/rt_detr/architecture/hybrid_encoder.py
+++ b/kornia/contrib/models/rt_detr/architecture/hybrid_encoder.py
@@ -13,6 +13,7 @@ from torch.nn.utils.fusion import fuse_conv_bn_weights
from kornia.contrib.models.common import ConvNormAct
from kornia.core import Module, Tensor, concatenate, pad
+from kornia.utils._compat import torch_meshgrid
class RepVggBlock(Module):
@@ -132,7 +133,7 @@ class AIFI(Module):
"""
xs = torch.arange(w, device=device, dtype=dtype)
ys = torch.arange(h, device=device, dtype=dtype)
- grid_x, grid_y = torch.meshgrid(xs, ys, indexing="ij")
+ grid_x, grid_y = torch_meshgrid([xs, ys], indexing="ij")
pos_dim = embed_dim // 4
omega = torch.arange(pos_dim, device=device, dtype=dtype) / pos_dim
diff --git a/kornia/contrib/models/rt_detr/architecture/rtdetr_head.py b/kornia/contrib/models/rt_detr/architecture/rtdetr_head.py
index 6cf2fce06..b75e56eca 100644
--- a/kornia/contrib/models/rt_detr/architecture/rtdetr_head.py
+++ b/kornia/contrib/models/rt_detr/architecture/rtdetr_head.py
@@ -10,6 +10,7 @@ from torch import nn
from kornia.contrib.models.common import MLP, ConvNormAct
from kornia.core import Module, Tensor, concatenate
+from kornia.utils._compat import torch_meshgrid
def _inverse_sigmoid(x: torch.Tensor, eps: float = 1e-5) -> torch.Tensor:
@@ -374,7 +375,7 @@ class RTDETRHead(Module):
level_start_index.append(h * w + level_start_index[-1])
# [b, l, c]
- feat_flatten: Tensor = torch.concat(feat_flatten_list, 1)
+ feat_flatten: Tensor = concatenate(feat_flatten_list, 1)
level_start_index.pop()
return feat_flatten, spatial_shapes, level_start_index
@@ -445,8 +446,9 @@ class RTDETRHead(Module):
for i, (h, w) in enumerate(spatial_shapes):
# TODO: fix later kornia.utils.create_meshgrid()
- grid_y, grid_x = torch.meshgrid(
- torch.arange(h, device=device, dtype=dtype), torch.arange(w, device=device, dtype=dtype), indexing="ij"
+ grid_y, grid_x = torch_meshgrid(
+ [torch.arange(h, device=device, dtype=dtype), torch.arange(w, device=device, dtype=dtype)],
+ indexing="ij",
)
grid_xy = torch.stack([grid_x, grid_y], -1) # HxWx2
@@ -464,7 +466,7 @@ class RTDETRHead(Module):
anchors = torch.log(anchors / (1 - anchors)) # anchors.logit() fails ONNX export
inf_t = torch.empty(1, device=device, dtype=dtype)
- inf_t[0] = torch.inf
+ inf_t[0] = float("inf")
anchors = torch.where(valid_mask, anchors, inf_t)
diff --git a/kornia/enhance/jpeg.py b/kornia/enhance/jpeg.py
index 014baa714..8fae9332c 100644
--- a/kornia/enhance/jpeg.py
+++ b/kornia/enhance/jpeg.py
@@ -5,6 +5,7 @@ from typing import Optional
import torch
from kornia.color import rgb_to_ycbcr, ycbcr_to_rgb
+from kornia.constants import pi
from kornia.core import Device, Dtype, Module, Parameter, Tensor
from kornia.core.check import (
KORNIA_CHECK,
@@ -99,7 +100,7 @@ def _dct_8x8(input: Tensor) -> Tensor:
# Make DCT tensor and scaling
index: Tensor = torch.arange(8, dtype=dtype, device=device)
x, y, u, v = torch.meshgrid(index, index, index, index)
- dct_tensor: Tensor = ((2.0 * x + 1.0) * u * torch.pi / 16.0).cos() * ((2.0 * y + 1.0) * v * torch.pi / 16.0).cos()
+ dct_tensor: Tensor = ((2.0 * x + 1.0) * u * pi / 16.0).cos() * ((2.0 * y + 1.0) * v * pi / 16.0).cos()
alpha: Tensor = torch.ones(8, dtype=dtype, device=device)
alpha[0] = 1.0 / (2**0.5)
dct_scale: Tensor = torch.einsum("i, j -> ij", alpha, alpha) * 0.25
@@ -128,7 +129,7 @@ def _idct_8x8(input: Tensor) -> Tensor:
# Make DCT tensor and scaling
index: Tensor = torch.arange(8, dtype=dtype, device=device)
x, y, u, v = torch.meshgrid(index, index, index, index)
- idct_tensor: Tensor = ((2.0 * u + 1.0) * x * torch.pi / 16.0).cos() * ((2.0 * v + 1.0) * y * torch.pi / 16.0).cos()
+ idct_tensor: Tensor = ((2.0 * u + 1.0) * x * pi / 16.0).cos() * ((2.0 * v + 1.0) * y * pi / 16.0).cos()
# Apply DCT
output: Tensor = 0.25 * torch.tensordot(input, idct_tensor, dims=2) + 128.0
return output
diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt
index 289dd70fc..54072b98d 100644
--- a/requirements/requirements-dev.txt
+++ b/requirements/requirements-dev.txt
@@ -7,3 +7,4 @@ pre-commit>=2
pydocstyle
pytest==7.4.4
pytest-timeout
+requests
diff --git a/requirements/requirements-x.txt b/requirements/requirements-x.txt
index b816c4336..f1ce911cb 100644
--- a/requirements/requirements-x.txt
+++ b/requirements/requirements-x.txt
@@ -1,2 +1,2 @@
-accelerate==0.26.1
+accelerate
onnxruntime-gpu>=1.16; sys_platform != 'darwin'
diff --git a/tests/augmentation/test_auto_operation.py b/tests/augmentation/test_auto_operation.py
index 25411e59b..c1ac631b8 100644
--- a/tests/augmentation/test_auto_operation.py
+++ b/tests/augmentation/test_auto_operation.py
@@ -113,7 +113,7 @@ class TestRandAugment(BaseTester):
aug(in_tensor)
@pytest.mark.xfail(
- torch_version() in {"1.10.2", "1.11.0", "1.12.1", "1.13.1"},
+ torch_version() in {"1.9.1", "1.10.2", "1.11.0", "1.12.1", "1.13.1"},
reason="randomness failing into some torch versions",
)
def test_transform_mat(self, device, dtype):
diff --git a/tests/geometry/camera/test_projections.py b/tests/geometry/camera/test_projections.py
index 0736af524..5bb74058e 100644
--- a/tests/geometry/camera/test_projections.py
+++ b/tests/geometry/camera/test_projections.py
@@ -53,7 +53,7 @@ class TestProjectionZ1(BaseTester):
# the projection is not defined and the function returns inf. The second point
# is behind the camera which is not a valid point and the user should handle it.
points = torch.tensor([[1.0, 2.0, 0.0], [4.0, 5.0, -1.0]], device=device, dtype=dtype)
- expected = torch.tensor([[torch.inf, torch.inf], [-4.0, -5.0]], device=device, dtype=dtype)
+ expected = torch.tensor([[float("inf"), float("inf")], [-4.0, -5.0]], device=device, dtype=dtype)
self.assert_close(project_points_z1(points), expected)
def test_unproject_points_z1(self, device, dtype):
diff --git a/tests/nerf/test_renderer.py b/tests/nerf/test_renderer.py
index d29435a5c..fed9eb648 100755
--- a/tests/nerf/test_renderer.py
+++ b/tests/nerf/test_renderer.py
@@ -4,6 +4,7 @@ import torch
from kornia.core import Device, Tensor
from kornia.nerf.volume_renderer import IrregularRenderer, RegularRenderer
+from kornia.utils._compat import torch_meshgrid
from testing.base import assert_close
@@ -13,7 +14,7 @@ def _create_regular_point_cloud(
) -> Tensor:
x = torch.linspace(0, width, steps=width, device=device, dtype=dtype)
y = torch.linspace(0, height, steps=height, device=device, dtype=dtype)
- xy = torch.meshgrid(y, x, indexing="ij")
+ xy = torch_meshgrid([y, x], indexing="ij")
z = torch.linspace(1, 11, steps=num_ray_points, device=device, dtype=dtype)
points3d = torch.zeros(height, width, num_ray_points, 3, device=device, dtype=dtype)
points3d[..., 0] = xy[0].unsqueeze(-1)