internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: kornia/kornia

Issue:
Outdated example
Outdated example on the geometry.transform.**crop_and_resize**() function

Following the clockwise order for the corners it should be:

`       >>> boxes = torch.tensor([[
                [1., 1.],
                [1., 2.],
                [2., 2.],
                [2., 1.],
            ]])  # 1x4x2`

Instead of the current:
`        >>> boxes = torch.tensor([[
                [1., 1.],
                [1., 2.],
                [2., 1.],
                [2., 2.],
            ]])  # 1x4x2`


Discussion:
Update from #461 
Actually now the coordinate must be give in x,y order. So the correct update is
`boxes = torch.tensor([[ 
                 [1., 1.], 
                 [2., 1.], 
                 [2., 2.], 
                 [1., 2.], 
             ]])`

Resolving patch:
diff --git a/kornia/geometry/transform/crop.py b/kornia/geometry/transform/crop.py
--- a/kornia/geometry/transform/crop.py
+++ b/kornia/geometry/transform/crop.py
@@ -36,9 +36,9 @@ def crop_and_resize(tensor: torch.Tensor, boxes: torch.Tensor, size: Tuple[int,
             ]])
         >>> boxes = torch.tensor([[
                 [1., 1.],
-                [1., 2.],
                 [2., 1.],
                 [2., 2.],
+                [1., 2.],
             ]])  # 1x4x2
         >>> kornia.crop_and_resize(input, boxes, (2, 2))
         tensor([[[ 6.0000,  7.0000],


Test patch:
Repository: kornia/kornia

Issue:
Backslash not showing in equation for Tversky Loss
## 📚 Documentation

The backslashs in the denominator of the Tversky loss equation is not rendered correctly with MathJax. As shown in this screenshot it only inserts a little space between P and G and thus does not correctly render the equation.

![tversky_doc](https://user-images.githubusercontent.com/7403236/83774582-28e2c480-a686-11ea-8fd3-dbc509719885.png)


<!-- A clear and concise description of what content in https://kornia.readthedocs.io is an issue. If this has to do with the general https://kornia.org website, please file an issue at https://github.com/kornia/kornia.github.io/issues/new/choose instead. If this has to do with https://kornia.org/tutorials, please file an issue at https://github.com/kornia/tutorials/issues/new -->




Discussion:

Resolving patch:
diff --git a/kornia/losses/tversky.py b/kornia/losses/tversky.py
--- a/kornia/losses/tversky.py
+++ b/kornia/losses/tversky.py
@@ -61,7 +61,7 @@ class TverskyLoss(nn.Module):
     .. math::
 
         \text{S}(P, G, \alpha; \beta) =
-          \frac{|PG|}{|PG| + \alpha |P \ G| + \beta |G \ P|}
+          \frac{|PG|}{|PG| + \alpha |P \setminus G| + \beta |G \setminus P|}
 
     where:
        - :math:`P` and :math:`G` are the predicted and ground truth binary


Test patch:
Repository: kornia/kornia

Issue:
_adapted_uniform is broken for tensors > 1 dimension and same_on_batch=True
## 🐛 Bug

`kornia.augmentation.utils.helpers._adapted_uniform` is broken for `len(shape) > 1` and `same_on_batch=True`

## To Reproduce

```python
from kornia.augmentation.utils.helpers import _adapted_uniform

shape = (1, 2)
_adapted_uniform(shape, 0.0, 1.0, same_on_batch=True)
```

```
RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor
```



Discussion:

Resolving patch:
diff --git a/kornia/augmentation/utils/helpers.py b/kornia/augmentation/utils/helpers.py
--- a/kornia/augmentation/utils/helpers.py
+++ b/kornia/augmentation/utils/helpers.py
@@ -127,7 +127,7 @@ def _adapted_uniform(
         high = torch.tensor(high, dtype=torch.float32)
     dist = Uniform(low, high)
     if same_on_batch:
-        return dist.rsample((1, *shape[1:])).repeat(shape[0])
+        return dist.rsample((1, *shape[1:])).repeat(shape[0], *[1] * (len(shape) - 1))
     else:
         return dist.rsample(shape)
 


Test patch:
Repository: kornia/kornia

Issue:
Enable typing support
## 🚀 Feature

Enable typing support for `kornia` so other packages can benefit from the type hints.

## Motivation

Currently `kornia` only uses the type hints to check for internal consistency. For other packages you get the following error message when running `mypy`:

```python
import kornia
```

```
error: Cannot find implementation or library stub for module named 'kornia'  [import]
```

## Pitch

To enable typing for other packages that depend on `kornia` we just need to put an empty file called `py.typed` in the root of the `kornia` package. See [`PEP561`](https://www.python.org/dev/peps/pep-0561/#packaging-type-information) for details.




Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -122,6 +122,10 @@ def run(self):
         # Package info
         packages=find_packages(exclude=('docs', 'test', 'examples',)),
 
+        package_data={
+            "kornia": ["py.typed"],
+        },
+
         zip_safe=True,
         install_requires=requirements,
         classifiers=[


Test patch:
Repository: kornia/kornia

Issue:
Broken link "InvDepthSmoothnessLoss"
## 📚 Documentation

In the documentation of this function https://kornia.readthedocs.io/en/latest/losses.html#kornia.losses.inverse_depth_smoothness_loss, the link is broken.

```See InvDepthSmoothnessLoss for details.```

The error is due to an incorrect name. The correct name should be `InverseDepthSmoothnessLoss`.




Discussion:
@KushajveerSingh could you send a quick PR fixing the typo ?

Resolving patch:
diff --git a/kornia/losses/depth_smooth.py b/kornia/losses/depth_smooth.py
--- a/kornia/losses/depth_smooth.py
+++ b/kornia/losses/depth_smooth.py
@@ -21,7 +21,7 @@ def inverse_depth_smoothness_loss(
         image: torch.Tensor) -> torch.Tensor:
     r"""Computes image-aware inverse depth smoothness loss.
 
-    See :class:`~kornia.losses.InvDepthSmoothnessLoss` for details.
+    See :class:`~kornia.losses.InverseDepthSmoothnessLoss` for details.
     """
     if not torch.is_tensor(idepth):
         raise TypeError("Input idepth type is not a torch.Tensor. Got {}"


Test patch:
Repository: kornia/kornia

Issue:
RandomAffine raises error
## 🐛 Bug

`kornia.augmentation.RandomAffine()` raises an error if `translate=(a, b)` with a < b. According to documentation, a and b should not be related, since they refer to maximum absolute fraction for horizontal and vertical translations, respectively. 

It seems that kornia/augmentation/random_generator/random_generator.py at line 181 run `_joint_range_check(cast(torch.Tensor, translate), "translate")` instead of `singular_range_check`

## To Reproduce

Code to reproduce:

```python
import kornia.augmentation as k_augmenter

affine_transformation = k_augmenter.RandomAffine(0, translate=(.5, 0))

aff_params = affine_transformation.generate_parameters([3, 100, 100])
```
>Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "site-packages/kornia/augmentation/augmentation.py", line 487, in generate_parameters
    self.same_on_batch)
  File "site-packages/kornia/augmentation/random_generator/random_generator.py", line 181, in random_affine_generator
    _joint_range_check(cast(torch.Tensor, translate), "translate")
  File "site-packages/kornia/augmentation/utils/param_validation.py", line 45, in _joint_range_check
    raise ValueError(f"{name}[0] should be smaller than {name}[1] got {ranged_factor}")
ValueError: translate[0] should be smaller than translate[1] got tensor([0.5000, 0.0000])

## Environment
 - torch==1.7.0
 - kornia==0.4.1




Discussion:
It happens to me to. Look like that instead of _joint_singular_check it use the _joint_range_check..  
This error has already been fixed in the master branch.

Please try install:
```base
pip install --upgrade git+https://github.com/kornia/kornia.git
```
Still getting the same error even with

```
kornia.__version__
'0.4.2+d8fb7fd'
```

<img width="900" alt="dd" src="https://user-images.githubusercontent.com/25898671/111329768-a9037500-866f-11eb-8a5d-c496064872a5.PNG">

Not really.. 
Ahh. I see the problem. I will fix it tomorrow.

Resolving patch:
diff --git a/kornia/augmentation/random_generator/random_generator.py b/kornia/augmentation/random_generator/random_generator.py
--- a/kornia/augmentation/random_generator/random_generator.py
+++ b/kornia/augmentation/random_generator/random_generator.py
@@ -244,7 +244,8 @@ def random_affine_generator(
 
     if translate is not None:
         translate = translate.to(device=device, dtype=dtype)
-        _joint_range_check(cast(torch.Tensor, translate), "translate")
+        assert 0. <= translate[0] <= 1. and 0. <= translate[1] <= 1. and translate.shape == torch.Size([2]), \
+            f"Expect translate contains two elements and ranges are in [0, 1]. Got {translate}."
         max_dx: torch.Tensor = translate[0] * width
         max_dy: torch.Tensor = translate[1] * height
         translations = torch.stack([


Test patch:
Repository: kornia/kornia

Issue:
[Bug] save pointcloud not updates num_points when inf
## 🐛 Bug

The function `K.utils.save_pointcloud_ply` doesn't update the final number of points to be serialized when one of the values contain an infinite value.

How to  fix:

update this line https://github.com/kornia/kornia/blob/master/kornia/utils/pointcloud_io.py#L34

```python
            if not bool(torch.isfinite(xyz).any()):
                continue
```
by

```python
            if not bool(torch.isfinite(xyz).any()):
                num_points -= 1
                continue
```


Discussion:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions, and happy coding day :sunglasses:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions, and happy coding day :sunglasses:


Resolving patch:
diff --git a/kornia/utils/pointcloud_io.py b/kornia/utils/pointcloud_io.py
--- a/kornia/utils/pointcloud_io.py
+++ b/kornia/utils/pointcloud_io.py
@@ -31,6 +31,7 @@ def save_pointcloud_ply(filename: str, pointcloud: torch.Tensor) -> None:
         for idx in range(num_points):
             xyz = xyz_vec[idx]
             if not bool(torch.isfinite(xyz).any()):
+                num_points -= 1
                 continue
             x: float = xyz[0].item()
             y: float = xyz[1].item()


Test patch:
diff --git a/test/utils/test_pointcloud_io.py b/test/utils/test_pointcloud_io.py
--- a/test/utils/test_pointcloud_io.py
+++ b/test/utils/test_pointcloud_io.py
@@ -22,3 +22,31 @@ def test_save_pointcloud(self):
         # remove the temporal file
         if os.path.exists(filename):
             os.remove(filename)
+
+    @staticmethod
+    def test_inf_coordinates_save_pointcloud():
+        # create the tensor to save
+        height, width = 10, 8
+        xyz_save = torch.rand(height, width, 3)
+
+        # add nans or infinite values
+        # point data (inf, inf, inf) skipped
+        xyz_save[0, 0, :] = float('inf')
+        # point data (inf, number, number) counted
+        xyz_save[0, 1, 0] = float('inf')
+        # point data (inf, inf, number) counted
+        xyz_save[1, 0, :-1] = float('inf')
+
+        # save to file
+        filename = "pointcloud.ply"
+        kornia.save_pointcloud_ply(filename, xyz_save)
+
+        # same as xyz_save but with dropping the first point
+        xyz_correct = xyz_save.reshape(-1, 3)[1:, :]
+
+        # load file
+        xyz_load = kornia.load_pointcloud_ply(filename)
+        assert_close(xyz_correct, xyz_load)
+
+        if os.path.exists(filename):
+            os.remove(filename)
Repository: kornia/kornia

Issue:
PyPI tarball missing required files
### Describe the bug

The tarball uploaded to PyPI does not contain `requirements/*` files which are required to run the `setup.py` file.

### Reproduction steps

```bash
$ wget https://files.pythonhosted.org/packages/source/k/kornia/kornia-0.6.0.tar.gz
$ tar zxf kornia-0.6.0.tar.gz
$ cd kornia-0.6.0
$ python setup.py install
...
Traceback (most recent call last):
  File "setup.py", line 43, in <module>
    "x": load_requirements("requirements/x.txt"),
  File "setup.py", line 38, in load_requirements
    with open(filename) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'requirements/x.txt'
```


### Expected behavior

I would expect the `setup.py` to function correctly. I believe there's a setuptools option to control which files get included in the upload tarball.

### Environment

```shell
- PyTorch Version (e.g., 1.0): 1.10
- OS (e.g., Linux): macOS
- How you installed PyTorch (`conda`, `pip`, source): `spack`
- Build command you used (if compiling from source): `python setup.py install`
- Python version: 3.8.11
- CUDA/cuDNN version: N/A
- GPU models and configuration: N/A
- Any other relevant information: N/A
```


### Additional context

_No response_


Discussion:
  since kornia[x] only requires accelerate - the easier might be to hard-code the dependency in the setup file
`requirements/dev.txt` is also required and includes a lot more dependencies. Yes, you can either write these in the `setup.py` file or add both files to the list of files uploaded to PyPI.
ok - seems that `package_data` is what we want here

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -63,6 +63,7 @@ def load_requirements(filename: str):
         tests_require=['pytest'],
         packages=find_packages(exclude=('docs', 'test', 'examples')),
         package_data={"kornia": ["py.typed"]},
+        data_files=[('', ['requirements/x.txt', 'requirements/dev.txt'])],
         zip_safe=True,
         install_requires=requirements,
         extras_require=requirements_extras,


Test patch:
Repository: kornia/kornia

Issue:
importing kornia attempts download of pretrained model
### Describe the bug

When importing kornia 0.6.0 for the first time it attempts to download a pretrained model.

This may be problematic for organizations which do not permit access to the internet.

kornia 0.5.x does not suffer from this problem.

### Reproduction steps

```bash
1. Build from source
2. python -c 'import kornia`

Leads to: 


Downloading: "https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/checkpoint_liberty_with_aug.pth" to .......snip...../.cache/torch/hub/checkpoints/checkpoint_liberty_with_aug.pth
```
```


### Expected behavior

I would expect pretrained models not to be needed until explicit use of the feature which requires it.

### Environment

```shell
- PyTorch Version (e.g., 1.0): 1.10.0
- OS (e.g., Linux): Linux
- How you installed PyTorch (`conda`, `pip`, source): source
- Build command you used (if compiling from source): 
- Python version: 3.7
- CUDA/cuDNN version: 11.4
- GPU models and configuration:
- Any other relevant information:
```


### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/kornia/feature/integrated.py b/kornia/feature/integrated.py
--- a/kornia/feature/integrated.py
+++ b/kornia/feature/integrated.py
@@ -62,10 +62,12 @@ class LAFDescriptor(nn.Module):
     """
 
     def __init__(self,
-                 patch_descriptor_module: nn.Module = HardNet(True),
+                 patch_descriptor_module: Optional[nn.Module] = None,
                  patch_size: int = 32,
                  grayscale_descriptor: bool = True) -> None:
         super().__init__()
+        if patch_descriptor_module is None:
+            patch_descriptor_module = HardNet(True)
         self.descriptor = patch_descriptor_module
         self.patch_size = patch_size
         self.grayscale_descriptor = grayscale_descriptor
@@ -165,7 +167,7 @@ def __init__(self,
                                       ori_module=PassLAF() if upright else LAFOrienter(19),
                                       aff_module=LAFAffNetShapeEstimator(True).eval(),
                                       mr_size=6.0).to(device)
-        descriptor = LAFDescriptor(HardNet(True).eval(),
+        descriptor = LAFDescriptor(None,
                                    patch_size=32,
                                    grayscale_descriptor=True).to(device)
         super().__init__(detector, descriptor)


Test patch:
Repository: kornia/kornia

Issue:
DataKey Typo BBOX_XYHW
### Describe the bug

`AugmentationSequential` doesnt accept the `bbox_xywh` data key

### Reproduction steps

```bash
1.Initialize `AugmentationSequential` with said data key
```


### Expected behavior

Initialize just fine like mentioned in the docs.

### Environment

```shell
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```
- PyTorch Version (e.g., 1.0): 1.10
- OS (e.g., Linux): Linux
- How you installed PyTorch (`conda`, `pip`, source): pip
- Build command you used (if compiling from source): no
- Python version: 3.9.12
- CUDA/cuDNN version: 11.5/8
- GPU models and configuration: 1
- Any other relevant information:
```


### Additional context

bbox format xywh is the common notation


Discussion:

Resolving patch:
diff --git a/kornia/augmentation/container/utils.py b/kornia/augmentation/container/utils.py
--- a/kornia/augmentation/container/utils.py
+++ b/kornia/augmentation/container/utils.py
@@ -313,7 +313,7 @@ def _get_func_by_key(cls, dcate: Union[str, int, DataKey]) -> Type[ApplyInverseI
             return MaskApplyInverse
         if DataKey.get(dcate) in [DataKey.BBOX, DataKey.BBOX_XYXY]:
             return BBoxXYXYApplyInverse
-        if DataKey.get(dcate) in [DataKey.BBOX_XYHW]:
+        if DataKey.get(dcate) in [DataKey.BBOX_XYWH]:
             return BBoxXYWHApplyInverse
         if DataKey.get(dcate) in [DataKey.KEYPOINTS]:
             return KeypointsApplyInverse
diff --git a/kornia/constants.py b/kornia/constants.py
--- a/kornia/constants.py
+++ b/kornia/constants.py
@@ -58,5 +58,5 @@ class DataKey(ConstantBase, Enum, metaclass=EnumMetaFlags):
     MASK = 1
     BBOX = 2
     BBOX_XYXY = 3
-    BBOX_XYHW = 4
+    BBOX_XYWH = 4
     KEYPOINTS = 5


Test patch:
Repository: kornia/kornia

Issue:
kornia.augmentation.resize does not have antialias flag, unlike kornia.geometry.transform.resize
### Describe the bug

Check 
https://kornia.readthedocs.io/en/latest/_modules/kornia/augmentation/_2d/geometric/resize.html#Resize

versus 
https://kornia.readthedocs.io/en/latest/geometry.transform.html#kornia.geometry.transform.Resize


Discussion:
Hi, I would like to work on this issue. Is there any specific requirement that I need to keep in mind while working on this?
@Tanmay06 please, go ahead! Just take a read on this
https://github.com/kornia/kornia/blob/master/CONTRIBUTING.rst#developing-kornia

Resolving patch:
diff --git a/kornia/augmentation/_2d/geometric/resize.py b/kornia/augmentation/_2d/geometric/resize.py
--- a/kornia/augmentation/_2d/geometric/resize.py
+++ b/kornia/augmentation/_2d/geometric/resize.py
@@ -18,6 +18,7 @@ class Resize(GeometricAugmentationBase2D):
         side: Which side to resize, if size is only of type int.
         resample: Resampling mode.
         align_corners: interpolation flag.
+        antialias: if True, then image will be filtered with Gaussian before downscaling. No effect for upscaling.
         keepdim: whether to keep the output shape the same as input (True) or broadcast it
             to the batch form (False).
     """
@@ -28,13 +29,20 @@ def __init__(
         side: str = "short",
         resample: Union[str, int, Resample] = Resample.BILINEAR.name,
         align_corners: bool = True,
+        antialias: bool = False,
         p: float = 1.0,
         return_transform: Optional[bool] = None,
         keepdim: bool = False,
     ) -> None:
         super().__init__(p=1., return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim)
         self._param_generator = cast(rg.ResizeGenerator, rg.ResizeGenerator(resize_to=size, side=side))
-        self.flags = dict(size=size, side=side, resample=Resample.get(resample), align_corners=align_corners)
+        self.flags = dict(
+            size=size,
+            side=side,
+            resample=Resample.get(resample),
+            align_corners=align_corners,
+            antialias=antialias
+        )
 
     def compute_transformation(self, input: Tensor, params: Dict[str, Tensor]) -> Tensor:
         if params["output_size"] == input.shape[-2:]:
@@ -60,6 +68,7 @@ def apply_transform(
                 out_size,
                 interpolation=(self.flags["resample"].name).lower(),
                 align_corners=self.flags["align_corners"],
+                antialias=self.flags["antialias"]
             )
         return out
 


Test patch:
Repository: kornia/kornia

Issue:
Missing `f` prefix on f-strings
Some strings looks like they're meant to be f-strings but are missing the `f` prefix meaning variable interpolation won't happen.

https://github.com/kornia/kornia/blob/9f9544de123b56155486df5b69b4cab81bcf3006/kornia/enhance/equalization.py#L359

I found this issue automatically. I'm a bot. Beep Boop 🦊. See other issues I found in your repo [here](https://codereview.doctor/kornia/kornia)


Discussion:

Resolving patch:
diff --git a/kornia/enhance/equalization.py b/kornia/enhance/equalization.py
--- a/kornia/enhance/equalization.py
+++ b/kornia/enhance/equalization.py
@@ -356,7 +356,7 @@ def equalize_clahe(input: torch.Tensor,
         raise TypeError("Input grid_size type is not valid, must be a Tuple[int, int].")
 
     if grid_size[0] <= 0 or grid_size[1] <= 0:
-        raise ValueError("Input grid_size elements must be positive. Got {grid_size}")
+        raise ValueError(f"Input grid_size elements must be positive. Got {grid_size}")
 
     imgs: torch.Tensor = input  # B x C x H x W
 


Test patch: