HF-Net是用来重定位的,也就是来一个查询帧query,去数据库中查找与哪一个图像匹配。

项目地址:https://github.com/ethz-asl/hfnet

环境配置

  • 首先作者提供了一个训练好的模型可供下载
  • 下载很慢,我提供个百度云,提取码: qiis
  • 下载下来后放到saved_models目录下即可
  • 要求的tensorflow版本是1.12
  • 而且cudnn必须是7.1.4,这是运行是报错时提示的
  • CUDA的版本9.0就好

Demo脚本


# coding: utf-8# In[ ]:import cv2
import numpy as np
from pathlib import Path
import picklefrom hfnet.settings import EXPER_PATH
from notebooks.utils import plot_images, plot_matches, add_frameimport tensorflow as tf
from tensorflow.python.saved_model import tag_constants
import tf.contrib.resampler  # import C++ op  !!这一行不能删除# # Load query (night) and database (day) images# In[2]:query_idx = 1  # also try with 2 and3
read_image = lambda n: cv2.imread('./doc/demo/' + n)[:, :, ::-1]
image_query = read_image(f'query{query_idx}.jpg')
images_db = [read_image(f'db{i}.jpg') for i in range(1, 5)]plot_images([image_query] + images_db, dpi=50)# # Create HF-Net model for inference# In[ ]:class HFNet:def __init__(self, model_path, outputs):self.session = tf.Session()self.image_ph = tf.placeholder(tf.float32, shape=(None, None, 3))net_input = tf.image.rgb_to_grayscale(self.image_ph[None])tf.saved_model.loader.load(self.session, [tag_constants.SERVING], str(model_path),clear_devices=True,input_map={'image:0': net_input})graph = tf.get_default_graph()self.outputs = {n: graph.get_tensor_by_name(n+':0')[0] for n in outputs}self.nms_radius_op = graph.get_tensor_by_name('pred/simple_nms/radius:0')self.num_keypoints_op = graph.get_tensor_by_name('pred/top_k_keypoints/k:0')def inference(self, image, nms_radius=4, num_keypoints=1000):inputs = {self.image_ph: image[..., ::-1].astype(np.float),self.nms_radius_op: nms_radius,self.num_keypoints_op: num_keypoints,}return self.session.run(self.outputs, feed_dict=inputs)model_path = Path(EXPER_PATH, 'saved_models/hfnet')
outputs = ['global_descriptor', 'keypoints', 'local_descriptors']
hfnet = HFNet(model_path, outputs)# # Compute global descriptors and local features for query and database
# In[4]:db = [hfnet.inference(i) for i in images_db]
global_index = np.stack([d['global_descriptor'] for d in db])
query = hfnet.inference(image_query)# # Perform a global search in the database
# In[5]:def compute_distance(desc1, desc2):# For normalized descriptors, computing the distance is a simple matrix multiplication.return 2 * (1 - desc1 @ desc2.T)# In[6]:nearest = np.argmin(compute_distance(query['global_descriptor'], global_index))
disp_db = [add_frame(im, (0, 255, 0)) if i == nearest else imfor i, im in enumerate(images_db)]
plot_images([image_query] + disp_db, dpi=50)# # Perform local matching with the retrieved image# In[7]:def match_with_ratio_test(desc1, desc2, thresh):dist = compute_distance(desc1, desc2)print(dist.shape)nearest = np.argpartition(dist, 2, axis=-1)[:, :2]dist_nearest = np.take_along_axis(dist, nearest, axis=-1)valid_mask = dist_nearest[:, 0] <= (thresh**2)*dist_nearest[:, 1]matches = np.stack([np.where(valid_mask)[0], nearest[valid_mask][:, 0]], 1)return matches# In[22]:matches = match_with_ratio_test(query['local_descriptors'],db[nearest]['local_descriptors'], 0.8)plot_matches(image_query, query['keypoints'],images_db[nearest], db[nearest]['keypoints'],matches, color=(0, 1, 0), dpi=50)

报错

  • 我这边召回是可以运行的,但是进行特征点匹配时,那个np.take_along_axis函数始终无法运行,应该是numpy版本问题

HF-NET使用记录相关推荐

  1. Proxmark​​​​​​​3常用命令

    1.1常用类 help 显示帮助. hw help 与 hw 是等价的. data 图形窗口/缓冲区数据操作等等 exit 退出Proxmark3的终端环境 hf 高频相关命令 hw 硬件检测相关命令 ...

  2. 【记录】python3 tkinterUI编辑器应用之索尼walkmanA35播放列表编辑工具

    tkinterUI编辑器应用(二) 前言 一.工具使用说明 二.分析播放列表文件 三.tinytag读取歌曲信息 四.treeview列表模式时点击标题进行排序 五.主文件代码,其他代码这里就不展示了 ...

  3. 浪潮HF系列闪存存储:不仅看性能,更看整体表现

    背景:浪潮HF系列闪存存储是IT融合架构的基础,可支持核心数据库业务应用.服务器和桌面虚拟化架构.消息协同环境,并适应Microsoft.VMware.Citrix.Oracle.SAP.CISCO. ...

  4. 国产安路FPGA(一)-TD软件使用及问题记录

    国产安路FPGA(一)-TD软件使用及问题记录 一.概述 本次博客为系列博客,仅是为了记录再使用国产安路各种芯片和软件使用工具上的问题以及解决方式. TD软件所使用的版本为TD5.0.5_SP1-64 ...

  5. 我今天给学习运维而英语不好的各位,提供一些计算机英语,感谢惨绿少年的原文和已经离开身边提供英标部分的小虾大佬,只是为了记录。...

    1.file,n.文件:v.保存文件 [faɪl] 2.command,n.命令,指令 [kəˈmænd] 3.use,v.使用,用途 [jus] 4.program,n.程序 [ˈproʊgræm] ...

  6. 西门子et200 分布式i/o_西门子S7-1200/1500的硬件数据记录(1)-参数数据记录

    通过使用分布式IO读指令(比如RDREC)或者写指令(比如WRREC),可以读取或写入西门子S7-1200/1500/ET200SP/ET200MP等硬件模块的数据记录.数据记录是模块硬件的固有属性, ...

  7. csr8670--不能不知道的基本知识,长期记录

    1.设备的状态 设备上电之后,系统会用相应的状态标志来描述设备的状态 Limbo:逻辑上关,物理上开,可以理解为手机安装了电池但是没有开机,这个状态下是不能处理任务的,所以上电之后首先要做的就是开机 ...

  8. 实验5 基于stm32的HF高频RFID通信协议

    实验5 基于stm32的HF高频RFID通信协议 实验目的 1.1  掌握高频读卡器的通讯协议 1.2  掌握本平台高频模块的操作过程 1.3  掌握高频模块工作原理 实验设备 硬件:RFID实验箱套 ...

  9. Access VBA 代码记录

    Option Compare DatabasePrivate Sub Combo4_AfterUpdate()Dim index As StringDim county As Stringindex ...

  10. 微软收购暴雪计划遭拒/ Edge被曝泄露浏览记录/ 微信小程序可用数字人民币...今日更多新鲜事在此...

    日报君 发自 凹非寺 量子位 | 公众号 QbitAI 大家好,今天是4月27日星期四,是这个月倒数第二天上班了~ 在假期可以翘首以待的日子里,还是来和日报君看看今天的科技圈资讯吧~ 微信支持数字人民 ...

最新文章

  1. java中的数据库事务处理
  2. MATLAB基本操作(二):数组中操作
  3. 精选Spring Boot三十五道必知必会知识点!
  4. JVM-分代垃圾回收器
  5. MPMovieplayercontroller
  6. 张贤国:视频压缩还远没有达到最优
  7. Visual SourceSafe 数据库安全性简介
  8. asp.net mvc webform和razor的page基类区别
  9. 谷歌开源 Python Fire:可自动生成命令行接口
  10. 贪心——买卖股票的最佳时机(Leetcode 122)
  11. java Instrument修改字节码实现aop功能
  12. 《C程序设计语言》笔记 (三) 控制流
  13. 华为慧通和华为区别_华为P30与华为P30 pro 的区别
  14. UEFI的诞生与优势
  15. 基于华为云轻松搭建属于自己的网站 (Linux,Apache,MySQL,PHP)
  16. RocketMQ事务消息学习及刨坑过程
  17. win10配置系统默认utf-8编码
  18. Isito - Rate Limits(请求限速)- 再战
  19. 用SQLite进行全文检索
  20. win7安装office2013过程中出现 office 15 click-to-run extensibility component提示

热门文章

  1. 神经网络为什么叫神经网络,神经网络的强大之处
  2. Linux内核4.14版本——SPI NOR子系统(3)——cadence-quadspi.c分析
  3. qq空间找不到服务器或dns错误,能上QQ,打不开网页,多次修复DNS ,有时还是不行,重启一下就又好了...
  4. 各大CDN的节点IP段
  5. Unity-使用系统字体
  6. 局部刷新,例如,列表中只更新 收藏图标
  7. virtual-box及相关系统镜像文件下载
  8. VB6里判断是否64位系统
  9. 中国协作机器人行业投资潜力规划及未来发展趋势报告2021-2027年
  10. oracle安装时日志在哪,oracle 安装日志 | 学步园