Interpreting results
run returns one ImageInferenceResult per input image. Each holds a flat list
of InferenceResult entries under results. In C#, these records are exposed
through the disposable, list-like ImageInferenceResults owner returned by
Run.
InferenceResult
Each InferenceResult carries the output of one network stage. The populated field depends on network_type:
| Field | Populated for |
|---|---|
bounding_box | object detection, instance segmentation |
segmentation | segmentation, instance segmentation, anomaly detection |
scalar | classification, anomaly detection |
text | optical character recognition |
barcode | barcode reading |
sub_results | nested results from downstream stages |
Additional fields: network_type (the producing stage), index (position within its sibling list), and batch_index (the source image). Coordinates on bounding_box, segmentation and barcode are absolute pixel values. C# exposes the same fields as PascalCase record properties.
Object definition
- Python
- C#
- C / C++
class InferenceResult:
network_type: str
batch_index: int
index: int
sub_results: list[InferenceResult]
scalar: Scalar | None
bounding_box: BoundingBox | None
segmentation: Segmentation | None
text: str | None
barcode: Barcode | None
public sealed class ImageInferenceResults :
IReadOnlyList<ImageInferenceResult>,
IDisposable
{
public IReadOnlyList<ImageInferenceResult> Results { get; }
// Count, indexer, enumeration, and Dispose are also available.
}
public sealed record ImageInferenceResult(
IReadOnlyList<InferenceResult> Results);
public sealed record InferenceResult(
NetworkType NetworkType,
ulong BatchIndex,
ulong Index,
IReadOnlyList<InferenceResult> SubResults,
BoundingBox? BoundingBox,
SegmentationResult? Segmentation,
Scalar? Scalar,
string? Text,
Barcode? Barcode);
ImageInferenceResults retains the native result tree needed for
ToImagesWithAnnotations and must be disposed. Its ImageInferenceResult and
InferenceResult records are managed copies and remain valid after the owner
is disposed.
typedef struct DenkflowInferenceResult {
DenkflowNetworkType network_type;
size_t index;
struct DenkflowInferenceResult *sub_results;
size_t sub_results_length;
DenkflowBoundingBox *bounding_box;
DenkflowSegmentation *segmentation;
DenkflowScalar *scalar;
char *text;
DenkflowBarcode *barcode;
} DenkflowInferenceResult;
Walking the results
- Python
- C#
- C / C++
for image_result in results:
for r in image_result.results:
if r.bounding_box:
print(r.bounding_box.class_label.name, r.bounding_box.confidence)
if r.text is not None:
print(r.text)
for sub in r.sub_results:
... # nested stage output
foreach (ImageInferenceResult imageResult in results)
{
foreach (InferenceResult result in imageResult.Results)
{
if (result.BoundingBox is BoundingBox box)
{
Console.WriteLine($"{box.ClassLabel.Name}: {box.Confidence:F2}");
}
if (result.Text is string text)
{
Console.WriteLine(text);
}
foreach (InferenceResult subResult in result.SubResults)
{
// Handle output from a nested stage.
}
}
}
for (size_t b = 0; b < inference_results->image_results_length; ++b) {
DenkflowImageInferenceResult* image_result = &inference_results->image_results[b];
for (size_t i = 0; i < image_result->results_length; ++i) {
DenkflowInferenceResult* r = &image_result->results[i];
if (r->bounding_box != NULL) {
printf("%s: %f\n", r->bounding_box->class_label.name, r->bounding_box->confidence);
}
}
}
In C, the result tree is released once with denkflow_inference_results_free.
Nested pipelines (for example detection followed by per-object classification) expose the downstream output under sub_results.