MLPredictorExtensions
class NatML.MLPredictorExtensions
This class contains extension methods for working with predictors.
Async Predictions
Some models might not be able to run in realtime. This doesn't mean they can't be used; in fact many models run slower-than-realtime in interactive applications. In this situation, it becomes beneficial to run predictions asynchronously. NatML provides the MLAsyncPredictor
which is a wrapper around any existing predictor for this purpose:
The async predictor spins up a dedicated worker thread for making predictions, completely freeing up your app to perform other processing:
When making predictions in streaming applications (like in camera apps), you can check if the async predictor is ready to make more predictions, so as not to backup the processing queue:
Finally, you must Dispose
the predictor when you are done with it, so as not to leave threads and other resources dangling.
Do not use predictors from multiple threads. So once you create an MLAsyncPredictor
from an inner predictor, do not use the inner predictor.
Last updated