From b722e8d8d1413a1ed165965bb3c7bece55f50488 Mon Sep 17 00:00:00 2001 From: Taiga Noumi Date: Sun, 17 Jan 2016 22:50:53 +0900 Subject: [PATCH] add --without-shuffle option to create idx without shuffling #5 --- src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b29191d..9dcfb67 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -116,7 +116,7 @@ string add_prefix(const string& prefix, const string& base) return prefix.empty() ? base : prefix + "_" + base; } -void exec(const string& dir, const string& output_prefix, int num_tests, int w, int h) +void exec(const string& dir, const string& output_prefix, int num_tests, int w, int h, bool data_shuffle = true) { auto map = make_table_from_subdir_to_label(dir); vector images; @@ -130,7 +130,8 @@ void exec(const string& dir, const string& output_prefix, int num_tests, int w, } // shuffle - shuffle(images.begin(), images.end(), default_random_engine(0)); + if (data_shuffle) + shuffle(images.begin(), images.end(), default_random_engine(0)); // split train/test data if ((int)images.size() <= num_tests) @@ -160,12 +161,13 @@ int main(int argc, char *argv[]) a.add("output", 'o', "output file prefix", false); a.add("num-tests", 'n', "number of test data", false, 0); a.add("size", 's', "size of output data (WxH)", false, "32x32"); + a.add("without-shuffle", 'w', "create data without shuffling"); a.parse_check(argc, argv); try { auto size = parse_size(a.get("size")); - exec(a.get("dir"), a.get("output"), a.get("num-tests"), size.first, size.second); + exec(a.get("dir"), a.get("output"), a.get("num-tests"), size.first, size.second, !a.exist("without-shuffle")); } catch (const exception& e) { cout << "error:" << e.what() << endl;