mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

ValueError: Mobile SSD models are expected to have exactly 4 outputs, found 2

Open SamMakesIt opened this issue 1 year ago • 1 comments

I created a dataset using roboflow, and trained it using the colab. I have done this once before and it worked, but with this model i keep getting the ValueError: Mobile SSD models are expected to have exactly 4 outputs, found 2 error.

SamMakesIt avatar Aug 07 '24 14:08 SamMakesIt

I met the same error in android sample object_detection.

libofei2004 avatar Aug 09 '24 17:08 libofei2004

Closing and tracking in https://github.com/google-ai-edge/mediapipe-samples/issues/473

PaulTR avatar Jan 07 '25 20:01 PaulTR

I am still confused on how to convert the model such that it gets the same 4 outputs I was initially giving. I also saved the model using model.export_model(model.export_model(model_name=model_out, quantization_config=quantization_config)

Can someone tell me how to convert the trained model to obtain the 4 output (locations, classes, scores, detections)?

I was trying to run inference in C++ using the following code but it failed due to output mismatch:

    // https://www.tensorflow.org/lite/models/object_detection/overview#starter_model
    TfLiteTensor *output_locations =
        interpreter->tensor(interpreter->outputs()[0]);
    TfLiteTensor *output_classes =
        interpreter->tensor(interpreter->outputs()[1]);
    TfLiteTensor *output_scores =
        interpreter->tensor(interpreter->outputs()[2]);
    TfLiteTensor *output_detections =
        interpreter->tensor(interpreter->outputs()[3]);

architjaiswal avatar Apr 24 '25 15:04 architjaiswal