vocabtree  0.0.1
compute_index_simple.cxx File Reference
#include "tests_config.hpp"
#include <utils/filesystem.hpp>
#include <utils/numerics.hpp>
#include <utils/dataset.hpp>
#include <utils/vision.hpp>
#include <utils/logger.hpp>
#include <search/bag_of_words/bag_of_words.hpp>
#include <search/inverted_index/inverted_index.hpp>
#include <iostream>
Include dependency graph for compute_index_simple.cxx:

Go to the source code of this file.

Functions

_INITIALIZE_EASYLOGGINGPP int main (int argc, char *argv[])
 

Function Documentation

_INITIALIZE_EASYLOGGINGPP int main ( int  argc,
char *  argv[] 
)

Definition at line 22 of file compute_index_simple.cxx.

References filesystem::create_file_directory(), Dataset::location(), s_oxfordmini_data_dir, s_oxfordmini_database_location, and InvertedIndex::train().

22  {
23 #if ENABLE_MULTITHREADING && ENABLE_MPI
24  MPI::Init(argc, argv);
25  int rank = MPI::COMM_WORLD.Get_rank();
26  if(rank == 0) {
27 #endif
28  const uint32_t num_clusters = 512;
29 
31  LINFO << simple_dataset;
32 
33  std::stringstream vocab_output_file;
34  vocab_output_file << simple_dataset.location() << "/vocabulary/" << num_clusters << ".vocab";
35 
36  std::shared_ptr<BagOfWords> bow = std::make_shared<BagOfWords>(vocab_output_file.str());
37 
38  InvertedIndex ii;
39  std::shared_ptr<InvertedIndex::TrainParams> train_params = std::make_shared<InvertedIndex::TrainParams>();
40  train_params->bag_of_words = bow;
41  ii.train(simple_dataset, train_params, simple_dataset.all_images());
42 
43  std::stringstream index_output_file;
44  index_output_file << simple_dataset.location() << "/index/" << num_clusters << ".index";
45  filesystem::create_file_directory(index_output_file.str());
46  ii.save(index_output_file.str());
47 #if ENABLE_MULTITHREADING && ENABLE_MPI
48  }
49  MPI::Finalize();
50 #endif
51  return 0;
52 }