Reputation: 674
I want to run the test on image and detect the image and return the result, but I am facing the following issue:
ubuntu@ip-172-31-6-58:~/caffe$ python python/classify.py --print_results examples/images/cat.jpg fo
usage: classify.py [-h] [--model_def MODEL_DEF]
[--pretrained_model PRETRAINED_MODEL] [--gpu]
[--center_only] [--images_dim IMAGES_DIM]
[--mean_file MEAN_FILE] [--input_scale INPUT_SCALE]
[--raw_scale RAW_SCALE] [--channel_swap CHANNEL_SWAP]
[--ext EXT]
input_file output_file
classify.py: error: unrecognized arguments: --print_results
ubuntu@ip-172-31-6-58:~/caffe$
Upvotes: 0
Views: 1073
Reputation: 341
Is there any other tutorial where i can get the right answer ?
Ye, this argument was in another tutorials. You can add this argument to classify.py from here: https://github.com/jetpacapp/caffe/blob/master/python/classify.py#L93
parser.add_argument(
"--print_results",
action='store_true',
help="Write output text to stdout rather than serializing to a file."
)
And you need add handler to view results from here: https://github.com/jetpacapp/caffe/blob/master/python/classify.py#L142
if args.print_results:
with open(args.labels_file) as f:
labels_df = pd.DataFrame([
{
'synset_id': l.strip().split(' ')[0],
'name': ' '.join(l.strip().split(' ')[1:]).split(',')[0]
}
for l in f.readlines()
])
labels = labels_df.sort('synset_id')['name'].values
indices = (-scores).argsort()[:5]
predictions = labels[indices]
meta = [
(p, '%.5f' % scores[i])
for i, p in zip(indices, predictions)
]
print meta
this code output data results with tags
P.S. I copied the code parts for best view
Upvotes: 1
Reputation: 5897
As you can see in the classify.py
script, there is no --print_results
option: https://github.com/BVLC/caffe/blob/master/python/classify.py
Also, you are not passing the required arguments, which are the input_file
and the output_file
. Maybe what you are looking for is the output_file
that will write the predictions to a file.
Upvotes: 1