代码拉取完成,页面将自动刷新
#coding=utf-8
import numpy as np
import sys,os
import caffe
net_file='deploy.prototxt'
caffe_model='bvlc_googlenet_iter_175750.caffemodel'
mean_file='AVA1_mean.npy'
#if you have no GPUs,set mode cpu
caffe.set_mode_cpu()
net = caffe.Net(net_file,caffe_model,caffe.TEST)
transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
transformer.set_transpose('data', (2,0,1))
transformer.set_mean('data', np.load(mean_file).mean(1).mean(1))
transformer.set_raw_scale('data', 255)
transformer.set_channel_swap('data', (2,1,0))
img = caffe.io.load_image('good01.jpg')
net.blobs['data'].data[...] = transformer.preprocess('data',img)
out = net.forward()
out1 = out["loss1/loss"][0]
print(out1)
print ("the score of the picture is:" + str(out1[1]))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。