linux 终端无法显示图片
2015-05-06 16:05
441 查看
由于是使用的终端,plt.plot函数不能用,采用的思路是不显示图像,直接保存要显示的图像。(红色字体为实现代码)
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# Make sure that caffe is on the python path:
caffe_root = '/public/home/zhkfu/zhkfu/caffe-master/' # this file is expected to be in {caffe_root}/examples
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe
# Set the right path to your model definition file, pretrained model weights,
# and the image you would like to classify.
MODEL_FILE = caffe_root + 'models/bvlc_reference_caffenet/deploy.prototxt'
PRETRAINED = caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'
IMAGE_FILE = caffe_root + 'examples/images/cat.jpg'
import os
if not os.path.isfile(PRETRAINED):
print("Downloading pre-trained CaffeNet model...")
caffe.set_mode_cpu()
net = caffe.Classifier(MODEL_FILE, PRETRAINED,
mean=np.load(caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1).mean(1),
channel_swap=(2,1,0),
raw_scale=255,
image_dims=(256, 256))
input_image = caffe.io.load_image(IMAGE_FILE)
#plt.imshow(input_image)
prediction = net.predict([input_image]) # predict takes any number of images, and formats them for the Caffe net automatically
plt.plot(prediction[0])
plt.savefig("prediction.png")
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# Make sure that caffe is on the python path:
caffe_root = '/public/home/zhkfu/zhkfu/caffe-master/' # this file is expected to be in {caffe_root}/examples
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe
# Set the right path to your model definition file, pretrained model weights,
# and the image you would like to classify.
MODEL_FILE = caffe_root + 'models/bvlc_reference_caffenet/deploy.prototxt'
PRETRAINED = caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'
IMAGE_FILE = caffe_root + 'examples/images/cat.jpg'
import os
if not os.path.isfile(PRETRAINED):
print("Downloading pre-trained CaffeNet model...")
caffe.set_mode_cpu()
net = caffe.Classifier(MODEL_FILE, PRETRAINED,
mean=np.load(caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1).mean(1),
channel_swap=(2,1,0),
raw_scale=255,
image_dims=(256, 256))
input_image = caffe.io.load_image(IMAGE_FILE)
#plt.imshow(input_image)
prediction = net.predict([input_image]) # predict takes any number of images, and formats them for the Caffe net automatically
plt.plot(prediction[0])
plt.savefig("prediction.png")
相关文章推荐
- 图片中文水印在Linux机器下无法正常显示
- linux下php无法显示图片
- 用w3m在linux 终端中看网页成功,在文本模式下还有中文无法显示的问题没有解决,请高手赐教啊!
- linux+tomcat无法显示图片验证码
- linux+tomcat无法显示图片验证码
- Linux终端内容太多无法全部显示
- 在linux终端模式下显示JPEG格式图片(参考了其他资料)
- linux下通过C语言读取BMP格式图片,在文本终端显示该图片
- 原来linux的虚拟终端是无法显示中文的
- linux+tomcat无法显示图片验证码
- php for linux 图片无法显示问题
- linux下 php img 图片无法显示
- linux+tomcat无法显示图片验证码
- Thinkphp 在linux下无法正常显示验证码图片,该怎么解决
- Linux技巧: Linux终端打印如何设置不同的颜色及显示方式
- centos服务器上缺少字体或工作流图片中文字无法显示
- 解决网通英文wiki无法显示图片问题【20100723更新】
- 将Linux终端字符编码显示为简体中文
- Linux 下 去掉终端显示的当前目录的绝对路径
- opencv imshow 图片无法显示, 显示不全问题,只出现一部分