# ImageRetrieval **Repository Path**: benjiaxu/ImageRetrieval ## Basic Information - **Project Name**: ImageRetrieval - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-03 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Unipower Image Retrieval Engine Based on Keras ```python In [1]: import keras Using Theano backend. ``` ### 使用 - 步骤一 `python index.py -database -index ` - 步骤二 `python query_online.py -query -index -result ` ```sh ├── database 图像数据集 ├── extract_cnn_vgg16_keras.py 使用预训练vgg16模型提取图像特征 |── index.py 对图像集提取特征,建立索引 ├── query_online.py 库内搜索 └── README.md ``` #### 示例 ```sh # 对database文件夹内图片进行特征提取,建立索引文件featureCNN.h5 python index.py -database database -index featureCNN.h5 # 使用database文件夹内001_accordion_image_0001.jpg作为测试图片,在database内以featureCNN.h5进行近似图片查找,并显示最近似的3张图片 python query_online.py -query database/001_accordion_image_0001.jpg -index featureCNN.h5 -result database ``` #### Flask Web Restful 接口 ```python python web_restful.py ``` 修复因为第一次加载model提取特征再次请求导致GPU OOM问题 ```python model = VGGNet() q_vector = model.extract_feat(im_file) clear_session() tf.reset_default_graph() ``` 没法并发测试,修复并发测试跑一张图占满整个GPU问题 ```python config = tf.ConfigProto() config.gpu_options.per_process_gpu_memory_fraction = 0.1 # 占用GPU10%的显存 session = tf.Session(config=config) ``` 使用gunicore代理服务,提高服务并发能力 `gunicorn -w 4 -b 0.0.0.0:9393 web_restful:app` #### 相关资料 ##### 图像特征提取算法 常用的图像特征提取算法有 `SIFT`, `SURF`, `CNN` `HOG`特征,`LBP`特征,`Haar`特征 ##### 特征矩阵相似度的计算方法 计算两个特征矩阵之间的余弦相似度。 高维数据的快速最近邻算法FLANN,构造kd Tree。优先搜索k-means树算法,层次聚类树, 设计高可用的哈希算法,把高维矩阵映射到哈希值上,LSH(Locality Sensitive Hashing)局部敏感哈希算法 https://blog.csdn.net/jinxueliu31/article/details/37768995 https://blog.csdn.net/wonner_/article/details/80985727 https://blog.csdn.net/guoziqing506/article/details/53019049 https://waltyou.github.io/Faiss-In-Project/