Skip to content

Commit 9c9f94e

Browse files
committedDec 4, 2015
Merge pull request #3395 from BonsaiAI/extract_features-compatibility
Fix compatibility issues with extract_features
2 parents 7e40583 + 99571c4 commit 9c9f94e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed
 

‎tools/extract_features.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ using caffe::Blob;
1616
using caffe::Caffe;
1717
using caffe::Datum;
1818
using caffe::Net;
19-
using boost::shared_ptr;
2019
using std::string;
2120
namespace db = caffe::db;
2221

@@ -51,7 +50,7 @@ int feature_extraction_pipeline(int argc, char** argv) {
5150
arg_pos = num_required_args;
5251
if (argc > arg_pos && strcmp(argv[arg_pos], "GPU") == 0) {
5352
LOG(ERROR)<< "Using GPU";
54-
uint device_id = 0;
53+
int device_id = 0;
5554
if (argc > arg_pos + 1) {
5655
device_id = atoi(argv[arg_pos + 1]);
5756
CHECK_GE(device_id, 0);
@@ -95,7 +94,7 @@ int feature_extraction_pipeline(int argc, char** argv) {
9594
}
9695
*/
9796
std::string feature_extraction_proto(argv[++arg_pos]);
98-
shared_ptr<Net<Dtype> > feature_extraction_net(
97+
boost::shared_ptr<Net<Dtype> > feature_extraction_net(
9998
new Net<Dtype>(feature_extraction_proto, caffe::TEST));
10099
feature_extraction_net->CopyTrainedLayersFrom(pretrained_binary_proto);
101100

@@ -119,15 +118,15 @@ int feature_extraction_pipeline(int argc, char** argv) {
119118

120119
int num_mini_batches = atoi(argv[++arg_pos]);
121120

122-
std::vector<shared_ptr<db::DB> > feature_dbs;
123-
std::vector<shared_ptr<db::Transaction> > txns;
121+
std::vector<boost::shared_ptr<db::DB> > feature_dbs;
122+
std::vector<boost::shared_ptr<db::Transaction> > txns;
124123
const char* db_type = argv[++arg_pos];
125124
for (size_t i = 0; i < num_features; ++i) {
126125
LOG(INFO)<< "Opening dataset " << dataset_names[i];
127-
shared_ptr<db::DB> db(db::GetDB(db_type));
126+
boost::shared_ptr<db::DB> db(db::GetDB(db_type));
128127
db->Open(dataset_names.at(i), db::NEW);
129128
feature_dbs.push_back(db);
130-
shared_ptr<db::Transaction> txn(db->NewTransaction());
129+
boost::shared_ptr<db::Transaction> txn(db->NewTransaction());
131130
txns.push_back(txn);
132131
}
133132

@@ -139,8 +138,8 @@ int feature_extraction_pipeline(int argc, char** argv) {
139138
for (int batch_index = 0; batch_index < num_mini_batches; ++batch_index) {
140139
feature_extraction_net->Forward(input_vec);
141140
for (int i = 0; i < num_features; ++i) {
142-
const shared_ptr<Blob<Dtype> > feature_blob = feature_extraction_net
143-
->blob_by_name(blob_names[i]);
141+
const boost::shared_ptr<Blob<Dtype> > feature_blob =
142+
feature_extraction_net->blob_by_name(blob_names[i]);
144143
int batch_size = feature_blob->num();
145144
int dim_features = feature_blob->count() / batch_size;
146145
const Dtype* feature_blob_data;

0 commit comments

Comments
 (0)
Please sign in to comment.