zoukankan      html  css  js  c++  java
  • 构建应用深层特征的图像检索系统

    这里写图片描述

    这里写图片描述

    从GraphLab Create 库里面导入一个深度学习的模型

    deep_learning_model=graphlab.load_model('http://s3.amazonaws.com/GraphLab-Datasets/deeplearning/imagenet_model_iter45')

    接着,利用deep_learning_model从我们定义的image_train中去抽取深度特征

    deep_learning_model.extract_features(image_train)

    执行完毕之后,
    这里写图片描述

    我们的深层特征也是给求出来了

    knn_model=graphlab.nearest_neighbors.create(image_train,features=['deep_features'],label='id')

    这里写图片描述

    通过运用深度特征的图像检索模型找到相似图像
    这里写图片描述

    这里写图片描述

    这里写图片描述

    这里写图片描述

    这里写图片描述

    这里写图片描述

    这里写图片描述

    通过运用深度特征的图像检索模型找到相似图像¶
    In [8]:
    
    cat =image_train[18:19]
    In [14]:
    
    graphlab.canvas.set_target('browser')
    In [15]:
    
    cat['image'].show()
    Canvas is accessible via web browser at the URL: http://localhost:55693/index.html
    Opening Canvas in default web browser.
    In [11]:
    
    cat['image'].show()
    开始检索
    In [17]:
    
    knn_model.query(cat)
    knn_model.query(cat)
    Starting pairwise querying.
    +--------------+---------+-------------+--------------+
    | Query points | # Pairs | % Complete. | Elapsed Time |
    +--------------+---------+-------------+--------------+
    | 0            | 1       | 0.0498753   | 127.073ms    |
    | Done         |         | 100         | 311.842ms    |
    +--------------+---------+-------------+--------------+
    Out[17]:
    query_label	reference_label	distance	rank
    0	384	0.0	1
    0	6910	36.9403137951	2
    0	39777	38.4634888975	3
    0	36870	39.7559623119	4
    0	41734	39.7866014148	5
    [5 rows x 4 columns]
    通过 reference_label关联id得到images
    In [18]:
    
    def get_images_from_id (query_result):
        return image_train.filter_by(query_result['reference_label'],'id')
    通过上面的函数得到猫的邻居
    In [19]:
    
    cat_neighbors
    cat_neighbors=get_images_from_id(knn_model.query(cat))
    Starting pairwise querying.
    +--------------+---------+-------------+--------------+
    | Query points | # Pairs | % Complete. | Elapsed Time |
    +--------------+---------+-------------+--------------+
    | 0            | 1       | 0.0498753   | 18.013ms     |
    | Done         |         | 100         | 241.681ms    |
    +--------------+---------+-------------+--------------+
    In [20]:
    
    cat_neighbors['image'].show()
    ​
    Canvas is updated and available in a tab in the default browser.
    

    接下来找到和红色小轿车相似的图像

    这里写图片描述

    这里写图片描述

    这里写图片描述

    这里写图片描述

    代码:

    car=image_train[8:9]
    car['image'].show()
    get_images_from_id(knn_model.query(car))['image'].show()
    

    构建一个lambda函数来方便寻找

    返回image的函数

    def get_images_from_id (query_result):
        return image_train.filter_by(query_result['reference_label'],'id')
    

    show_neighbors=lambda x: get_images_from_id(knn_model.query(image_train[x:x+1]))['image'].show()

    这里写图片描述

    这里写图片描述

  • 相关阅读:
    HTML5和CSS3的学习视频
    webpack中bundler源码编写2
    webpack中bundler源码编写
    webpack中如何编写一个plugin
    webpack多页面打包配置
    webpack中配置eslint
    webpack解决单页面路由问题
    webpack中使用WebpackDevServer实现请求转发
    webpack中typeScript的打包配置
    rsync 同步
  • 原文地址:https://www.cnblogs.com/liuge36/p/9882957.html
Copyright © 2011-2022 走看看