Skip to content

woctezuma/feature-matcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎯 Feature Matcher

This repository contains Python code to match representation vectors, using cosine similarity.

Requirements

  • Install the latest version of Python 3.X.
  • Install the required packages:
pip install -r requirements.txt

Usage

Run:

!python match_fts.py \
 --input_dir features \
 --feature_filename fts.npy \
 --output_dir matches \
 --numpy_matches matches.npy \
 --numpy_similarity_scores scores.npy \
 --num_neighbors 10

The following files will be saved in the --output_dir folder:

  • matches.npy: the matched indices (as np.uint32) in a NumPy file,
  • scores.npy: the similarity scores (as np.float16) in a NumPy file.

Example

For instance, to match features for images in the balloon dataset:

%cd /content
!git clone https://github.com/woctezuma/feature-extractor.git
%cd feature-extractor
%pip install --quiet -r requirements.txt

!wget https://github.com/matterport/Mask_RCNN/releases/download/v2.1/balloon_dataset.zip
!unzip -q balloon_dataset.zip

!python extract_fts.py --data_dir balloon

%cd /content
!git clone https://github.com/woctezuma/feature-matcher.git
%cd feature-matcher
%pip install --quiet -r requirements.txt

!python match_fts.py --input_dir /content/feature-extractor/features

References