本文介绍了Caffe,如何为一组图像运行classify.py.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux上成功安装了Caffe。然后我没能使它与Matlab一起工作。所以我按照。但是,在我运行命令python python / classify.py --print_results examples / images / cat.jpg foo之前,我从未使用过Python。

I installed Caffe on Linux successfully. Then I failed to make it work with Matlab. So I installed it with Python following the tutorial of Pete Warden. However, I never used Python before I just run the command "python python/classify.py --print_results examples/images/cat.jpg foo" and it works.

我的问题是我如何测试 calssify.py 来设置图像而不是单个图像?我试图从测试目录中读取图像,如下所示

My question is how can I test calssify.py for a set images rather than a single image? I tried to read images from test directory as following

cd caffe
Python
Import os
For file in os.listdir("example/images"):
     python/classify.py --print_results os.path.join("examples/images/",file) foo

但每次都会返回

我只是在Matlab中直观地工作。在使用之前我是否需要编译 classify.py ?论证的通过是否正确?

I just work intuitively as in Matlab. Do I need to compile classify.py before using it? Is the passage of arguments correct?

提前谢谢。

推荐答案

好吧,这适用于目录中的文件

well, this works for files in a dir

mypath = './'
files = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
for f in files:
    print join(mypath,f)

所以也许你应该修改你的东西,比如

so perhaps you should modify yours to something like

import os
from os.path import isfile, join

mypath = './example/images/'
files = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
for f in files:
    cmd = "python python/classify.py --print_results %s foo" % join(mypath,f)
    os.system(cmd)

这篇关于Caffe,如何为一组图像运行classify.py.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 11:51