limap.features package

Subpackages

Submodules

limap.features.extract_line_patches module

limap.features.extract_line_patches.extract_line_patch_oneimage(cfg, track, img_id, camview, feature)

Returns: _features.PatchInfo_fx

limap.features.extract_line_patches.extract_line_patches(cfg, track, p_camviews, p_features)

Returns: list of _features.PatchInfo_fx

limap.features.extract_line_patches.get_extractor(cfg, channels)
limap.features.extract_line_patches.load_patch(fname, dtype='float16')
limap.features.extract_line_patches.write_patch(fname, patch, dtype='float16')

limap.features.extractors module

class limap.features.extractors.DSIFTExtractor(device: str, *args, **kwargs)

Bases: Extractor

adapt_image(pil_img: <module 'PIL.Image' from '/home/shaoliu/anaconda3/envs/limap/lib/python3.9/site-packages/PIL/Image.py'>) Tensor

Preprocess images. The output is later forwarded to extract_featuremaps.

Parameters:

pil_img – RGB PIL-Image, not preprocessed.

Returns:

Preprocessed and corrected image as torch.Tensor[1xHxWxC].

extract_featuremaps(image_batch: Tensor) list

Extract list of featuremaps where first is finest and last is coarsest.

Parameters:

image_batch – [BxHxWxC] Tensor.

Returns:

List of self.num_levels featuremaps as torch.Tensor[HxWxC] on device.

training: bool
class limap.features.extractors.Extractor(device: str)

Bases: Module

Dense feature extractor.

Parameters:

device – torch device name (cuda, cpu, cuda:0, …).

model

Torch model used for extraction (else None).

Type:

torch.NN.Module

num_levels

Number of levels returned by this network.

Type:

int

channels

output channels for each level of featuremaps.

Type:

List[int]

adapt_image(pil_img: <module 'PIL.Image' from '/home/shaoliu/anaconda3/envs/limap/lib/python3.9/site-packages/PIL/Image.py'>) Tensor

Preprocess images. The output is later forwarded to extract_featuremaps.

Parameters:

pil_img – RGB PIL-Image, not preprocessed.

Returns:

Preprocessed and corrected image as torch.Tensor[1xHxWxC].

extract_featuremaps(image_batch: Tensor) list

Extract list of featuremaps where first is finest and last is coarsest.

Parameters:

image_batch – [BxHxWxC] Tensor.

Returns:

List of self.num_levels featuremaps as torch.Tensor[HxWxC] on device.

forward(pil_img: <module 'PIL.Image' from '/home/shaoliu/anaconda3/envs/limap/lib/python3.9/site-packages/PIL/Image.py'>)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class limap.features.extractors.GrayscaleExtractor(device: str, *args, **kwargs)

Bases: Extractor

adapt_image(pil_img: <module 'PIL.Image' from '/home/shaoliu/anaconda3/envs/limap/lib/python3.9/site-packages/PIL/Image.py'>) Tensor

Preprocess images. The output is later forwarded to extract_featuremaps.

Parameters:

pil_img – RGB PIL-Image, not preprocessed.

Returns:

Preprocessed and corrected image as torch.Tensor[1xHxWxC].

extract_featuremaps(image_batch: Tensor) list

Extract list of featuremaps where first is finest and last is coarsest.

Parameters:

image_batch – [BxHxWxC] Tensor.

Returns:

List of self.num_levels featuremaps as torch.Tensor[HxWxC] on device.

training: bool
class limap.features.extractors.ImageExtractor(device: str, *args, **kwargs)

Bases: Extractor

adapt_image(pil_img: <module 'PIL.Image' from '/home/shaoliu/anaconda3/envs/limap/lib/python3.9/site-packages/PIL/Image.py'>) Tensor

Preprocess images. The output is later forwarded to extract_featuremaps.

Parameters:

pil_img – RGB PIL-Image, not preprocessed.

Returns:

Preprocessed and corrected image as torch.Tensor[1xHxWxC].

extract_featuremaps(image_batch: Tensor) list

Extract list of featuremaps where first is finest and last is coarsest.

Parameters:

image_batch – [BxHxWxC] Tensor.

Returns:

List of self.num_levels featuremaps as torch.Tensor[HxWxC] on device.

training: bool
class limap.features.extractors.S2DNetExtractor(device: str, *args, **kwargs)

Bases: Extractor

adapt_image(pil_img: <module 'PIL.Image' from '/home/shaoliu/anaconda3/envs/limap/lib/python3.9/site-packages/PIL/Image.py'>) Tensor

Preprocess images. The output is later forwarded to extract_featuremaps.

Parameters:

pil_img – RGB PIL-Image, not preprocessed.

Returns:

Preprocessed and corrected image as torch.Tensor[1xHxWxC].

extract_featuremaps(image_batch: Tensor) list

Extract list of featuremaps where first is finest and last is coarsest.

Parameters:

image_batch – [BxHxWxC] Tensor.

Returns:

List of self.num_levels featuremaps as torch.Tensor[HxWxC] on device.

training: bool
class limap.features.extractors.VGGNetExtractor(device: str, *args, **kwargs)

Bases: Extractor

adapt_image(pil_img: <module 'PIL.Image' from '/home/shaoliu/anaconda3/envs/limap/lib/python3.9/site-packages/PIL/Image.py'>) Tensor

Preprocess images. The output is later forwarded to extract_featuremaps.

Parameters:

pil_img – RGB PIL-Image, not preprocessed.

Returns:

Preprocessed and corrected image as torch.Tensor[1xHxWxC].

extract_featuremaps(image_batch: Tensor) list

Extract list of featuremaps where first is finest and last is coarsest.

Parameters:

image_batch – [BxHxWxC] Tensor.

Returns:

List of self.num_levels featuremaps as torch.Tensor[HxWxC] on device.

training: bool
limap.features.extractors.load_extractor(extractor_name: str, device: str, *args, **kwargs) Extractor

Load extractor by name onto device.

Parameters:
  • extractor_name – Name of extractor.

  • device – Device where extractor should be loaded on.

Returns:

Extractor model

Return type:

Extractor

Raises:

NotImplementedError – When no extractor matching extractor_name is found.

Module contents