]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - jacinto-ai/caffe-jacinto.git/blob - examples/test_read_imagenet.cpp
get_mnist.sh: changed the script to generate leveldb as well.
[jacinto-ai/caffe-jacinto.git] / examples / test_read_imagenet.cpp
1 // Copyright 2013 Yangqing Jia
3 #include <glog/logging.h>
4 #include <leveldb/db.h>
6 #include <string>
8 int main(int argc, char** argv) {
9   ::google::InitGoogleLogging(argv[0]);
10   leveldb::DB* db;
11   leveldb::Options options;
12   options.create_if_missing = false;
14   LOG(INFO) << "Opening leveldb " << argv[1];
15   leveldb::Status status = leveldb::DB::Open(
16       options, argv[1], &db);
17   CHECK(status.ok()) << "Failed to open leveldb " << argv[1];
19   leveldb::ReadOptions read_options;
20   read_options.fill_cache = false;
21   int count = 0;
22   leveldb::Iterator* it = db->NewIterator(read_options);
23   for (it->SeekToFirst(); it->Valid(); it->Next()) {
24     // just a dummy operation
25     LOG(ERROR) << it->key().ToString();
26     if (++count % 10000 == 0) {
27       LOG(ERROR) << "Processed " << count << " files.";
28     }
29   }
31   delete db;
32   return 0;
33 }