匹配一切 match anything

目录

masa Matching Anything By Segmenting Anything

Matching Anything

github上没有代码:

示例代码:


masa Matching Anything By Segmenting Anything

https://github.com/siyuanliii/masa

Matching Anything

github上没有代码:

MatchAnything/video at main · zju3dv/MatchAnything · GitHub

https://huggingface.co/spaces/LittleFrog/MatchAnything/blob/main/requirements.txt

示例代码:

import cv2
from pathlib import Path
from imcui.hloc import logger
from imcui.ui.utils import DEVICE, get_matcher_zoo, load_config
from imcui.api import ImageMatchingAPI

ROOT = Path(__file__).parents[1]


def test_all():
    config = load_config(ROOT / "config/config.yaml")
    img_path1 = ROOT / "tests/data/02928139_3448003521.jpg"
    img_path2 = ROOT / "tests/data/17295357_9106075285.jpg"
    image0 = cv2.imread(str(img_path1))[:, :, ::-1]  # RGB
    image1 = cv2.imread(str(img_path2))[:, :, ::-1]  # RGB

    matcher_zoo_restored = get_matcher_zoo(config["matcher_zoo"])
    for k, v in matcher_zoo_restored.items():
        if image0 is None or image1 is None:
            logger.error("Error: No images found! Please upload two images.")
        enable = config["matcher_zoo"][k].get("enable", True)
        skip_ci = config["matcher_zoo"][k].get("skip_ci", False)
        if enable and not skip_ci:
            logger.info(f"Testing {k} ...")
            api = ImageMatchingAPI(conf=v, device=DEVICE)
            pred = api(image0, image1)
            assert pred is not None
            log_path = ROOT / "experiments" / "all"
            log_path.mkdir(exist_ok=True, parents=True)
            api.visualize(log_path=log_path)
        else:
            logger.info(f"Skipping {k} ...")


def test_one():
    img_path1 = ROOT / "tests/data/02928139_3448003521.jpg"
    img_path2 = ROOT / "tests/data/17295357_9106075285.jpg"

    image0 = cv2.imread(str(img_path1))[:, :, ::-1]  # RGB
    image1 = cv2.imread(str(img_path2))[:, :, ::-1]  # RGB
    # sparse
    conf = {
        "feature": {
            "output": "feats-superpoint-n4096-rmax1600",
            "model": {
                "name": "superpoint",
                "nms_radius": 3,
                "max_keypoints": 4096,
                "keypoint_threshold": 0.005,
            },
            "preprocessing": {
                "grayscale": True,
                "force_resize": True,
                "resize_max": 1600,
                "width": 640,
                "height": 480,
                "dfactor": 8,
            },
        },
        "matcher": {
            "output": "matches-NN-mutual",
            "model": {
                "name": "nearest_neighbor",
                "do_mutual_check": True,
                "match_threshold": 0.2,
            },
        },
        "dense": False,
    }
    api = ImageMatchingAPI(conf=conf, device=DEVICE)
    pred = api(image0, image1)
    assert pred is not None
    log_path = ROOT / "experiments" / "one"
    log_path.mkdir(exist_ok=True, parents=True)
    api.visualize(log_path=log_path)

    # dense
    conf = {
        "matcher": {
            "output": "matches-loftr",
            "model": {
                "name": "loftr",
                "weights": "outdoor",
                "max_keypoints": 2000,
                "match_threshold": 0.2,
            },
            "preprocessing": {
                "grayscale": True,
                "resize_max": 1024,
                "dfactor": 8,
                "width": 640,
                "height": 480,
                "force_resize": True,
            },
            "max_error": 1,
            "cell_size": 1,
        },
        "dense": True,
    }

    api = ImageMatchingAPI(conf=conf, device=DEVICE)
    pred = api(image0, image1)
    assert pred is not None
    log_path = ROOT / "experiments" / "one"
    log_path.mkdir(exist_ok=True, parents=True)
    api.visualize(log_path=log_path)


if __name__ == "__main__":
    test_one()
    test_all()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值