Created
February 2, 2023 16:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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