5int smp_simple(
const char* model_name,
const char* img_name)
20 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
21 printf_s(
"img: %d\r\n", ret);
22 if (F_ERR_NONE != ret) {
goto finally; }
28 printf_s(
"lic : %d\r\n", ret);
29 if (F_ERR_NONE != ret) {
goto finally; }
35 printf_s(
"failed to create handle\r\n");
38 else { printf_s(
"handle created\r\n"); }
42 printf_s(
"load: %d\r\n", ret);
43 if (F_ERR_NONE != ret) {
goto finally; }
47 printf_s(
"par : %d category=%d\r\n", ret, model_category);
48 if (F_ERR_NONE != ret) {
goto finally; }
50 ret = F_ERR_INVALID_OBJECT;
51 printf_s(
"unmatch model\r\n");
57 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
58 if (F_ERR_NONE != ret) {
goto finally; }
62 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
63 if (F_ERR_NONE != ret) {
goto finally; }
67 printf_s(
"pred: %d\r\n", ret);
68 if (F_ERR_NONE != ret) {
goto finally; }
69 if (NULL != scores && 0 < n_scores) {
71 printf_s(
" # of scores = %zd\r\n", n_scores);
72 for (i_score = 0; i_score < n_scores; i_score++) {
73 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
88 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
89 if (NULL != scores) { fnOAL_free(scores); }
95int smp_benchmark(
const char* model_name,
const char* img_name,
const int bench_iter)
98 std::chrono::system_clock::time_point start, end;
100 INT ret = F_ERR_NONE;
104 FLOAT* scores = NULL;
111 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
112 printf_s(
"img: %d\r\n", ret);
113 if (F_ERR_NONE != ret) {
goto finally; }
117 printf_s(
"lic : %d\r\n", ret);
118 if (F_ERR_NONE != ret) {
goto finally; }
122 if (NULL == hmodel) {
123 ret = F_ERR_NOMEMORY;
124 printf_s(
"failed to create handle\r\n");
127 else { printf_s(
"handle created\r\n"); }
131 printf_s(
"load: %d\r\n", ret);
132 if (F_ERR_NONE != ret) {
goto finally; }
136 printf_s(
"par : %d category=%d\r\n", ret, model_category);
137 if (F_ERR_NONE != ret) {
goto finally; }
139 ret = F_ERR_INVALID_OBJECT;
140 printf_s(
"unmatch model\r\n");
144 printf_s(
"--- start ---\r\n");
145 printf_s(
"number, elapsed[msec], scores\r\n");
147 for (
int i = 0; i < bench_iter; i++) {
151 start = std::chrono::system_clock::now();
157 end = std::chrono::system_clock::now();
159 if (F_ERR_NONE != ret) {
160 printf_s(
"pred. err: %d\r\n", ret);
165 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
168 printf_s(
"%04d, %.3e", i, elapsed);
169 for (
int i_score = 0; i_score < n_scores; i_score++) {
170 printf_s(
", %.6e", scores[i_score]);
175 printf_s(
"--- finish ---\r\n");
183 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
184 if (NULL != scores) { fnOAL_free(scores); }
190int smp_with_fie(
const char* model_name,
const char* img_name)
192 INT ret = F_ERR_NONE;
196 FLOAT* scores = NULL;
199 FHANDLE hfiltered = NULL;
207 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
208 printf_s(
"img: %d\r\n", ret);
209 if (F_ERR_NONE != ret) {
goto finally; }
215 printf_s(
"lic : %d\r\n", ret);
216 if (F_ERR_NONE != ret) {
goto finally; }
220 if (NULL == hmodel) {
221 ret = F_ERR_NOMEMORY;
222 printf_s(
"failed to create handle\r\n");
225 else { printf_s(
"handle created\r\n"); }
229 printf_s(
"load: %d\r\n", ret);
230 if (F_ERR_NONE != ret) {
goto finally; }
234 printf_s(
"par : %d category=%d\r\n", ret, model_category);
235 if (F_ERR_NONE != ret) {
goto finally; }
237 ret = F_ERR_INVALID_OBJECT;
238 printf_s(
"unmatch model\r\n");
248 printf_s(
"pred(original): %d\r\n", ret);
249 if (F_ERR_NONE != ret) {
goto finally; }
250 if (NULL != scores && 0 < n_scores) {
252 printf_s(
" # of scores = %zd\r\n", n_scores);
253 for (i_score = 0; i_score < n_scores; i_score++) {
254 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
263 ret = fnFIE_img_get_params(hsrc, &ch, &type, &step, &w, &h);
264 if (F_ERR_NONE != ret) {
goto finally; }
265 hfiltered = fnFIE_img_root_alloc(type, ch, w, h);
266 if (NULL == hfiltered) { ret = F_ERR_NOMEMORY;
goto finally; }
267 ret = fnFIE_average(hsrc, hfiltered, 0, 0);
268 if (F_ERR_NONE != ret) {
goto finally; }
272 printf_s(
"pred(average): %d\r\n", ret);
273 if (F_ERR_NONE != ret) {
goto finally; }
274 if (NULL != scores && 0 < n_scores) {
276 printf_s(
" # of scores = %zd\r\n", n_scores);
277 for (i_score = 0; i_score < n_scores; i_score++) {
278 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
289 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
290 if (NULL != hfiltered) { fnFIE_free_object(hfiltered); }
291 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:1989
INT FVALGAPI fnPDL_get_model_backend(const H_MODEL hmodel, MODEL_BACKEND *model_backend)
モデルのバックエンドの取得
Definition: prediction_cpp.cpp:1968
MODEL_CATEGORY
モデルの種別
Definition: fv_pdl.h:46
INT fnPDL_check_license()
ライセンス確認
Definition: check_licence.cpp:160
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:1937
VOID FVALGAPI fnPDL_dispose(H_MODEL hmodel)
モデルハンドルの解放
Definition: prediction_cpp.cpp:2556
INT FVALGAPI fnPDL_predict(const H_MODEL hmodel, const FHANDLE hsrc, FLOAT **scores, size_t *num_scores)
推論の実行
Definition: prediction_cpp.cpp:2239
INT FVALGAPI fnPDL_load_model(const CHAR *filename, H_MODEL hmodel)
モデルの読み込み
Definition: prediction_cpp.cpp:1810
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:1755
@ CLASSIFICATION
Definition: fv_pdl.h:50