google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.46k stars 5.15k forks source link

MnasNet classification using TfliteInferenceCalculator #461

Closed PrinceP closed 4 years ago

PrinceP commented 4 years ago

Models input is not getting loaded properly. The MnasNet is trained using Auto ML. Attached is the sample graph used and the tflite model. The tflite model is renamed to .zip for upload error.

hand_gesture_gpu.txt

mobile_net.zip

PrinceP commented 4 years ago

Hi @fanzhanggoogle, is there any issue with tflite calculator. Is pre-processing fine?

fanzhanggoogle commented 4 years ago

Hi, I don't see any reason it won't work. It should be fine at least on CPU unless you have custom TFlite ops. On GPU it might be trickier if some ops are not support. Could you share your log/error so that I can provide some guidance?

PrinceP commented 4 years ago

The code doesn't crash. For CPU, I have to check and get back. For GPU, the tflite_inference_calculator.cc gets stuck at the following code `
if (gpuinput) {

// Get input image sizes. const auto& inputindices = interpreter->inputs(); gpu_datain.resize(input_indices.size()); for (int i = 0; i < inputindices.size(); ++i) { const TfLiteTensor* tensor = interpreter->tensor(input_indices[0]); gpu_datain[i] = absl::make_unique(); gpu_datain[i]->elements = 1; for (int d = 0; d < tensor->dims->size; ++d) { // LOG(INFO) << "Tensors " << i << " - " << d << " - " <dims->data[d] << std::endl; gpu_datain[i]->elements *= tensor->dims->data[d]; } // Create and bind input buffer. RET_CHECK_CALL( ::tflite::gpu::gl::CreateReadWriteShaderStorageBuffer( gpu_datain[i]->elements, &gpu_datain[i]->buffer)); RET_CHECKEQ(TfLiteGpuDelegateBindBufferToTensor( delegate, gpu_datain[i]->buffer.id(), interpreter_->inputs()[i]), kTfLiteOk); } } ` Create and bind input buffer doesn't work.

PrinceP commented 4 years ago

I was able to run the Efficient net on the pipeline. The fp32 model works fine.