Skip to content

[WACV 2024] BALF: Simple and Efficient Blur Aware Local Feature Detector

License

Notifications You must be signed in to change notification settings

ericzzj1989/BALF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5afc64b · Mar 10, 2025

History

54 Commits
Mar 10, 2025
Mar 10, 2025
Mar 10, 2025
Mar 10, 2025
Mar 10, 2025
Sep 3, 2024
Mar 10, 2025
Sep 3, 2024
Mar 10, 2025

Repository files navigation

BALF
Simple and Efficient Blur Aware Local Feature Detector

WACV 2024

Zhenjun Zhao     

   

Logo
BALF is able to detect well localized and repeatable keypoints from both sharp and blurred images.

Installation

Install this repo using pip:

git clone https://github.com/ericzzj1989/BALF.git && cd BALF
python -m pip install -e .

Demo

Below we show how BALF, in combination with HardNet, can be used for feature extraction and matching on an image pair. You can also refer to the demo for more details.

from balf.utils import test_utils
from balf.configs import config
from balf.model import get_model
from demo import demo_match
from third_party.hardnet.hardnet_pytorch import HardNet

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
args, cfg = config.parse_test_config()

detector = get_model.load_model(cfg['model'])
_,_ = get_model.load_test_pretrained_model(model=detector, filename=args.ckpt_file)
detector = detector.eval().to(device)

descriptor = HardNet()
checkpoint_descriptor = torch.load(args.ckpt_descriptor_file, weights_only=True)
descriptor.load_state_dict(checkpoint_descriptor['state_dict'])
descriptor = descriptor.eval().to(device)

im_rgb1, im_gray1 = demo_match.load_im('media/im1.jpg')
im_rgb2, im_gray2 = demo_match.load_im('media/im2.jpg')

matches1, matches2 = demo_match.extract_matches(
  args,
  im_rgb1, im_gray1, im_rgb2, im_gray2,
  detector, descriptor, device)

Image.fromarray(demo_match.draw_matches(im_rgb1, matches1, im_rgb2, matches2)).save("demo/matches.png")

Training BALF

To train BALF, refer to train.py in balf.

Pretrained Models

Pretrained models are available here.

Acknowledgments

The author thanks Peidong Liu and Ben M. Chen for supporting.

Citation

If you find this code or paper useful, please cite:

@InProceedings{Zhao_2024_WACV,
    author    = {Zhao, Zhenjun},
    title     = {BALF: Simple and Efficient Blur Aware Local Feature Detector},
    booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV)},
    month     = {January},
    year      = {2024},
    pages     = {3362-3372}
}

Contact

Contact Zhenjun Zhao for questions, comments and reporting bugs.