Skip to content

DiGi.YOLO.Classes

github-actions[bot] edited this page Aug 28, 2026 · 3 revisions

DiGi.YOLO.Classes Namespace

Classes

BoundingBox Class

Represents a rectangular bounding box used to define the location and size of an object within an image.

public class BoundingBox : DiGi.YOLO.Interfaces.IBoundingBox

Inheritance System.Object → BoundingBox

Derived
↳ BoundingBoxResult

Implements IBoundingBox

Constructors

BoundingBox(double, double, double, double) Constructor

Initializes a new instance of the BoundingBox class.

public BoundingBox(double x, double y, double width, double height);

Parameters

x System.Double

The x-coordinate of the top-left corner of the bounding box.

y System.Double

The y-coordinate of the top-left corner of the bounding box.

width System.Double

The width of the bounding box.

height System.Double

The height of the bounding box.

Properties

BoundingBox.Height Property

Gets the height of the bounding box.

public double Height { get; }

Implements Height

Property Value

System.Double

BoundingBox.Width Property

Gets the width of the bounding box.

public double Width { get; }

Implements Width

Property Value

System.Double

BoundingBox.X Property

Gets the x-coordinate of the top-left corner of the bounding box.

public double X { get; }

Implements X

Property Value

System.Double

BoundingBox.Y Property

Gets the y-coordinate of the top-left corner of the bounding box.

public double Y { get; }

Implements Y

Property Value

System.Double

Methods

BoundingBox.Equals(object) Method

Determines whether the specified object is equal to the current bounding box based on its coordinates and dimensions.

public override bool Equals(object? @object);

Parameters

object System.Object

The object to compare with the current bounding box.

Returns

System.Boolean
True if the objects are equal; otherwise, false.

BoundingBox.GetHashCode() Method

Returns a hash code for the current bounding box based on its coordinates and dimensions.

public override int GetHashCode();

Returns

System.Int32
A hash code for the current object.

BoundingBox.ToString() Method

Returns a string that represents the current bounding box in the format "x y width height".

public override string ToString();

Returns

System.String
A string representation of the bounding box.

BoundingBoxResult Class

Represents the result of a bounding box detection, containing spatial coordinates, label information, and confidence score.

public class BoundingBoxResult : DiGi.YOLO.Classes.BoundingBox

Inheritance System.Object → BoundingBox → BoundingBoxResult

Constructors

BoundingBoxResult(string, int, double, double, double, double, double) Constructor

Initializes a new instance of the BoundingBoxResult class.

public BoundingBoxResult(string? name, int labelIndex, double x, double y, double width, double height, double confidence);

Parameters

name System.String

The name of the detected object.

labelIndex System.Int32

The index of the label associated with the detection.

x System.Double

The X coordinate of the bounding box.

y System.Double

The Y coordinate of the bounding box.

width System.Double

The width of the bounding box.

height System.Double

The height of the bounding box.

confidence System.Double

The confidence score of the detection.

Properties

BoundingBoxResult.Confidence Property

Gets the confidence score of the detected object.

public double Confidence { get; }

Property Value

System.Double

BoundingBoxResult.LabelIndex Property

Gets the index of the label for the detected object.

public int LabelIndex { get; }

Property Value

System.Int32

BoundingBoxResult.Name Property

Gets the name of the detected object.

public string? Name { get; }

Property Value

System.String

Methods

BoundingBoxResult.Equals(object) Method

Determines whether the specified object is equal to the current bounding box result based on its properties.

public override bool Equals(object? @object);

Parameters

object System.Object

The object to compare with the current object.

Returns

System.Boolean
true if the objects are equal; otherwise, false.

BoundingBoxResult.GetHashCode() Method

Gets the hash code for the current bounding box result.

public override int GetHashCode();

Returns

System.Int32
A 32-bit signed integer hash code.

BoundingBoxResult.ToString() Method

Returns a string representation of the bounding box result, including name, label index, coordinates, dimensions, and confidence.

public override string ToString();

Returns

System.String
A tab-separated string containing the detection details.

BoundingBoxResultFile Class

Represents a collection of bounding box results typically associated with a result file.

public class BoundingBoxResultFile : System.Collections.Generic.List<DiGi.YOLO.Classes.BoundingBoxResult>

Inheritance System.Object → System.Collections.Generic.List<BoundingBoxResult> → BoundingBoxResultFile

Constructors

BoundingBoxResultFile() Constructor

Initializes a new instance of the BoundingBoxResultFile class.

public BoundingBoxResultFile();

Methods

BoundingBoxResultFile.ToString() Method

Returns a string representation of the bounding box results contained in the file, with each result on a new line.

public override string? ToString();

Returns

System.String
A string containing the concatenated string representations of all valid bounding box results.

ConfigurationFile Class

Represents the configuration settings for a YOLO project, including directory paths and labels.

public class ConfigurationFile

Inheritance System.Object → ConfigurationFile

Constructors

ConfigurationFile() Constructor

Initializes a new instance of the ConfigurationFile class.

public ConfigurationFile();

ConfigurationFile(string, string, string, string, IEnumerable<Label>) Constructor

Initializes a new instance of the ConfigurationFile class with specified directory paths and labels.

public ConfigurationFile(string? directory, string? trainDirectoryName, string? validateDirectoryName, string? testDirectoryName, System.Collections.Generic.IEnumerable<DiGi.YOLO.Classes.Label>? labels);

Parameters

directory System.String

The base root directory path.

trainDirectoryName System.String

The relative name of the training directory.

validateDirectoryName System.String

The relative name of the validation directory.

testDirectoryName System.String

The relative name of the test directory.

labels System.Collections.Generic.IEnumerable<Label>

A collection of labels to be associated with this configuration.

Properties

ConfigurationFile.Directory Property

Gets the base root directory path.

public string? Directory { get; }

Property Value

System.String

ConfigurationFile.Labels Property

Gets the collection of labels associated with this configuration.

public System.Collections.Generic.IEnumerable<DiGi.YOLO.Classes.Label> Labels { get; }

Property Value

System.Collections.Generic.IEnumerable<Label>

Methods

ConfigurationFile.GetCategories() Method

Retrieves all categories defined within the configuration.

public System.Collections.Generic.IEnumerable<DiGi.YOLO.Enums.Category> GetCategories();

Returns

System.Collections.Generic.IEnumerable<Category>
An enumerable collection of Category values.

ConfigurationFile.GetDirectory(Category) Method

Gets the full combined path for a specific category.

public string? GetDirectory(DiGi.YOLO.Enums.Category category);

Parameters

category Category

The category for which to retrieve the full directory path.

Returns

System.String
The absolute path combining the base directory and the category folder, or null if not found or empty.

ConfigurationFile.GetDirectoryNames(Category) Method

Gets the relative directory name for a specific category.

public string? GetDirectoryNames(DiGi.YOLO.Enums.Category category);

Parameters

category Category

The category for which to retrieve the folder name.

Returns

System.String
The relative directory name, or null if not found or empty.

ConfigurationFile.ToString() Method

Returns a string representation of the configuration file, formatted for output or storage.

public override string? ToString();

Returns

System.String
A formatted string containing the base path, category paths, and label names.

Image Class

Represents an image associated with a collection of BoundingBox instances.

public class Image : DiGi.YOLO.Classes.Image<DiGi.YOLO.Classes.BoundingBox>

Inheritance System.Object → DiGi.YOLO.Classes.Image<BoundingBox> → Image

Constructors

Image(string) Constructor

Initializes a new instance of the Image class.

public Image(string? path);

Parameters

path System.String

The file path to the image.

Methods

Image.GetLabelFile() Method

Creates and populates a LabelFile containing all bounding boxes associated with this image.

public DiGi.YOLO.Classes.LabelFile GetLabelFile();

Returns

LabelFile
A LabelFile instance populated with the image's bounding box data.

Image<TBoundingBox> Class

Represents an image associated with a collection of bounding boxes categorized by label indices.

public class Image<TBoundingBox>
    where TBoundingBox : DiGi.YOLO.Interfaces.IBoundingBox

Type parameters

TBoundingBox

The type of the bounding box, which must implement IBoundingBox.

Inheritance System.Object → Image<TBoundingBox>

Derived
↳ Image

Constructors

Image(string) Constructor

Initializes a new instance of the Image<TBoundingBox> class.

public Image(string? path);

Parameters

path System.String

The file path to the image.

Fields

Image<TBoundingBox>.boundingBoxes Field

The dictionary containing bounding boxes grouped by label indices.

protected Dictionary<int,HashSet<TBoundingBox>> boundingBoxes;

Field Value

System.Collections.Generic.Dictionary<System.Int32,System.Collections.Generic.HashSet<TBoundingBox>>

Image<TBoundingBox>.path Field

The file path to the image.

protected string? path;

Field Value

System.String

Properties

Image<TBoundingBox>.LabelIndexes Property

Gets the collection of label indices that have associated bounding boxes in this image.

public System.Collections.Generic.IEnumerable<int> LabelIndexes { get; }

Property Value

System.Collections.Generic.IEnumerable<System.Int32>

Image<TBoundingBox>.Path Property

Gets the file path of the image.

public string? Path { get; }

Property Value

System.String

Image<TBoundingBox>.this[int] Property

Gets the set of bounding boxes associated with the specified label index.

public System.Collections.Generic.IEnumerable<TBoundingBox>? this[int labelIndex] { get; }

Parameters

labelIndex System.Int32

The index of the label to retrieve bounding boxes for.

Property Value

System.Collections.Generic.IEnumerable<TBoundingBox>

Methods

Image<TBoundingBox>.Add(int, TBoundingBox) Method

Adds a bounding box to the image for the specified label index.

public bool Add(int labelIndex, TBoundingBox? boundingBox);

Parameters

labelIndex System.Int32

The index of the label.

boundingBox TBoundingBox

The bounding box instance to add.

Returns

System.Boolean
True if the bounding box was successfully added; otherwise, false.

Label Class

Represents a label associated with an object detection class in YOLO.

public class Label

Inheritance System.Object → Label

Constructors

Label(int, string) Constructor

Initializes a new instance of the Label class.

public Label(int index, string? name);

Parameters

index System.Int32

The numerical index for the label.

name System.String

The descriptive name for the label.

Fields

Label.index Field

The numerical index of the label.

public int index;

Field Value

System.Int32

Label.name Field

The descriptive name of the label.

public string? name;

Field Value

System.String

Properties

Label.Index Property

Gets the numerical index of the label.

public int Index { get; }

Property Value

System.Int32

Label.Name Property

Gets the descriptive name of the label.

public string? Name { get; }

Property Value

System.String

Methods

Label.Equals(object) Method

Determines whether the specified object is equal to the current label based on its string representation.

public override bool Equals(object @object);

Parameters

object System.Object

The object to compare with the current label.

Returns

System.Boolean
True if the objects are equal; otherwise, false.

Label.GetHashCode() Method

Returns a hash code for the current label based on its string representation.

public override int GetHashCode();

Returns

System.Int32
A 32-bit signed integer hash code.

Label.ToString() Method

Returns a string that represents the current label.

public override string ToString();

Returns

System.String
A string containing the index and name of the label.

LabelFile Class

Represents a label file containing associations between class indices and bounding boxes for an image.

public class LabelFile

Inheritance System.Object → LabelFile

Constructors

LabelFile() Constructor

Initializes a new instance of the LabelFile class.

public LabelFile();

Fields

LabelFile.tuples Field

The collection of tuples pairing label indices with their corresponding bounding boxes.

public List<Tuple<int,BoundingBox>> tuples;

Field Value

System.Collections.Generic.List<System.Tuple<System.Int32,BoundingBox>>

Properties

LabelFile.Count Property

Gets the total number of entries in the label file.

public int Count { get; }

Property Value

System.Int32

Methods

LabelFile.Add(int, BoundingBox) Method

Adds a label index and its associated bounding box to the collection.

public bool Add(int labelIndex, DiGi.YOLO.Classes.BoundingBox? boundingBox);

Parameters

labelIndex System.Int32

The integer index of the label.

boundingBox BoundingBox

The bounding box associated with the label.

Returns

System.Boolean
True if the pair was successfully added; otherwise, false if the bounding box is null or the index is negative.

LabelFile.GetBoundingBox(int) Method

Retrieves the bounding box at the specified position.

public DiGi.YOLO.Classes.BoundingBox GetBoundingBox(int index);

Parameters

index System.Int32

The zero-based index of the entry to retrieve.

Returns

BoundingBox
The BoundingBox associated with the given position.

LabelFile.GetBoundingBoxes(int) Method

Retrieves all bounding boxes associated with a specific label index.

public System.Collections.Generic.List<DiGi.YOLO.Classes.BoundingBox> GetBoundingBoxes(int labelIndex);

Parameters

labelIndex System.Int32

The label index to filter by.

Returns

System.Collections.Generic.List<BoundingBox>
A list of BoundingBox objects matching the specified label index.

LabelFile.GetLabelIndex(int) Method

Retrieves the label index at the specified position.

public int GetLabelIndex(int index);

Parameters

index System.Int32

The zero-based index of the entry to retrieve.

Returns

System.Int32
The label index associated with the given position.

LabelFile.GetTagIndexes() Method

Retrieves a set of all unique tag indices present in the label file.

public System.Collections.Generic.HashSet<int> GetTagIndexes();

Returns

System.Collections.Generic.HashSet<System.Int32>
A System.Collections.Generic.HashSet<> containing the unique label indices.

LabelFile.ToString() Method

Returns a string representation of the label file, formatted as space-separated values per line.

public override string ToString();

Returns

System.String
A string containing the labels and bounding boxes separated by new lines.

YOLOModel Class

Represents a YOLO model structure that manages images, labels, and their associated categories and bounding boxes.

public class YOLOModel

Inheritance System.Object → YOLOModel

Constructors

YOLOModel() Constructor

Initializes a new instance of the YOLOModel class and sets up default directory paths for train, validate, and test categories.

public YOLOModel();

YOLOModel(ConfigurationFile) Constructor

Initializes a new instance of the YOLOModel class using the provided configuration file.

public YOLOModel(DiGi.YOLO.Classes.ConfigurationFile? configurationFile);

Parameters

configurationFile ConfigurationFile

The configuration file to initialize the model with.

YOLOModel(string) Constructor

Initializes a new instance of the YOLOModel class with a specified root directory and sets up default category paths.

public YOLOModel(string? directory);

Parameters

directory System.String

The base directory path for the model.

Properties

YOLOModel.Directory Property

Gets or sets the base directory path for the model data.

public string? Directory { get; set; }

Property Value

System.String

Methods

YOLOModel.Add(ConfigurationFile) Method

Adds the specified configuration file settings to the YOLO model.

public bool Add(DiGi.YOLO.Classes.ConfigurationFile? configurationFile);

Parameters

configurationFile ConfigurationFile

The configuration file containing directory and label information.

Returns

System.Boolean
True if the configuration was successfully added; otherwise, false.

YOLOModel.Add(Label) Method

Adds a specific Label object to the model's labels collection.

public bool Add(DiGi.YOLO.Classes.Label? label);

Parameters

label Label

The label object to add.

Returns

System.Boolean
True if the label was successfully added; otherwise, false.

YOLOModel.Add(string) Method

Adds a new label name to the model's labels collection if it does not already exist.

public bool Add(string? labelName);

Parameters

labelName System.String

The name of the label to add.

Returns

System.Boolean
True if the label was added; false if the label already exists or is invalid.

YOLOModel.Add(string, LabelFile) Method

Adds all labels and bounding boxes contained within a label file to an image at the given path.

public bool Add(string? path, DiGi.YOLO.Classes.LabelFile? labelFile);

Parameters

path System.String

The file path of the image.

labelFile LabelFile

The label file containing annotation data.

Returns

System.Boolean
True if at least one bounding box was successfully added; otherwise, false.

YOLOModel.Add(string, Category[]) Method

Associates an image at the specified path with one or more categories.

public bool Add(string? path, params DiGi.YOLO.Enums.Category[]? categories);

Parameters

path System.String

The file path of the image.

categories Category[]

An array of categories to assign to the image.

Returns

System.Boolean
True if the image and categories were successfully added; otherwise, false.

YOLOModel.Add(string, string, BoundingBox) Method

Adds a bounding box for a specific label to an image at the given path.

public bool Add(string? path, string? labelName, DiGi.YOLO.Classes.BoundingBox? boundingBox);

Parameters

path System.String

The file path of the image.

labelName System.String

The name of the label associated with the bounding box.

boundingBox BoundingBox

The bounding box coordinates and dimensions.

Returns

System.Boolean
True if the bounding box was successfully added to the image; otherwise, false.

YOLOModel.GetCategories() Method

Retrieves a collection of all unique categories currently stored in the model.

public System.Collections.Generic.IEnumerable<DiGi.YOLO.Enums.Category>? GetCategories();

Returns

System.Collections.Generic.IEnumerable<Category>
An enumerable containing all registered Category values.

YOLOModel.GetCategories(string) Method

Retrieves the collection of categories associated with the specified path.

public System.Collections.Generic.IEnumerable<DiGi.YOLO.Enums.Category>? GetCategories(string? path);

Parameters

path System.String

The directory path to look up categories for.

Returns

System.Collections.Generic.IEnumerable<Category>
An enumerable of Category if found; otherwise, null.

YOLOModel.GetConfigurationFile() Method

Creates and returns a ConfigurationFile instance based on the current model configuration.

public DiGi.YOLO.Classes.ConfigurationFile? GetConfigurationFile();

Returns

ConfigurationFile
A ConfigurationFile object representing the current settings.

YOLOModel.GetDirectory_Images() Method

Retrieves the full path to the base images directory.

public string? GetDirectory_Images();

Returns

System.String
The combined path string if the base directory is set; otherwise, null.

YOLOModel.GetDirectory_Images(Category) Method

Retrieves the full path to the images directory for the specified category using the model's current base directory.

public string? GetDirectory_Images(DiGi.YOLO.Enums.Category category);

Parameters

category Category

The category (e.g., Train, Validate, Test) to locate.

Returns

System.String
The combined path string if successful; otherwise, null.

YOLOModel.GetDirectory_Images(string, Category) Method

Retrieves the full path to the images directory for a specific category within a provided root directory.

public string? GetDirectory_Images(string? directory, DiGi.YOLO.Enums.Category category);

Parameters

directory System.String

The root directory path.

category Category

The category (e.g., Train, Validate, Test) to locate.

Returns

System.String
The combined path string if the root directory is valid; otherwise, null.

YOLOModel.GetDirectory_Labels() Method

Retrieves the full path to the labels directory by deriving it from the images directory path.

public string? GetDirectory_Labels();

Returns

System.String
The combined path string for labels if successful; otherwise, null.

YOLOModel.GetDirectory_Labels(Category) Method

Retrieves the labels directory path for a specific category using the model's internal directory state.

public string? GetDirectory_Labels(DiGi.YOLO.Enums.Category category);

Parameters

category Category

The category associated with the directories.

Returns

System.String
The calculated path to the labels directory, or null.

YOLOModel.GetDirectory_Labels(string, Category) Method

Retrieves the labels directory path based on a provided image directory and category.

public string? GetDirectory_Labels(string? directory, DiGi.YOLO.Enums.Category category);

Parameters

directory System.String

The base directory path to evaluate.

category Category

The category associated with the directories.

Returns

System.String
The calculated path to the labels directory, or null if the provided directory is null or whitespace.

YOLOModel.GetImage(string) Method

Retrieves an image object associated with the specified file path.

public DiGi.YOLO.Classes.Image? GetImage(string? path);

Parameters

path System.String

The file path of the image.

Returns

Image
The Image object if found in the model; otherwise, null.

YOLOModel.GetImages(Category) Method

Retrieves all images that belong to a specific category.

public System.Collections.Generic.IEnumerable<DiGi.YOLO.Classes.Image> GetImages(DiGi.YOLO.Enums.Category category);

Parameters

category Category

The category used to filter the images.

Returns

System.Collections.Generic.IEnumerable<Image>
An enumerable collection of Image objects belonging to the specified category.

YOLOModel.GetLabel(int) Method

Retrieves a label based on its unique integer index.

public DiGi.YOLO.Classes.Label? GetLabel(int labelIndex);

Parameters

labelIndex System.Int32

The index of the label to retrieve.

Returns

Label
The Label object if found; otherwise, null.

YOLOModel.GetLabelFile(string) Method

Retrieves the label file associated with the image at the specified path.

public DiGi.YOLO.Classes.LabelFile? GetLabelFile(string? path);

Parameters

path System.String

The file path of the image.

Returns

LabelFile
The LabelFile object if found; otherwise, null.

YOLOModel.GetLabels() Method

Retrieves all labels defined within the model.

public System.Collections.Generic.IEnumerable<DiGi.YOLO.Classes.Label> GetLabels();

Returns

System.Collections.Generic.IEnumerable<Label>
An enumerable collection of all available Label objects.

YOLOModel.GetLabels(string) Method

Retrieves all labels associated with the image at the specified path.

public System.Collections.Generic.IEnumerable<DiGi.YOLO.Classes.Label>? GetLabels(string? path);

Parameters

path System.String

The file path of the image.

Returns

System.Collections.Generic.IEnumerable<Label>
An enumerable collection of Label objects associated with the image, or null if no labels are found.

YOLOModel.LabelIndex(string) Method

Retrieves the index of a label based on its name.

public int LabelIndex(string? labelName);

Parameters

labelName System.String

The name of the label to search for.

Returns

System.Int32
The integer index of the label if found; otherwise, -1.

YOLOPredictionOptions Class

Provides the settings one run of the YOLO prediction script needs: which interpreter runs it, which weights it scores with, which images it reads, and where it writes its results.

The constructors only assign. Use YOLOPredictionOptions(string, string, string, string, string, double) to resolve the interpreter, tidy the paths and reject a combination that cannot make a run.

public class YOLOPredictionOptions : DiGi.Core.Classes.SerializableOptions, DiGi.YOLO.Interfaces.IYOLOSerializableObject, DiGi.YOLO.Interfaces.IYOLOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject

Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → DiGi.Core.Classes.SerializableOptions → YOLOPredictionOptions

Implements IYOLOSerializableObject, IYOLOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject

Constructors

YOLOPredictionOptions() Constructor

Initializes a new instance of the YOLOPredictionOptions class with default values.

public YOLOPredictionOptions();

YOLOPredictionOptions(YOLOPredictionOptions) Constructor

Initializes a new instance of the YOLOPredictionOptions class by copying an existing options instance.

public YOLOPredictionOptions(DiGi.YOLO.Classes.YOLOPredictionOptions? yOLOPredictionOptions);

Parameters

yOLOPredictionOptions YOLOPredictionOptions

The source options instance to copy from.

YOLOPredictionOptions(JsonObject) Constructor

Initializes a new instance of the YOLOPredictionOptions class using a JSON object.

public YOLOPredictionOptions(System.Text.Json.Nodes.JsonObject? jsonObject);

Parameters

jsonObject System.Text.Json.Nodes.JsonObject

The JSON object containing the configuration settings.

Properties

YOLOPredictionOptions.Confidence Property

Gets or sets the confidence threshold a detection has to reach to be reported, passed to predict.py as --conf.

The default matches the script's own default. Lowering it returns more boxes and more false positives; the weights are frozen, so this is the only knob over how much the detector reports.

public double Confidence { get; set; }

Property Value

System.Double

YOLOPredictionOptions.ModelPath Property

Gets or sets the path of the trained weights file the prediction scores with, passed to predict.py as --model.

Left null the script falls back to its own search, which picks whichever training run is newest on disk. Name the file, so a run is reproducible.

public string? ModelPath { get; set; }

Property Value

System.String

YOLOPredictionOptions.OutputPath Property

Gets or sets the path of the bounding box result file the prediction writes, passed to predict.py as --output.

The script opens it for writing rather than appending, so re-running a source directory replaces the previous answer instead of doubling it.

public string? OutputPath { get; set; }

Property Value

System.String

YOLOPredictionOptions.PythonPath Property

Gets or sets the path of the CPython interpreter that runs the prediction script, or the name of one on PATH.

This has to be CPython with ultralytics and torch installed. The IronPython engine in DiGi.Scripting.Python cannot host either of them.

public string? PythonPath { get; set; }

Property Value

System.String

YOLOPredictionOptions.SourceDirectory Property

Gets or sets the directory holding the images to score, passed to predict.py as --source.

The script reads the .jpg, .jpeg and .png files directly in the directory and does not descend into it.

public string? SourceDirectory { get; set; }

Property Value

System.String

YOLOPredictionOptions.WorkingDirectory Property

Gets or sets the directory the prediction process runs in, which is also where the runner keeps the Python scripts.

predict.py imports utils.py, and Python resolves that import against the directory the script itself sits in, so the two files have to stay together. The runner puts them there with WriteScripts(string) when they are missing. Ultralytics also writes its own caches here.

public string? WorkingDirectory { get; set; }

Property Value

System.String

YOLOPredictionResult Class

Represents what one run of the YOLO prediction script did: how it ended, what it said, and the result lines it produced.

The detections are kept as the raw lines of the bounding box result file rather than as parsed objects, so that a result read back from JSON is the same result that was written. Parse them with BoundingBoxResultFile(this YOLOPredictionResult).

public class YOLOPredictionResult : DiGi.Core.Classes.SerializableResult, DiGi.YOLO.Interfaces.IYOLOSerializableObject, DiGi.YOLO.Interfaces.IYOLOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject

Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → DiGi.Core.Classes.SerializableResult → YOLOPredictionResult

Implements IYOLOSerializableObject, IYOLOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject

Constructors

YOLOPredictionResult(YOLOPredictionResult) Constructor

Initializes a new instance of the YOLOPredictionResult class by copying an existing result.

public YOLOPredictionResult(DiGi.YOLO.Classes.YOLOPredictionResult? yOLOPredictionResult);

Parameters

yOLOPredictionResult YOLOPredictionResult

The source result to copy from.

YOLOPredictionResult(int, int, string, IEnumerable<string>, IEnumerable<string>, IEnumerable<string>, Nullable<DateTimeOffset>, Nullable<DateTimeOffset>) Constructor

Initializes a new instance of the YOLOPredictionResult class.

public YOLOPredictionResult(int exitCode, int imageCount, string? outputPath, System.Collections.Generic.IEnumerable<string>? values, System.Collections.Generic.IEnumerable<string>? standardOutput, System.Collections.Generic.IEnumerable<string>? standardError, System.Nullable<System.DateTimeOffset> start, System.Nullable<System.DateTimeOffset> end);

Parameters

exitCode System.Int32

The code the prediction process ended with, or -1 when the runner never got one.

imageCount System.Int32

The number of images found in the source directory.

outputPath System.String

The path of the bounding box result file the run was told to write.

values System.Collections.Generic.IEnumerable<System.String>

The lines of the bounding box result file the run produced.

standardOutput System.Collections.Generic.IEnumerable<System.String>

The trailing lines the process wrote to its standard output stream.

standardError System.Collections.Generic.IEnumerable<System.String>

The trailing lines the process wrote to its standard error stream.

start System.Nullable<System.DateTimeOffset>

The moment the run began.

end System.Nullable<System.DateTimeOffset>

The moment the run ended.

YOLOPredictionResult(JsonObject) Constructor

Initializes a new instance of the YOLOPredictionResult class using a JSON object.

public YOLOPredictionResult(System.Text.Json.Nodes.JsonObject? jsonObject);

Parameters

jsonObject System.Text.Json.Nodes.JsonObject

The JSON object containing the result data.

Properties

YOLOPredictionResult.Duration Property

Gets how long the run took, or null when either end of it is unknown.

public System.Nullable<System.TimeSpan> Duration { get; }

Property Value

System.Nullable<System.TimeSpan>

YOLOPredictionResult.End Property

Gets the moment the run ended.

public System.Nullable<System.DateTimeOffset> End { get; }

Property Value

System.Nullable<System.DateTimeOffset>

YOLOPredictionResult.ExitCode Property

Gets the code the prediction process ended with. Zero means it ran to completion.

-1 is the runner's own code for a run it never handed to the interpreter or took back from it - the process could not be started, the source directory was gone, or the run was cancelled. StandardError carries the reason in the first two cases; a caller that cancelled already knows about the third.

public int ExitCode { get; }

Property Value

System.Int32

YOLOPredictionResult.ImageCount Property

Gets the number of images found in the source directory.

Zero here with an exit code of zero is a run that had nothing to do, which is worth telling apart from a run that scored images and found nothing on them.

public int ImageCount { get; }

Property Value

System.Int32

YOLOPredictionResult.OutputPath Property

Gets the path of the bounding box result file the run was told to write.

public string? OutputPath { get; }

Property Value

System.String

YOLOPredictionResult.StandardError Property

Gets the trailing lines the process wrote to its standard error stream, at most OutputLines of them.

public System.Collections.Generic.List<string>? StandardError { get; }

Property Value

System.Collections.Generic.List<System.String>

YOLOPredictionResult.StandardOutput Property

Gets the trailing lines the process wrote to its standard output stream, at most OutputLines of them.

public System.Collections.Generic.List<string>? StandardOutput { get; }

Property Value

System.Collections.Generic.List<System.String>

YOLOPredictionResult.Start Property

Gets the moment the run began.

public System.Nullable<System.DateTimeOffset> Start { get; }

Property Value

System.Nullable<System.DateTimeOffset>

YOLOPredictionResult.Succeeded Property

Gets a value indicating whether the run completed and produced its result file.

public bool Succeeded { get; }

Property Value

System.Boolean

YOLOPredictionResult.Values Property

Gets the lines of the bounding box result file the run produced, or null when it produced none.

An empty list is a run that scored images and detected nothing; null is a run that wrote no file at all.

public System.Collections.Generic.List<string>? Values { get; }

Property Value

System.Collections.Generic.List<System.String>

Clone this wiki locally