microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
include/ortx_processor.h
72lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | // C ABI header file for the onnxruntime-extensions tokenization module |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "ortx_utils.h" |
| 9 | |
| 10 | // typedefs to create/dispose function flood, and to make the API more C++ friendly with less casting |
| 11 | typedef OrtxObject OrtxProcessor; |
| 12 | typedef OrtxObject OrtxRawImages; |
| 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | /** \brief Create a processor object with the specified processor definition |
| 19 | * |
| 20 | * \param processor Pointer to store the created processor object |
| 21 | * \param processor_def The processor definition, either a path to the processor directory or a JSON string, and is |
| 22 | * utf-8 encoded. \return Error code indicating the success or failure of the operation |
| 23 | */ |
| 24 | extError_t ORTX_API_CALL OrtxCreateProcessor(OrtxProcessor** processor, const char* processor_def); |
| 25 | |
| 26 | /** |
| 27 | * @brief Loads a set of images from the specified image paths. |
| 28 | * |
| 29 | * This function loads a set of images from the given image paths and returns a pointer to the loaded images. |
| 30 | * The number of images loaded is also returned through the `num_images_loaded` parameter. |
| 31 | * |
| 32 | * @param[out] images A pointer to a pointer that will be set to the loaded images. |
| 33 | * @param[in] image_paths An array of image paths. |
| 34 | * @param[in] num_images The number of images to load. |
| 35 | * @param[out] num_images_loaded A pointer to a variable that will be set to the number of images loaded. |
| 36 | * |
| 37 | * @return An error code indicating the status of the operation. |
| 38 | */ |
| 39 | extError_t ORTX_API_CALL OrtxLoadImages(OrtxRawImages** images, const char** image_paths, size_t num_images, |
| 40 | size_t* num_images_loaded); |
| 41 | |
| 42 | |
| 43 | /** |
| 44 | * @brief Creates raw images from the provided data. |
| 45 | * |
| 46 | * This function creates raw images from the provided data. The raw images are stored in the `images` parameter. |
| 47 | * |
| 48 | * @param images Pointer to a pointer to the `OrtxRawImages` structure that will hold the created raw images. |
| 49 | * @param data Array of pointers to the data for each image. |
| 50 | * @param sizes Array of pointers to the sizes of each image. |
| 51 | * @param num_images Number of images to create. |
| 52 | * @return An `extError_t` value indicating the success or failure of the operation. |
| 53 | */ |
| 54 | extError_t ORTX_API_CALL OrtxCreateRawImages(OrtxRawImages** images, const void* data[], const int64_t sizes[], size_t num_images); |
| 55 | |
| 56 | /** |
| 57 | * @brief Pre-processes the given raw images using the specified processor. |
| 58 | * |
| 59 | * This function applies preprocessing operations on the raw images using the provided processor. |
| 60 | * The result of the preprocessing is stored in the `OrtxImageProcessorResult` object. |
| 61 | * |
| 62 | * @param processor A pointer to the `OrtxProcessor` object used for preprocessing. |
| 63 | * @param images A pointer to the `OrtxRawImages` object containing the raw images to be processed. |
| 64 | * @param result A pointer to the `OrtxImageProcessorResult` object to store the preprocessing result. |
| 65 | * @return An `extError_t` value indicating the success or failure of the preprocessing operation. |
| 66 | */ |
| 67 | extError_t ORTX_API_CALL OrtxImagePreProcess(OrtxProcessor* processor, OrtxRawImages* images, |
| 68 | OrtxTensorResult** result); |
| 69 | |
| 70 | #ifdef __cplusplus |
| 71 | } |
| 72 | #endif |
| 73 | |