class_docstr: Module which detects and described local features in an image using the DISK method. See
  :cite:`tyszkiewicz2020disk` for details.
  
  .. image:: _static/img/disk_outdoor_depth.jpg
  
  Args:
      desc_dim: The dimension of the descriptor.
      unet: The U-Net to use. If None, a default U-Net is used. Kornia doesn't provide the training code for DISK
            so this is only useful when using a custom checkpoint trained using the code released with the paper.
            The unet should take as input a tensor of shape :math:`(B, C, H, W)` and output a tensor of shape
            :math:`(B, \mathrm{desc\_dim} + 1, H, W)`.
  
  Example:
      >>> disk = DISK.from_pretrained('depth')
      >>> images = torch.rand(1, 3, 256, 256)
      >>> features = disk(images)
class_docstr_tok: ["Module","which","detects","and","described","local","features","in","an","image","using","the","DISK","method",".","See",":","cite",":","`","tyszkiewicz2020disk","`","for","details",".","..","image",":",":","_static\/img\/disk_outdoor_depth.jpg","Args",":","desc_dim",":","The","dimension","of","the","descriptor",".","unet",":","The","U-Net","to","use",".","If","None",",","a","default","U-Net","is","used",".","Kornia","does","n't","provide","the","training","code","for","DISK","so","this","is","only","useful","when","using","a","custom","checkpoint","trained","using","the","code","released","with","the","paper",".","The","unet","should","take","as","input","a","tensor","of","shape",":","math",":","`","(","B",",","C",",","H",",","W",")","`","and","output","a","tensor","of","shape",":","math",":","`","(","B",",","\\mathrm","{","desc\\_dim","}","+","1",",","H",",","W",")","`",".","Example",":",">",">",">","disk","=","DISK.from_pretrained","(","'depth","'",")",">",">",">","images","=","torch.rand","(","1",",","3",",","256",",","256",")",">",">",">","features","=","disk","(","images",")"]
docstr: Detects features in an image, returning keypoint locations, descriptors and detection scores.
  
  Args:
      images: The image to detect features in. Shape :math:`(B, 3, H, W)`.
      n: The maximum number of keypoints to detect. If None, all keypoints are returned.
      window_size: The size of the non-maxima suppression window used to filter detections.
      score_threshold: The minimum score a detection must have to be returned.
                       See :py:class:`DISKFeatures` for details.
      pad_if_not_divisible: if True, the non-16 divisible input is zero-padded to the closest 16-multiply
  
  Returns:
      A list of length :math:`B` containing the detected features.
docstr_tok: ["Detects","features","in","an","image",",","returning","keypoint","locations",",","descriptors","and","detection","scores",".","Args",":","images",":","The","image","to","detect","features","in",".","Shape",":","math",":","`","(","B",",","3",",","H",",","W",")","`",".","n",":","The","maximum","number","of","keypoints","to","detect",".","If","None",",","all","keypoints","are","returned",".","window_size",":","The","size","of","the","non-maxima","suppression","window","used","to","filter","detections",".","score_threshold",":","The","minimum","score","a","detection","must","have","to","be","returned",".","See",":","py",":","class",":","`","DISKFeatures","`","for","details",".","pad_if_not_divisible",":","if","True",",","the","non-16","divisible","input","is","zero-padded","to","the","closest","16-multiply","Returns",":","A","list","of","length",":","math",":","`","B","`","containing","the","detected","features","."]
code: def forward(
      self,
      images: Tensor,
      n: Optional[int] = None,
      window_size: int = 5,
      score_threshold: float = 0.0,
      pad_if_not_divisible: bool = False,
  ) -> list[DISKFeatures]:
      """Detects features in an image, returning keypoint locations, descriptors and detection scores.
  
      Args:
          images: The image to detect features in. Shape :math:`(B, 3, H, W)`.
          n: The maximum number of keypoints to detect. If None, all keypoints are returned.
          window_size: The size of the non-maxima suppression window used to filter detections.
          score_threshold: The minimum score a detection must have to be returned.
                           See :py:class:`DISKFeatures` for details.
          pad_if_not_divisible: if True, the non-16 divisible input is zero-padded to the closest 16-multiply
  
      Returns:
          A list of length :math:`B` containing the detected features.
      """
      B = images.shape[0]
      if pad_if_not_divisible:
          h, w = images.shape[2:]
          pd_h = 16 - h % 16 if h % 16 > 0 else 0
          pd_w = 16 - w % 16 if w % 16 > 0 else 0
          images = torch.nn.functional.pad(
              images, (0, pd_w, 0, pd_h), value=0.0
          )
  
      heatmaps, descriptors = self.heatmap_and_dense_descriptors(images)
      if pad_if_not_divisible:
          heatmaps = heatmaps[..., :h, :w]
          descriptors = descriptors[..., :h, :w]
  
      keypoints = heatmap_to_keypoints(
          heatmaps,
          n=n,
          window_size=window_size,
          score_threshold=score_threshold,
      )
  
      features = []
      for i in range(B):
          features.append(
              keypoints[i].merge_with_descriptors(descriptors[i])
          )
  
      return features
  
file_path: kornia/kornia/feature/disk/disk.py
imports: from __future__ import annotations
  from typing import Optional
  import torch
  from kornia.core import Module, Tensor
  from ._unets import Unet
  from .detector import heatmap_to_keypoints
  from .structs import DISKFeatures
label_desc: Use image node_id 3 for calling the DISK obj's underlying member method code with example usage: obj.forward(images, n, window_size, score_threshold, pad_if_not_divisible) and returns: features