没有界面faster-rcnn 跑demo.py

来源:互联网 发布:商场广播软件 编辑:程序博客网 时间:2024/04/30 09:41

http://blog.csdn.net/jiajunlee/article/details/50373815 这个博客解决了 编译cd$FRCN_ROOT/lib/ && make   找不到文件的问题。

往往caffe环境都是在Linux服务器,或者远程登录,faster-rcnn的demo.py不能显示,运行会出现错误。

将demo.py做以下修改:

1   刚开始加入两行

import _init_paths
import matplotlib
matplotlib.use('Agg')

from fast_rcnn.config import cfg
from fast_rcnn.test import im_detect
from fast_rcnn.nms_wrapper import nms
from utils.timer import Timer
import matplotlib.pyplot as plt
import numpy as np
import scipy.io as sio
import caffe, os, sys, cv2
import argparse



2  在显示函数vis_detections加入一行保存文件,方便下载下载看

def vis_detections(im, class_name, dets, thresh=0.5):

         .................

          plt.savefig("/home/yourname/picFaster.jpg")



然后运行  ~/fastercnn/py-faster-rcnn$ ./tools/demo.py

就成运行成功了。


但是这个demo总共有5个文件

    im_names = ['000456.jpg', '000542.jpg', '001150.jpg',
                '001763.jpg', '004545.jpg']

所以后面的结果图会覆盖前面的结果图。

可以修改检测图的个数来解决。

0 1