6int smp_mvcnn_simple(
const char*model_name,
const char* img_folder)
12 FHANDLE* hsrcs = NULL;
25 printf_s(
"lic : %d¥r¥n", ret);
29 if (NULL == hmodel) { printf_s(
"failed to create handle¥r¥n"); }
30 else { printf_s(
"handle created¥r¥n"); }
34 printf_s(
"load: %d¥r¥n", ret);
38 printf_s(
"par : %d category=%d¥r¥n", ret, model_category);
39 if (
MULTI_VIEW_CNN != model_category) { printf_s(
"unmatch model"); }
43 printf_s(
"par : %d ch=%d w=%d h=%d¥r¥n", ret, ch, w, h);
47 printf_s(
"# of views=%d", n_views);
50 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
53 printf_s(
"malloc error");
57 for (i_img = 0; i_img < n_views; i_img++) {
58 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
59 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
60 printf_s(
"img ( #=%d ): %d¥r¥n", i_img, ret);
66 printf_s(
"pred: %d¥r¥n", ret);
67 if (NULL != scores && 0 < n_scores) {
69 printf_s(
" # of scores = %zd¥r¥n", n_scores);
70 for (i_score = 0; i_score < n_scores; i_score++) {
71 printf_s(
" label%d: %.6e¥r¥n", i_score, scores[i_score]);
84 for (i_img = 0; i_img < n_views; i_img++) {
85 fnFIE_free_object(hsrcs[i_img]);
89 if (NULL != scores) { fnOAL_free(scores); }
95int smp_mvcnn_benchmark(
const char*model_name,
const int num_views,
const char* img_folder,
const int bench_iter)
98 std::chrono::system_clock::time_point start, end;
100 INT ret = F_ERR_NONE;
104 FHANDLE* hsrcs = NULL;
106 FLOAT* scores = NULL;
114 printf_s(
"lic : %d¥r¥n", ret);
118 if (NULL == hmodel) { printf_s(
"failed to create handle¥r¥n"); }
119 else { printf_s(
"handle created¥r¥n"); }
123 printf_s(
"load: %d¥r¥n", ret);
127 printf_s(
"par : %d category=%d¥r¥n", ret, model_category);
128 if (
MULTI_VIEW_CNN != model_category) { printf_s(
"unmatch model"); }
132 printf_s(
"par : %d ch=%d w=%d h=%d¥r¥n", ret, ch, w, h);
136 printf_s(
"# of views=%d", n_views);
139 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
141 ret = F_ERR_NOMEMORY;
142 printf_s(
"malloc error");
146 for (i_img = 0; i_img < n_views; i_img++) {
147 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
148 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
149 printf_s(
"img ( #=%d ): %d¥r¥n", i_img, ret);
156 printf_s(
"--- start ---¥r¥n");
157 printf_s(
"ret, elapsed[msec], scores¥r¥n");
158 for (
int i = 0; i < bench_iter, F_ERR_NONE == ret; i++) {
162 start = std::chrono::system_clock::now();
168 end = std::chrono::system_clock::now();
170 if (F_ERR_NONE != ret) {
171 printf_s(
"pred. err: %d¥r¥n", ret);
176 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
179 printf_s(
"%04d, %.3e", i, elapsed);
180 for (
int i_score = 0; i_score < n_scores; i_score++) {
181 printf_s(
", %.6e", scores[i_score]);
185 printf_s(
"--- finish ---¥r¥n");
196 for (i_img = 0; i_img < n_views; i_img++) {
197 fnFIE_free_object(hsrcs[i_img]);
201 if (NULL != scores) { fnOAL_free(scores); }
207int smp_mvcnn_with_fie(
const char*model_name,
const int num_views,
const char* img_folder)
209 INT ret = F_ERR_NONE;
213 FHANDLE* hsrcs = NULL;
214 FHANDLE* hfiltereds = NULL;
216 FLOAT* scores = NULL;
224 printf_s(
"lic : %d¥r¥n", ret);
228 if (NULL == hmodel) { printf_s(
"failed to create handle¥r¥n"); }
229 else { printf_s(
"handle created¥r¥n"); }
233 printf_s(
"load: %d¥r¥n", ret);
237 printf_s(
"par : %d category=%d¥r¥n", ret, model_category);
238 if (
MULTI_VIEW_CNN != model_category) { printf_s(
"unmatch model"); }
242 printf_s(
"par : %d ch=%d w=%d h=%d¥r¥n", ret, ch, w, h);
246 printf_s(
"# of views=%d", n_views);
249 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
251 ret = F_ERR_NOMEMORY;
252 printf_s(
"malloc error");
256 for (i_img = 0; i_img < n_views; i_img++) {
257 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
258 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
259 printf_s(
"img ( #=%d ): %d¥r¥n", i_img, ret);
269 printf_s(
"pred: %d¥r¥n", ret);
270 if (NULL != scores && 0 < n_scores) {
272 printf_s(
" # of scores = %zd¥r¥n", n_scores);
273 for (i_score = 0; i_score < n_scores; i_score++) {
274 printf_s(
" label%d: %.6e¥r¥n", i_score, scores[i_score]);
283 hfiltereds = (FHANDLE*)fnOAL_malloc(
sizeof(FHANDLE)*n_views);
285 ret = F_ERR_NOMEMORY;
286 printf_s(
"malloc error ( filtered images )");
290 for (i_img = 0; i_img < n_views; i_img++) {
291 FHANDLE hsrc = hsrcs[i_img];
292 FHANDLE hdst = hfiltereds[i_img];
293 ret = fnFIE_average(hsrc, hdst, 0, 0);
294 if (F_ERR_NONE != ret) {
goto finally; }
300 printf_s(
"pred(average): %d¥r¥n", ret);
301 if (F_ERR_NONE != ret) {
goto finally; }
302 if (NULL != scores && 0 < n_scores) {
304 printf_s(
" # of scores = %zd¥r¥n", n_scores);
305 for (i_score = 0; i_score < n_scores; i_score++) {
306 printf_s(
" label%d: %.6e¥r¥n", i_score, scores[i_score]);
318 for (i_img = 0; i_img < n_views; i_img++) {
319 fnFIE_free_object(hsrcs[i_img]);
323 if (NULL != hfiltereds) {
325 for (i_img = 0; i_img < n_views; i_img++) {
326 fnFIE_free_object(hfiltereds[i_img]);
328 fnOAL_free(hfiltereds);
330 if (NULL != scores) { fnOAL_free(scores); }
INT FVALGAPI fnPDL_get_input_image_size(const H_MODEL hmodel, INT *channels, INT *width, INT *height)
モデルパラメータの取得
Definition: prediction_cpp.cpp:1112
MODEL_CATEGORY
モデルの種別
Definition: fv_pdl.h:29
INT fnPDL_check_license()
ライセンス確認
Definition: check_licence.cpp:158
INT FVALGAPI fnPDL_get_model_category(const H_MODEL hmodel, MODEL_CATEGORY *model_category)
モデルの種別の取得
Definition: prediction_cpp.cpp:1091
INT FVALGAPI fnPDL_get_how_many_views(const H_MODEL hmodel, INT *num_views)
モデルパラメータの取得
Definition: prediction_cpp.cpp:1134
INT FVALGAPI fnPDL_predict_multi_images(const H_MODEL hmodel, INT num_images, FHANDLE *hsrcs, FLOAT **scores, size_t *num_scores)
推論の実行 ( MVCNN )
Definition: prediction_cpp.cpp:1324
VOID FVALGAPI fnPDL_dispose(H_MODEL hmodel)
モデルハンドルの解放
Definition: prediction_cpp.cpp:1446
INT FVALGAPI fnPDL_predict(const H_MODEL hmodel, const FHANDLE hsrc, FLOAT **scores, size_t *num_scores)
推論の実行
Definition: prediction_cpp.cpp:1268
INT FVALGAPI fnPDL_load_model(const CHAR *filename, H_MODEL hmodel)
モデルの読み込み
Definition: prediction_cpp.cpp:995
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:971
@ MULTI_VIEW_CNN
Definition: fv_pdl.h:37