photonvision icon indicating copy to clipboard operation
photonvision copied to clipboard

Support selecting Object Detection models

Open Alextopher opened this issue 1 year ago • 7 comments

It is going to take me a while to implement #1354 as I've got a lot to learn about the project and the tools :sweat_smile:

This (draft) PR is for part 1 of the implementation. It focuses on adding a model selection interface for models that exist in photonvision_config/models/. Upon completion we can ship more than 1 model and users could upload their own through ssh without deleting the shipped model.

TODO List

  • [x] Initial rewrite NeuralNetworkModelManager
  • [x] RknnDetectionPipe parameters
  • [x] Frontend UI ~~- [ ] Update docs~~

Removing documentation milestone from this PR because there are likely to be a lot of object detection changes this year making any docs I write out of date by the time the fall comes around.

Alextopher avatar Jul 02 '24 02:07 Alextopher

Sadly I think I need to click the approve workflow button every time you push until you make at least one contribution

mcm001 avatar Jul 02 '24 03:07 mcm001

Sadly I think I need to click the approve workflow button every time you push until you make at least one contribution

Skill issue on my part. Sorry!

Alextopher avatar Jul 02 '24 03:07 Alextopher

What do we think about the design for defining model labels?

note-640-640-yolov5s-labels.txt
note-640-640-yolov5s.rknn

My thought process is that someday when we are able to support uploading models in different formats we might see something like:

note-640-640-yolov5s-labels.txt
note-640-640-yolov5s.onnx
note-640-640-yolov5s.rknn
note-640-640-yolov5s.tflite

Alextopher avatar Jul 02 '24 03:07 Alextopher

I think that potential conflict (with keeping track of label names/number of classes across different model types with the same name) makes me a little scared.

mcm001 avatar Jul 02 '24 04:07 mcm001

different model types

What I'm going for is all those files encode the same "model" - just in different file formats. The difference between onnx and rknn isn't topological, both have the same weights & structure, it's just they use a different format for encoding.

The metadata format I'm going for is name-width-height-model.format.

The alternative is you have multiple copies of the same model (keyed by '"name"`) and you risk screwing up writing the labels file.

Alextopher avatar Jul 02 '24 09:07 Alextopher

I feel pretty good about the implementation so far. I have a question, how can I go about getting the list of available models from core to the client? I need to give the UI a List<String>.

Alextopher avatar Jul 02 '24 13:07 Alextopher

Ready for review - if someone is able to test this code running on hardware that would be great.

Alextopher avatar Jul 04 '24 16:07 Alextopher

At the moment this is hung up on extracting models from the JAR. There is some kind of platform dependency - I'll work through it and move on to testing the actual implementation.

Alextopher avatar Aug 09 '24 14:08 Alextopher

I'm preparing a more reviewable patch set!

Alextopher avatar Sep 19 '24 06:09 Alextopher

@mcm001 I think this is the minimum abstractions needed to start #1340 and the uploading part of #1354

Alextopher avatar Sep 19 '24 08:09 Alextopher

To have a second model to test with I just copied the existing one but slightly changed the name.

cp photon-server/src/main/resources/models/note-640-640-yolov5s.rknn photon-server/src/main/resources/models/note-640-640-yolov5m.rknn
cp photon-server/src/main/resources/models/note-640-640-yolov5s-labels.txt photon-server/src/main/resources/models/note-640-640-yolov5m-labels.txt

Alextopher avatar Sep 19 '24 08:09 Alextopher