53int entry(
const int argc,
char **argv)
59 arser.add_argument(
"--first_model").required(
true).help(
"First input model filepath");
61 arser.add_argument(
"--second_model").required(
true).help(
"Second input model filepath");
63 arser.add_argument(
"--first_input_data")
64 .help(
"Input data filepath for the first model. If not given, circle-eval-diff will run with "
65 "randomly generated data");
67 arser.add_argument(
"--second_input_data")
68 .help(
"Input data filepath for the second model. If not given, circle-eval-diff will run with "
69 "randomly generated data");
71 arser.add_argument(
"--dump_output_with_prefix")
72 .help(
"Dump output to files. <prefix> should be given as an argument. "
73 "Outputs are saved in <prefix>.<data_index>.first.output<output_index> and "
74 "<prefix>.<data_index>.second.output<output_index>.");
76 arser.add_argument(
"--print_mae").nargs(0).default_value(
false).help(
"Print Mean Absolute Error");
78 arser.add_argument(
"--print_mape")
81 .help(
"Print Mean Absolute PercentageError");
83 arser.add_argument(
"--print_mpeir")
86 .help(
"Print Mean Peak Error to Interval Ratio");
88 arser.add_argument(
"--print_top1_match")
91 .help(
"Print Mean Top-1 Match Ratio");
93 arser.add_argument(
"--print_top5_match")
96 .help(
"Print Mean Top-5 Match Ratio");
98 arser.add_argument(
"--print_mse").nargs(0).default_value(
false).help(
"Print Mean Squared Error");
100 arser.add_argument(
"--input_data_format")
102 .help(
"Input data format. h5/hdf5 (default) or directory");
106 arser.parse(argc, argv);
108 catch (
const std::runtime_error &err)
110 std::cout << err.what() << std::endl;
115 const auto first_model_path =
arser.get<std::string>(
"--first_model");
116 const auto second_model_path =
arser.get<std::string>(
"--second_model");
119 std::string first_input_data_path;
120 std::string second_input_data_path;
122 std::string input_data_format;
123 std::string output_prefix;
125 if (
arser[
"--first_input_data"])
126 first_input_data_path =
arser.get<std::string>(
"--first_input_data");
128 if (
arser[
"--second_input_data"])
129 second_input_data_path =
arser.get<std::string>(
"--second_input_data");
131 if (
arser[
"--first_input_data"] !=
arser[
"--second_input_data"])
132 throw std::runtime_error(
"Input data path should be given for both first_model and "
133 "second_model, or neither must be given.");
135 if (
arser[
"--dump_output_with_prefix"])
136 output_prefix =
arser.get<std::string>(
"--dump_output_with_prefix");
139 std::vector<Metric> metrics;
140 if (
arser[
"--print_mae"] and
arser.get<
bool>(
"--print_mae"))
142 metrics.emplace_back(Metric::MAE);
144 if (
arser[
"--print_mape"] and
arser.get<
bool>(
"--print_mape"))
146 metrics.emplace_back(Metric::MAPE);
148 if (
arser[
"--print_mpeir"] and
arser.get<
bool>(
"--print_mpeir"))
150 metrics.emplace_back(Metric::MPEIR);
152 if (
arser[
"--print_top1_match"] and
arser.get<
bool>(
"--print_top1_match"))
154 metrics.emplace_back(Metric::MTOP1);
156 if (
arser[
"--print_top5_match"] and
arser.get<
bool>(
"--print_top5_match"))
158 metrics.emplace_back(Metric::MTOP5);
160 if (
arser[
"--print_mse"] and
arser.get<
bool>(
"--print_mse"))
162 metrics.emplace_back(Metric::MSE);
165 input_data_format =
arser.get<std::string>(
"--input_data_format");
167 auto ctx = std::make_unique<CircleEvalDiff::Context>();
169 ctx->first_model_path = first_model_path;
170 ctx->second_model_path = second_model_path;
171 ctx->first_input_data_path = first_input_data_path;
172 ctx->second_input_data_path = second_input_data_path;
173 ctx->metric = metrics;
174 ctx->input_format = to_input_format(input_data_format);
175 ctx->output_prefix = output_prefix;