• caffe-ubuntu1604-gtx850m-i7-4710hq----VGG_ILSVRC_16_layers.caffemodel


     c++调用vgg16: 

    ./build/install/bin/classification    
     /media/whale/wsWin10/wsCaffe/model-zoo/VGG16//deploy.prototxt  
      /media/whale/wsWin10/wsCaffe/model-zoo/VGG16/VGG_ILSVRC_16_layers.caffemodel 
       data/ilsvrc12/imagenet_mean.binaryproto 
       /media/whale/wsWin10/wsCaffe/model-zoo/VGG16/synset_words.txt 
       /media/whale/wsWin10/images/person/2.jpg

     然后就报错了。

    然后

    whale@sea:/media/whale/wsWin10/wsUbuntu16.04/DlFrames/caffe$ ./build/install/bin/classification     /media/whale/wsWin10/wsCaffe/model-zoo/VGG16//deploy.prototxt    /media/whale/wsWin10/wsCaffe/model-zoo/VGG16/VGG_ILSVRC_16_layers.caffemodel    data/ilsvrc12/imagenet_mean.binaryproto    ./3labels.txt    /media/whale/wsWin10/images/person/2.jpg
    labels_.size() = 3 output_layer->channels()  = 3 ---------- Prediction for /media/whale/wsWin10/images/person/2.jpg ----------
    0.3333 - "1000"
    0.3333 - "2000"
    0.3333 - "3000"
    whale@sea:/media/whale/wsWin10/wsUbuntu16.04/DlFrames/caffe$ ./build/install/bin/classification     /media/whale/wsWin10/wsCaffe/model-zoo/VGG16//deploy.prototxt    /media/whale/wsWin10/wsCaffe/model-zoo/VGG16/VGG_ILSVRC_16_layers.caffemodel    data/ilsvrc12/imagenet_mean.binaryproto    ./3labels.txt    /media/whale/wsWin10/images/person/3.jpg
    labels_.size() = 3 output_layer->channels()  = 3 ---------- Prediction for /media/whale/wsWin10/images/person/3.jpg ----------
    0.3333 - "1000"
    0.3333 - "2000"
    0.3333 - "3000"

    只能给3个标签,不然就报错。然后,。。。,这个模型是假的吗?

    还是什么是假的?

    keras-python调用vgg16: 

    python-keras接口调用模型要简单些,只需要标签文件,和keras模型就可以了。

    from keras.applications.vgg16 import VGG16
    from keras.preprocessing import image
    from keras.applications.vgg16 import preprocess_input
    from keras.models import Model
    import numpy as np
    import matplotlib.pyplot as plt
    # get_ipython().magic(u'matplotlib inline')
    
    
    # ### 显示图像
    
    # In[2]:
    
    img_path = './data/elephant.jpg'
    img_path = '/media/whale/wsWin10/images/dog/0c02094a98d126cf541c4318188699a5.jpg'
    img_path = '/media/whale/wsWin10/images/dog/dd92db98b99479db3619f62c724757a4.jpg'
    
    
    img = image.load_img(img_path, target_size=(224, 224))
    
    plt.imshow(img)
    plt.show(   )
    
    
    # ### 加载VGG16模型(包含全连接层)
    
    # In[3]:
    
    model = VGG16(include_top=True, weights='imagenet')
    print(" type(model) =  ",   type(model))
    
    
    # In[4]:
    
    x = image.img_to_array(img)
    
    x = np.expand_dims(x, axis=0)
    
    x = preprocess_input(x)
    
    print( "x.max()  = ",   x.max())
    
    scores = model.predict(x)
    
    
    # In[10]:
    
    class_table = open('./data/synset_words', 'r')
    lines = class_table.readlines()
    print(" scores type: ", type(scores))
    print(" scores shape: ", scores.shape)
    print("  np.argmax(scores) = ",  np.argmax(scores))
    print('result is ', lines[np.argmax(scores)])
    class_table.close()
    
    import sys
    sys.exit()

    。。。/wsWin10/wsPycharm/sklearnStu/Keras-Tutorials/08.vgg-16.py
    Using TensorFlow backend.
    2018-01-16 17:35:28.541700: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
    2018-01-16 17:35:28.627059: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
    2018-01-16 17:35:28.627317: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: 
    name: GeForce GTX 850M major: 5 minor: 0 memoryClockRate(GHz): 0.9015
    pciBusID: 0000:01:00.0
    totalMemory: 3.95GiB freeMemory: 3.63GiB
    2018-01-16 17:35:28.627334: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 850M, pci bus id: 0000:01:00.0, compute capability: 5.0)
    (' type(model) =  ', <class 'keras.engine.training.Model'>)
    ('x.max()  = ', 151.061)
    (' scores type: ', <type 'numpy.ndarray'>)
    (' scores shape: ', (1, 1000))
    ('  np.argmax(scores) = ', 235)
    ('result is ', 'n02106662 German shepherd, German shepherd dog, German police dog, alsatian
    ')
    
    Process finished with exit code 0

    翻译下: 德国牧羊犬,德国牧羊犬,德国警犬,阿尔萨斯

  • 相关阅读:
    jQuery实现选项联动轮播
    EasyUI datagrid 行编辑
    UEditor的使用
    jQuery Pagination分页插件的使用
    SQL Server论坛楼层计算触发器
    编写了一个简单的串口映射工具
    JS表单验证插件(支持Ajax验证)
    JS虚拟键盘
    JS数字键盘
    HTML的select控件美化
  • 原文地址:https://www.cnblogs.com/leoking01/p/8277714.html
Copyright © 2020-2023  润新知