Skip to content

Instantly share code, notes, and snippets.

@olokobayusuf
Created February 2, 2023 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olokobayusuf/a66c86622045d2a803bca48fbb3d104e to your computer and use it in GitHub Desktop.
Save olokobayusuf/a66c86622045d2a803bca48fbb3d104e to your computer and use it in GitHub Desktop.
Performing object detection on the contents of a render texture with the YOLOX model.
void Detect (RenderTexture renderTexture) {
// Create the YOLOX model
var model = await MLEdgeModel.Create("@natsuite/yolox");
// Create the YOLOX predictor
var predictor = new YOLOXPredictor(model);
// Readback the render texture
AsyncGPUReadback.Request(renderTexture, request => {
// Create an image feature
var feature = new MLImageFeature(request.GetData<byte>(), request.width, request.height);
// Predict
var detections = predictor.Predict(feature);
// Dispose model
model.Dispose();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment