Loading...
Searching...
No Matches
inference_worker.c
Go to the documentation of this file.
19 * @brief Persistent saved-picture inference with explicit request correlation and module-owned results.
20 * @details No sensor is acquired here; simulated and real saved images enter the same model path. */
37/** @brief Probe sibling INT8 then FP32 ONNX exports when automatic settings point to an RPK or unsupported INT8 graph. */
62 if (inference_context_open(context, &candidate, processor->adapter, probe_error, sizeof(probe_error))) {
75int inference_worker_cli(int argc, char **argv, const struct inference_image_processor *processor)
80 if (!processor || !processor->write || !processor->application || !processor->module || !processor->adapter) return 2;
82 if (!strcmp(argv[index], "--analyze") || !strcmp(argv[index], "--analyze-server") || !strcmp(argv[index], "--check-model")) selected = true;
88 else if (!strcmp(argv[index], "--private-images")) { if (private_images) return 2; private_images = true; }
93 else if (!strcmp(option, "--settings")) { if (settings_path) return 2; settings_path = argv[index]; }
104 if (!inference_settings_find(processor->application, processor->module, discovered, sizeof(discovered))) {
112 if (!inference_settings_read(&settings, settings_path, processor->setting, processor->context, error, sizeof(error))) {
122 if (processor->validate && !processor->validate(processor->context, &context, error, sizeof(error))) {
129 /* Only a producer may opt into mutation; normal analysis must leave published source images immutable. */
132 else printf("%s model ready adapter=%s sha256=%s\n", processor->application, context.model.adapter, context.model.graph_sha256);
143 if (!length || command[length - 1] != '\n' || strncmp(command, "ANALYZE ", 8)) { result = 2; break; }
149 /* Reject replay/reordering before running the graph, not after an old result has already been written. */
static bool ini_uint(const char *text, uint64_t *number)
Parse digits-only uint64; overflow and signs are rejected.
Definition bounded_ini.h:52
bool inference_jpeg_prepare(struct inference_context *context, const char *filename, char *error, size_t capacity)
Stream a JPEG into an open context's single declared image input.
Definition inference_jpeg.c:167
bool inference_context_run(struct inference_context *context, char *error, size_t capacity)
Run the currently prepared tensors using the context's timeout policy.
Definition inference_model.c:346
bool inference_context_open(struct inference_context *context, const struct inference_settings *settings, const char *adapter, char *error, size_t capacity)
Verify a bundle, map bounded tensors and bind one warm session.
Definition inference_model.c:277
void inference_context_close(struct inference_context *context)
Release the session before unmapping its borrowed tensor storage.
Definition inference_model.c:373
bool inference_settings_find(const char *application, const char *module, char *filename, size_t capacity)
Discover application_settings.ini in adjacent, development-module, then installed-share order.
Definition inference_settings.c:202
bool inference_settings_read(struct inference_settings *settings, const char *filename, ini_field_handler extra, void *context, char *error, size_t capacity)
Parse one flat INI, delegate application keys and resolve paths against the selected file.
Definition inference_settings.c:158
void inference_settings_init(struct inference_settings *settings, enum inference_backend backend)
Reset storage and select conservative thread/timeout defaults.
Definition inference_settings.c:28
static bool analyze_image(struct inference_context *context, const struct inference_image_processor *processor, const char *image, uint32_t sequence, char *error, size_t capacity)
Publish a result only after complete preparation and execution for this picture.
Definition inference_worker.c:28
int inference_worker_cli(int argc, char **argv, const struct inference_image_processor *processor)
Dispatch one-shot analysis, model checks or the persistent ANALYZE protocol.
Definition inference_worker.c:75
static bool open_fallback_onnx(struct inference_context *context, struct inference_settings *settings, const struct inference_image_processor *processor, char *error, size_t capacity)
Probe sibling INT8 then FP32 ONNX exports when automatic settings point to an RPK or unsupported INT8...
Definition inference_worker.c:38
Warm saved-picture processing without acquiring a camera or interpreting CAM results.
Independent, noncopyable model owner; mapped tensor buffers and session are reused between jobs.
Definition inference_model.h:43
Borrowed module callbacks; the worker serializes calls and retains no per-request pixel pointers.
Definition inference_worker.h:32
bool(* validate)(void *context, const struct inference_context *model, char *error, size_t capacity)
Definition inference_worker.h:38
bool(* write)(void *context, const struct inference_context *model, const char *image, uint32_t sequence, char *error, size_t capacity)
Definition inference_worker.h:36
Per-application configuration; all resolved paths belong to this caller-owned value.
Definition inference_settings.h:39
char descriptor[INFERENCE_PATH_CAPACITY]
Definition inference_settings.h:43