For text and images v13 introduces the ability to train detectors easy which result in ContentDetectorFunction
's. To use these IRL we need to export to python's torch & onnx libraries.
I'm looking for guidance (or a tutorial) on how this can be done for both images (object detection) and text (entity detection). Here's an outline of what I've tried for the image case:
Running the first example from ref/TrainImageContentDetector:
It can take a while, so I uploaded the result for you:
imgdf = Import @ URLDownload["https://www.dropbox.com/s/c84ghzpkndwhyci/imgdf.mx?dl=1", "~/Downloads/imgdf.mx"];
The resulting ContentDetectorFunction
object contains various keys:
But most important are "Net" and "Decoder". The first is a NetChain
which exports fine, but it seems we can't Export FunctionLayer
:
Export["~/Downloads/imgdf-net.onnx", imgdf[[1, "Net"]]]
Export["~/Downloads/imgdf-dec.onnx", NetGraph[imgdf[[1, "Decoder"]]]]
This is basically as far as I got, and I'm asking for help understanding the basics of pre-processing and post-processing that goes on with a ContentDetectorFunction
during inference.
Notes:
- Most of the spelunking will be in the private context file19YOLO`.
- I'm very familiar with the onnx runtime and torch, so if a developer or someone can clarify the missing things on the mma side: encoding, non-max suppression, and decoding. Then I will write up the equivalent python code for those missing parts and post it here.