classifier.h¶
-
struct mmdeploy_classification_t¶
-
typedef struct mmdeploy_classifier *mmdeploy_classifier_t¶
-
int mmdeploy_classifier_create(mmdeploy_model_t model, const char *device_name, int device_id, mmdeploy_classifier_t *classifier)¶
Create classifier’s handle.
- Parameters
model – [in] an instance of mmclassification sdk model created by mmdeploy_model_create_by_path or mmdeploy_model_create in model.h
device_name – [in] name of device, such as “cpu”, “cuda”, etc.
device_id – [in] id of device.
classifier – [out] instance of a classifier, which must be destroyed by mmdeploy_classifier_destroy
- Returns
status of creating classifier’s handle
-
int mmdeploy_classifier_create_by_path(const char *model_path, const char *device_name, int device_id, mmdeploy_classifier_t *classifier)¶
Create classifier’s handle.
- Parameters
model_path – [in] path of mmclassification sdk model exported by mmdeploy model converter
device_name – [in] name of device, such as “cpu”, “cuda”, etc.
device_id – [in] id of device.
classifier – [out] instance of a classifier, which must be destroyed by mmdeploy_classifier_destroy
- Returns
status of creating classifier’s handle
-
int mmdeploy_classifier_apply(mmdeploy_classifier_t classifier, const mmdeploy_mat_t *mats, int mat_count, mmdeploy_classification_t **results, int **result_count)¶
Use classifier created by mmdeploy_classifier_create_by_path to get label information of each image in a batch.
- Parameters
classifier – [in] classifier’s handle created by mmdeploy_classifier_create_by_path
mats – [in] a batch of images
mat_count – [in] number of images in the batch
results – [out] a linear buffer to save classification results of each image, which must be freed by mmdeploy_classifier_release_result
result_count – [out] a linear buffer with length being
mat_count
to save the number of classification results of each image. It must be released by mmdeploy_classifier_release_result
- Returns
status of inference
-
void mmdeploy_classifier_release_result(mmdeploy_classification_t *results, const int *result_count, int count)¶
Release the inference result buffer created mmdeploy_classifier_apply.
- Parameters
results – [in] classification results buffer
result_count – [in]
results
size buffercount – [in] length of
result_count
-
void mmdeploy_classifier_destroy(mmdeploy_classifier_t classifier)¶
Destroy classifier’s handle.
- Parameters
classifier – [in] classifier’s handle created by mmdeploy_classifier_create_by_path
-
int mmdeploy_classifier_create_v2(mmdeploy_model_t model, mmdeploy_context_t context, mmdeploy_classifier_t *classifier)¶
Same as mmdeploy_classifier_create, but allows to control execution context of tasks via context.
-
int mmdeploy_classifier_create_input(const mmdeploy_mat_t *mats, int mat_count, mmdeploy_value_t *value)¶
Pack classifier inputs into mmdeploy_value_t.
- Parameters
mats – [in] a batch of images
mat_count – [in] number of images in the batch
value – [out] the packed value
- Returns
status of the operation
-
int mmdeploy_classifier_apply_v2(mmdeploy_classifier_t classifier, mmdeploy_value_t input, mmdeploy_value_t *output)¶
Same as mmdeploy_classifier_apply, but input and output are packed in mmdeploy_value_t.
-
int mmdeploy_classifier_apply_async(mmdeploy_classifier_t classifier, mmdeploy_sender_t input, mmdeploy_sender_t *output)¶
Apply classifier asynchronously.
- Parameters
classifier – [in] handle of the classifier
input – [in] input sender that will be consumed by the operation
output – [out] output sender
- Returns
status of the operation
-
int mmdeploy_classifier_get_result(mmdeploy_value_t output, mmdeploy_classification_t **results, int **result_count)¶
- Parameters
output – [in] output obtained by applying a classifier
results – [out] a linear buffer containing classification results of each image, released by mmdeploy_classifier_release_result
result_count – [out] a linear buffer containing the number of results for each input image, released by mmdeploy_classifier_release_result
- Returns
status of the operation