6int smp_mvcnn_simple(
const char*model_name,
const char* img_folder)
13 FHANDLE* hsrcs = NULL;
26 printf_s(
"lic : %d\r\n", ret);
30 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
31 else { printf_s(
"handle created\r\n"); }
35 printf_s(
"load: %d\r\n", ret);
39 printf_s(
"par : %d category=%d\r\n", ret, model_category);
40 if (
MULTI_VIEW_CNN != model_category) { printf_s(
"unmatch model"); }
44 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
48 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
52 printf_s(
"# of views=%d", n_views);
55 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
58 printf_s(
"malloc error");
62 for (i_img = 0; i_img < n_views; i_img++) {
63 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
64 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
65 printf_s(
"img ( #=%d ): %d\r\n", i_img, ret);
71 printf_s(
"pred: %d\r\n", ret);
72 if (NULL != scores && 0 < n_scores) {
74 printf_s(
" # of scores = %zd\r\n", n_scores);
75 for (i_score = 0; i_score < n_scores; i_score++) {
76 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
89 for (i_img = 0; i_img < n_views; i_img++) {
90 fnFIE_free_object(hsrcs[i_img]);
94 if (NULL != scores) { fnOAL_free(scores); }
100int smp_mvcnn_benchmark(
const char*model_name,
const char* img_folder,
const int bench_iter)
103 std::chrono::system_clock::time_point start, end;
105 INT ret = F_ERR_NONE;
109 FHANDLE* hsrcs = NULL;
111 FLOAT* scores = NULL;
119 printf_s(
"lic : %d\r\n", ret);
123 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
124 else { printf_s(
"handle created\r\n"); }
128 printf_s(
"load: %d\r\n", ret);
132 printf_s(
"par : %d category=%d\r\n", ret, model_category);
133 if (
MULTI_VIEW_CNN != model_category) { printf_s(
"unmatch model"); }
137 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
141 printf_s(
"# of views=%d", n_views);
144 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
146 ret = F_ERR_NOMEMORY;
147 printf_s(
"malloc error");
151 for (i_img = 0; i_img < n_views; i_img++) {
152 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
153 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
154 printf_s(
"img ( #=%d ): %d\r\n", i_img, ret);
161 printf_s(
"--- start ---\r\n");
162 printf_s(
"ret, elapsed[msec], scores\r\n");
163 for (
int i = 0; i < bench_iter, F_ERR_NONE == ret; i++) {
167 start = std::chrono::system_clock::now();
173 end = std::chrono::system_clock::now();
175 if (F_ERR_NONE != ret) {
176 printf_s(
"pred. err: %d\r\n", ret);
181 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
184 printf_s(
"%04d, %.3e", i, elapsed);
185 for (
int i_score = 0; i_score < n_scores; i_score++) {
186 printf_s(
", %.6e", scores[i_score]);
190 printf_s(
"--- finish ---\r\n");
201 for (i_img = 0; i_img < n_views; i_img++) {
202 fnFIE_free_object(hsrcs[i_img]);
206 if (NULL != scores) { fnOAL_free(scores); }
212int smp_mvcnn_with_fie(
const char*model_name,
const char* img_folder)
214 INT ret = F_ERR_NONE;
218 FHANDLE* hsrcs = NULL;
219 FHANDLE* hfiltereds = NULL;
221 FLOAT* scores = NULL;
229 printf_s(
"lic : %d\r\n", ret);
233 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
234 else { printf_s(
"handle created\r\n"); }
238 printf_s(
"load: %d\r\n", ret);
242 printf_s(
"par : %d category=%d\r\n", ret, model_category);
243 if (
MULTI_VIEW_CNN != model_category) { printf_s(
"unmatch model"); }
247 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
251 printf_s(
"# of views=%d", n_views);
254 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
256 ret = F_ERR_NOMEMORY;
257 printf_s(
"malloc error");
261 for (i_img = 0; i_img < n_views; i_img++) {
262 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
263 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
264 printf_s(
"img ( #=%d ): %d\r\n", i_img, ret);
274 printf_s(
"pred: %d\r\n", ret);
275 if (NULL != scores && 0 < n_scores) {
277 printf_s(
" # of scores = %zd\r\n", n_scores);
278 for (i_score = 0; i_score < n_scores; i_score++) {
279 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
288 hfiltereds = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
290 ret = F_ERR_NOMEMORY;
291 printf_s(
"malloc error ( filtered images )");
295 for (i_img = 0; i_img < n_views; i_img++) {
296 FHANDLE hsrc = hsrcs[i_img];
297 FHANDLE hdst = hfiltereds[i_img];
298 ret = fnFIE_average(hsrc, hdst, 0, 0);
299 if (F_ERR_NONE != ret) {
goto finally; }
305 printf_s(
"pred(average): %d\r\n", ret);
306 if (F_ERR_NONE != ret) {
goto finally; }
307 if (NULL != scores && 0 < n_scores) {
309 printf_s(
" # of scores = %zd\r\n", n_scores);
310 for (i_score = 0; i_score < n_scores; i_score++) {
311 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
323 for (i_img = 0; i_img < n_views; i_img++) {
324 fnFIE_free_object(hsrcs[i_img]);
328 if (NULL != hfiltereds) {
330 for (i_img = 0; i_img < n_views; i_img++) {
331 fnFIE_free_object(hfiltereds[i_img]);
333 fnOAL_free(hfiltereds);
335 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:1680
INT FVALGAPI fnPDL_get_model_backend(const H_MODEL hmodel, MODEL_BACKEND *model_backend)
モデルのバックエンドの取得
Definition: prediction_cpp.cpp:1659
MODEL_CATEGORY
モデルの種別
Definition: fv_pdl.h:46
INT fnPDL_check_license()
ライセンス確認
Definition: check_licence.cpp:158
MODEL_BACKEND
推論バックエンド
Definition: fv_pdl.h:30
INT FVALGAPI fnPDL_get_model_category(const H_MODEL hmodel, MODEL_CATEGORY *model_category)
モデルの種別の取得
Definition: prediction_cpp.cpp:1628
INT FVALGAPI fnPDL_get_how_many_views(const H_MODEL hmodel, INT *num_views)
モデルパラメータの取得
Definition: prediction_cpp.cpp:1704
INT FVALGAPI fnPDL_predict_multi_images(const H_MODEL hmodel, INT num_images, FHANDLE *hsrcs, FLOAT **scores, size_t *num_scores)
推論の実行 ( 多視点画像分類、多視点アノマリー検出 )
Definition: prediction_cpp.cpp:1937
VOID FVALGAPI fnPDL_dispose(H_MODEL hmodel)
モデルハンドルの解放
Definition: prediction_cpp.cpp:2110
INT FVALGAPI fnPDL_load_model(const CHAR *filename, H_MODEL hmodel)
モデルの読み込み
Definition: prediction_cpp.cpp:1501
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:1446
@ MULTI_VIEW_CNN
Definition: fv_pdl.h:54