Distributing Predictors
Sharing with the World
Last updated
Was this helpful?
Sharing with the World
Last updated
Was this helpful?
Predictors are designed to be shared. Whether you choose to open-source your predictor or sell it, here are some general guidelines:
We highly recommend packaging a predictor with the following layout:
You can use to generate a template predictor package that already has this layout, saving you time.
The foundational principle in designing the developer experience is to reduce cognitive load. The developer should not have to learn many--or ideally, any--new concepts in order to use your predictor.
Try to keep the number of public methods in your predictor at a minimum. Ideally, there should only be one public method: Predict
.
Most developers will simply not read the README
, so keeping it short and sweet would increase their chances of actually reading it.
NatML predictors have a typical usage pattern:
Create the predictor.
Use the output(s) directly, or call a post-processing method on the output(s).
Predictors must not deviate from this usage pattern. Specifically, the predictor must not have any public methods for feature pre- or post-processing.
If your predictor requires further post-processing before the outputs can be used, then your predictor should return an instance of an inner class. This inner class should expose a method to perform the required post-processing. This is a common pattern for computer vision predictors that output an image:
One advantage of this pattern is that the developer can run your post-processing code on the main thread, giving you full access to Unity API's.
Predictors should be written for maximum performance and minimal overhead. Predictors, along with any pre- or post-processors, must not use any performance-degrading API's that might have significant adverse effects on the entire app.
Predictor packages that use GPU readbacks (Texture2D.ReadPixels
, ComputeBuffer.GetData
) or Disk IO will be immediately rejected.
All public predictors on must pass a review process to ensure that they meet developer experience and performance standards. Below are the criteria used in the review process:
The README
should be the entrypoint for developers. Keeping in line with the considerations above, the README
should very quickly discuss how the predictor is used, .
Call with one or more features.
Predictors should be thread-safe, and should support background processing. As a result, the Predict
method should not use any Unity APIs which . This includes familiar classes like Texture2D
, RenderTexture
, ComputeShader
, and Job
.
If your predictor requires pre-processing on the main thread, you should instead create a CustomFeature
class which derives from and implements IMLEdgeFeature
or IMLCloudFeature
.
Finally, all public methods must be annotated with . This is critical for developers to know how to use different methods in your classes.