Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live object detection example, confidence is very low #137

Open
JobiJoba opened this issue Aug 29, 2023 · 12 comments
Open

Live object detection example, confidence is very low #137

JobiJoba opened this issue Aug 29, 2023 · 12 comments

Comments

@JobiJoba
Copy link

Hi,

I'm trying the example given in this repo live_object_detection_ssd_mobilenet but the confidence of what the camera see is very low (less than 0.5).

Is there a way to improve that? What are the variable that make the confidence that low?

I'm using a Oppo Reno 7Z
(I've downloaded the model using the script)
No errors in the debug console

Thanks

@gregorscholz
Copy link
Contributor

Can you please provide some screenshots? Maybe look at the label.txt. The model does not recognise that many things.

@JobiJoba
Copy link
Author

Hi, I'm using the default label.txt downloaded from the script (so there is like 96 entries).

I've the same setup as in the example gif so like a bottle of water / coffee cup / laptop :) the only thing he recognize with a high score of confidence is my table when I put the phone camera face down on it.

b7fc3740-224f-4dfa-b1d5-9ec129530837.mp4

If I change the confidence under 0.5 (I didn't change anything else in the code), you'll start to see some square detection but not fantastic as the confidence is very low :)

The object detection ssd mobile net example works well, if I take a picture of my laptop he recognize it.

So I'm not sure if the model is the issue in fact. The phone? Is there a list of compatible phone?

@gregorscholz
Copy link
Contributor

Maybe its the phone, do you have another phone you can test it with?

@nelzaatari
Copy link

im facing the same issue, on colab everything works fine, did anyone find any solution

@ghost
Copy link

ghost commented Oct 2, 2023

Hi everyone,

I believe I have found a bug. Changing ResolutionPreset from "medium" to "low" may improve accuracy. (I have only tested this on my Android device.)

@JobiJoba
Copy link
Author

Well this is shocking but using an older phone the example detect correctly ... a bug with Oppo Reno 7 ? -_-

@daniwaxman
Copy link

I have the same issue.

@JobiJoba
Copy link
Author

I start using flutter_vision which under the hood use tflite and obviously , have the same issue.

I've created another issue there with more detail in the hope someone have an idea why it's doing that or guide me through idea :)

vladiH/flutter_vision#36

@vianziro
Copy link

I have a different problem, I created a model using yolov5 and converted it to tflite. when I try my model, the detection process doesn't work, but in colab everything works normally.

@JobiJoba
Copy link
Author

Anyone would have an hint on what could be done to fix that issue?

I've tried another implementation (https://github.com/Pawandeep-prog/realtime_object_detection android only) on my Oppo Reno 7Z and that works perfectly, they use under the hood tflite also but it's a bit different from what is done in this project.

Unfortunately, it wasn't working on multiples phones so we had to find another solution with a webview but it would be nice to come back to a native solution (for performance reason).

@JobiJoba
Copy link
Author

For those having the same issue, i did the following to fix it:

instead of :

void _convertCameraImage(CameraImage cameraImage) {
   var preConversionTime = DateTime.now().millisecondsSinceEpoch;

   convertCameraImageToImage(cameraImage).then((image) {
     if (image != null) {
       if (Platform.isAndroid) {
         image = image_lib.copyRotate(image, angle: 90);
       }

       final results = analyseImage(image, preConversionTime);
       _sendPort.send(_Command(_Codes.result, args: [results]));
     }
   });
 }

I do

 void _convertCameraImage(CameraImage cameraImage) async {
    var preConversionTime = DateTime.now().millisecondsSinceEpoch;

    // var image = await ImageUtilsIsolate.convertCameraImage(cameraImage);
    var image = ImageUtils.convertCameraImage(cameraImage);
    if (image != null) {
      if (Platform.isAndroid) {
        image = image_lib.copyRotate(image, angle: 90);
      }

      // print("Image $image");
      final results = analyseImage(image, preConversionTime);
      _sendPort.send(_Command(_Codes.result, args: [results]));
    }
  }

I didn't test on many phone (2) but my phone which wasn't "detecting" anything can now detect without any issue at the speed of light :P

thanks a lot to the Pytorch Library which works wonderfully but unfortunately is not performant enough overall.

@yanghoonkim
Copy link

I tried to check the processed image using convertCameraImageToImage in image_utils.dart in live_object_detection_ssd_mobilenet example and found that it results in very strange image (both for ios and android).

Using the image_util.dart mentioned by @JobiJoba, it is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants