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);
27 printf_s(
"lic : %d\r\n", ret);
31 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
32 else { printf_s(
"handle created\r\n"); }
36 printf_s(
"load: %d\r\n", ret);
40 printf_s(
"par : %d category=%d\r\n", ret, model_category);
41 if (
CLASSIFICATION != model_category) { printf_s(
"unmatch model"); }
45 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
49 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
53 printf_s(
"pred: %d\r\n", ret);
54 if (NULL != scores && 0 < n_scores) {
56 printf_s(
" # of scores = %zd\r\n", n_scores);
57 for (i_score = 0; i_score < n_scores; i_score++) {
58 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
71 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
72 if (NULL != scores) { fnOAL_free(scores); }
78int smp_benchmark(
const char* model_name,
const char* img_name,
const int bench_iter)
81 std::chrono::system_clock::time_point start, end;
94 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
95 printf_s(
"img: %d\r\n", ret);
96 if (F_ERR_NONE != ret) {
goto finally; }
100 printf_s(
"lic : %d\r\n", ret);
104 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
105 else { printf_s(
"handle created\r\n"); }
109 printf_s(
"load: %d\r\n", ret);
113 printf_s(
"par : %d category=%d\r\n", ret, model_category);
114 if (
CLASSIFICATION != model_category) { printf_s(
"unmatch model"); }
116 printf_s(
"--- start ---\r\n");
117 printf_s(
"ret, elapsed[msec], scores\r\n");
119 for (
int i = 0; i < bench_iter; i++) {
123 start = std::chrono::system_clock::now();
129 end = std::chrono::system_clock::now();
131 if (F_ERR_NONE != ret) {
132 printf_s(
"pred. err: %d\r\n", ret);
137 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
140 printf_s(
"%04d, %.3e", i, elapsed);
141 for (
int i_score = 0; i_score < n_scores; i_score++) {
142 printf_s(
", %.6e", scores[i_score]);
147 printf_s(
"--- finish ---\r\n");
154 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
155 if (NULL != scores) { fnOAL_free(scores); }
161int smp_with_fie(
const char* model_name,
const char* img_name)
163 INT ret = F_ERR_NONE;
167 FLOAT* scores = NULL;
170 FHANDLE hfiltered = NULL;
178 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
179 printf_s(
"img: %d\r\n", ret);
185 printf_s(
"lic : %d\r\n", ret);
189 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n");
goto finally; }
190 else { printf_s(
"handle created\r\n"); }
194 printf_s(
"load: %d\r\n", ret);
195 if (F_ERR_NONE != ret) {
goto finally; }
199 printf_s(
"par : %d category=%d\r\n", ret, model_category);
200 if (
CLASSIFICATION != model_category) { printf_s(
"unmatch model"); }
208 printf_s(
"pred(original): %d\r\n", ret);
209 if (F_ERR_NONE != ret) {
goto finally; }
210 if (NULL != scores && 0 < n_scores) {
212 printf_s(
" # of scores = %zd\r\n", n_scores);
213 for (i_score = 0; i_score < n_scores; i_score++) {
214 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
223 ret = fnFIE_img_get_params(hsrc, &ch, &type, &step, &w, &h);
224 if (F_ERR_NONE != ret) {
goto finally; }
225 hfiltered = fnFIE_img_root_alloc(type, ch, w, h);
226 if (NULL == hfiltered) { ret = F_ERR_NOMEMORY;
goto finally; }
227 ret = fnFIE_average(hsrc, hfiltered, 0, 0);
228 if (F_ERR_NONE != ret) {
goto finally; }
232 printf_s(
"pred(average): %d\r\n", ret);
233 if (F_ERR_NONE != ret) {
goto finally; }
234 if (NULL != scores && 0 < n_scores) {
236 printf_s(
" # of scores = %zd\r\n", n_scores);
237 for (i_score = 0; i_score < n_scores; i_score++) {
238 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
248 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
249 if (NULL != hfiltered) { fnFIE_free_object(hfiltered); }
250 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:1914
INT FVALGAPI fnPDL_get_model_backend(const H_MODEL hmodel, MODEL_BACKEND *model_backend)
モデルのバックエンドの取得
Definition: prediction_cpp.cpp:1893
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:1862
VOID FVALGAPI fnPDL_dispose(H_MODEL hmodel)
モデルハンドルの解放
Definition: prediction_cpp.cpp:2440
INT FVALGAPI fnPDL_predict(const H_MODEL hmodel, const FHANDLE hsrc, FLOAT **scores, size_t *num_scores)
推論の実行
Definition: prediction_cpp.cpp:2164
INT FVALGAPI fnPDL_load_model(const CHAR *filename, H_MODEL hmodel)
モデルの読み込み
Definition: prediction_cpp.cpp:1735
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:1680
@ CLASSIFICATION
Definition: fv_pdl.h:50