xAlpharax / YOLO-Flutter

You Only Look Once (YOLO) application in Flutter, built as part of my entry at EUCYS 2023, representing Romania in Brussels.
GNU Affero General Public License v3.0
11 stars 2 forks source link

two models at once #3

Open neryabCommitted opened 4 months ago

neryabCommitted commented 4 months ago

hey, because of budget consideration I'm forced to run two yolo models at the same time (instead of training one that combines them).

it it possible with flutterVision?

from what i've seen for some reason it only inference the second model loaded

Future<void> loadYoloModel() async {
    await vision1.loadYoloModel(
      labels: 'assets/labels1.txt',
      modelPath: 'assets/model1.tflite',
      modelVersion: "yolov5",
      numThreads: 4,
      useGpu: true,
    );

    await vision2.loadYoloModel(
      labels: 'assets/labels2.txt',
      modelPath: 'assets/model2.tflite',
      modelVersion: "yolov5",
      numThreads: 4,
      useGpu: true,
    );
  }
xAlpharax commented 4 months ago

Hi there! Sorry for the late reply. As far as I've seen, flutter vision is not intended for inference of 2 models at the same time. But explain your situation better, and maybe I can help you fit everything into a single model through some techniques. We may be able to path the package, but I wouldn't spend time modifying it if I were you. You're better off taking a smarter approach as for your model.

neryabCommitted commented 4 months ago

well, I have one model that detecting some classes (YOLOv5s as is), and another that detecting a specific group of objects that are not a part of the 80 YOLOv5s is detecting. I know i can build the necessary dataset and train a new model to detect all of the combined classes, but i don't have the time or the money for that at the moment so the goal is for the time being is to inference each frame twice one for each model, and then i have some logic to combine the results and display them.

xAlpharax commented 4 months ago

well that seems to be very expensive computationally even if you achieve it... how many classes that aren t in the yolo v5 are we talking about? 2, 10, 100?

neryabCommitted commented 4 months ago

5 more classes, I'm aware its expensive computationally, but I've already done it in python and it is totally usable (the frame rate doesn't drop so much that its becoming noticeable)

xAlpharax commented 4 months ago

5 more classes, I'm aware its expensive computationally, but I've already done it in python and it is totally usable (the frame rate doesn't drop so much that its becoming noticeable)

you could merge the 2 yolo models, i believe if you look over to ultralytics they have guides on that. it should be the easiest way.

xAlpharax commented 4 months ago

https://docs.ultralytics.com/yolov5/tutorials/model_ensembling/#test-normally

neryabCommitted commented 4 months ago

I've seen that, it only works if the models have the same number of classes.

Thank you for your time, we've given up on this for now and we'll train a model combining the classes when we'll have the time and money for it.

xAlpharax commented 4 months ago

I've seen that, it only works if the models have the same number of classes.

Thank you for your time, we've given up on this for now and we'll train a model combining the classes when we'll have the time and money for it.

You re welcome, I would ve liked to be more helpful but frankly I'm not all that knowledgeable about these neiche lite libraries for inference like flutter_vision. I picked flutter_vision for this project because it has been the most reliable for what I needed it to do for me.