-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change loading behaviour when annotation is None * feature extractor puts model back to cpu * add parameter for silent tqdm * fix nan in bbox and segmetnation * Loading bboxes fixed * Segmentation can be polygon * Added mask_crop to image loading * improve loading methods * Support for loading uncompressed RLE * Merge readme (#12) * Update README.md * Update README.md * Update README.md * Update README.md * Readme updated --------- Co-authored-by: sadda <lukas.adam.cr@gmail.com> * Wildfusion (#14) * add refactored nn classifiers * refactor pairwise matching similarity * add wildfusion * delete optim * merge from origin * fix imports * update docs * cleanup * cleanup * chore: formatting * chore: change naming * chore: formatting * chore: black formatting * chore: formatting isort * add visualisation tools * fix: examples consistency * examples: update * docs: fix imports in examples * chore: formatting * chore: update readme * chore: update readme --------- Co-authored-by: sadda <lukas.adam.cr@gmail.com>
- Loading branch information
1 parent
2db0cb4
commit f5fd69e
Showing
68 changed files
with
5,023 additions
and
3,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,46 @@ | ||
# Feature extraction | ||
Feature extractors offers a standardized way to extract features from instances of the `WildlifeDataset`. | ||
|
||
Feature extractors, implemented as classes, can be created with specific arguments that define the extraction properties. After instantiation, the extractor functions as a callable, requiring only a single argument—the `WildlifeDataset` instance. The specific output type and shape vary based on the chosen feature extractor. In general, the output is iterable, with the first dimension corresponding to the size of the `WildlifeDataset` input. | ||
Feature extractors, implemented as classes, can be created with specific arguments that define the extraction properties. After instantiation, the extractor functions as a callable, requiring only a single argument—the `WildlifeDataset` instance. The specific output type and shape vary based on the chosen feature extractor. Output is `FeatureDataset` instance. | ||
|
||
## Deep features | ||
|
||
::: features.deep | ||
options: | ||
show_root_heading: true | ||
heading_level: 2 | ||
|
||
The `DeepFeatures` extractor operates by extracting features through the forward pass of a PyTorch model. The output is a 2D array, where the rows represent images, and the columns correspond to the embedding dimensions. The size of the columns is determined by the output size of the model performing the feature extraction. | ||
|
||
### Example | ||
The term `dataset` refers to any instance of WildlifeDataset with transforms that convert it into a tensor with the appropriate shape. | ||
|
||
```Python | ||
import timm | ||
from wildlife_tools.features import DeepFeatures | ||
::: features.local | ||
options: | ||
show_root_heading: true | ||
heading_level: 2 | ||
|
||
backbone = timm.create_model('hf-hub:BVRA/MegaDescriptor-T-224', num_classes=0, pretrained=True) | ||
extractor = DeepFeatures(backbone, device='cuda') | ||
features = extractor(dataset) | ||
``` | ||
|
||
### Reference | ||
::: features.deep.DeepFeatures | ||
::: features.memory | ||
options: | ||
show_symbol_type_heading: false | ||
show_bases: false | ||
show_root_toc_entry: false | ||
|
||
show_root_heading: true | ||
heading_level: 2 | ||
|
||
|
||
## SIFT features | ||
The `SIFTFeatures` extractor retrieves a set of SIFT descriptors for each provided image. The output is a list with a length of `n_inputs`, containing arrays. These arrays are 2D with a shape of `n_descriptors` x `128`, where the value of `n_descriptors` depends on the number of SIFT descriptors extracted for the specific image. If one or less descriptors are extracted, the value is None. The SIFT implementation from OpenCV is used. | ||
## Examples | ||
|
||
### Example | ||
The term `dataset` refers to any instance of WildlifeDataset with transforms that convert it into grayscale PIL image. | ||
### Example - SuperPoint features | ||
|
||
```Python | ||
from wildlife_tools.features import SIFTFeatures | ||
from wildlife_tools.features.local import SuperPointExtractor | ||
|
||
extractor = SIFTFeatures() | ||
extractor = SuperPointExtractor(backend='opencv', detection_threshold=0.0, force_num_keypoints=True, max_num_keypoints=256) | ||
features = extractor(dataset) | ||
``` | ||
|
||
|
||
### Reference | ||
::: features.sift.SIFTFeatures | ||
options: | ||
show_symbol_type_heading: false | ||
show_bases: false | ||
show_root_toc_entry: false | ||
|
||
|
||
### Example - Deep features | ||
|
||
## Data to memory | ||
|
||
The `DataToMemory` extractor loads the `WildlifeDataset` into memory. This is particularly usefull for the `LoftrMatcher`, which operates directly with image tensors. While it is feasible to directly use the `WildlifeDataset` and load images from storage dynamically, the `LoftrMatcher` lacks a loading buffer. Consequently, loading images on the fly could become a significant bottleneck, especially when matching all query-database pairs, involving `n_query` x `n_database` image loads. | ||
```Python | ||
import timm | ||
from wildlife_tools.features.deep import DeepFeatures | ||
|
||
::: features.memory.DataToMemory | ||
options: | ||
show_symbol_type_heading: false | ||
show_bases: false | ||
show_root_toc_entry: false | ||
backbone = timm.create_model('hf-hub:BVRA/MegaDescriptor-T-224', num_classes=0, pretrained=True) | ||
extractor = DeepFeatures(backbone, device='cuda') | ||
features = extractor(dataset) | ||
``` |
Oops, something went wrong.