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

Invalid argument(s): Size of bounding box dimBouBoxension 1 is not 4. Got 25 in shape [1, 25] #240

Open
cahyowhy opened this issue Aug 23, 2023 · 1 comment

Comments

@cahyowhy
Copy link

got an error while running method BoundingBoxUtils.convert

E/flutter ( 8045): [ERROR:flutter/runtime/dart_isolate.cc(1097)] Unhandled exception:
E/flutter ( 8045): Invalid argument(s): Size of bounding box dimBouBoxension 1 is not 4. Got 25 in shape [1, 25]
E/flutter ( 8045): #0      SupportPreconditions.checkArgument (package:tflite_flutter_helper_plus/src/common/support_preconditions.dart:16:7)
E/flutter ( 8045): #1      BoundingBoxUtils.convert (package:tflite_flutter_helper_plus/src/image/bounding_box_utils.dart:74:26)
E/flutter ( 8045): #2      TfliteClassifier.predict (package:etlesigap/utils/object_detection/tflite_clasifier.dart:219:45)
E/flutter ( 8045): #3      IsolateimageClasifier.entryPoint (package:etlesigap/utils/object_detection/isolate_image_clasifier.dart:62:32)
E/flutter ( 8045): <asynchronous suspension>

this is my output shapes

[
    [1,25],
    [1,25,4],
    [1],
    [1,25]
]

and this is how i used

TensorBuffer outputLocations = TensorBufferFloat(_outputShapes[0]);
    TensorBuffer outputClasses = TensorBufferFloat(_outputShapes[1]);
    TensorBuffer outputScores = TensorBufferFloat(_outputShapes[2]);
    TensorBuffer numLocations = TensorBufferFloat(_outputShapes[3]);

    // Outputs map
    Map<int, Object> outputs = {
      0: outputLocations.buffer,
      1: outputClasses.buffer,
      2: outputScores.buffer,
      3: numLocations.buffer,
    };

    var inferenceTimeStart = DateTime.now().millisecondsSinceEpoch;

    // run inference
    _interpreter.runForMultipleInputs([inputImage.buffer], outputs);
    // _interpreter.runForMultipleInputs([inputImage.buffer.asUint8List()], outputs);

    var inferenceTimeElapsed =
        DateTime.now().millisecondsSinceEpoch - inferenceTimeStart;

    // Maximum number of results to show
    int resultsCount = min(numResults, numLocations.getIntValue(0));

    // Using labelOffset = 1 as ??? at index 0
    int labelOffset = 1;

    // Using bounding box utils for easy conversion of tensorbuffer to List<Rect>
    List<Rect> locations = BoundingBoxUtils.convert(
      // tensor: outputClasses,
      tensor: outputLocations,
      // valueIndex: [1, 0, 3, 2],
      valueIndex: [1, 3, 0, 2],
      boundingBoxAxis: 1,
      // boundingBoxAxis: 2,
      boundingBoxType: BoundingBoxType.boundaries,
      coordinateType: CoordinateType.ratio,
      height: inputSize,
      width: inputSize,
    );
@cahyowhy
Copy link
Author

my model props
Screenshot 2023-08-23 at 09 46 03

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

1 participant