mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

XCode iOS - ERROR: The model is not a valid Flatbuffer buffer

Open blaiseliou opened this issue 1 year ago • 7 comments

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

None

OS Platform and Distribution

iOS / Xcode

MediaPipe Tasks SDK version

0.10.9

Task name (e.g. Image classification, Gesture recognition etc.)

HandLandmarker

Programming Language and version (e.g. C++, Python, Java)

Swift 5

Describe the actual behavior

The model is not getting loaded by the HandLandmarker initializer

Describe the expected behaviour

It should not throw an error

Standalone code/steps you may have used to try to get what you need

 let modelPath = Bundle.main.path(forResource: "hand_landmarker",
                                            ofType: "task")

      let options = HandLandmarkerOptions()
      options.baseOptions.modelAssetPath = modelPath!
      options.runningMode = .image
      options.minHandDetectionConfidence = 0.5
      options.minHandPresenceConfidence = 0.5
      options.minTrackingConfidence = 0.5
      options.numHands = 1
      
      do {
          let handLandmarker = try HandLandmarker(options: options)
      } catch {
          print(error)
      }

Other info / Complete Logs

hand_landmarker.task is correctly added to the project and to the target (Bundle.main.path is not nil and I can see the path), however when trying to init the HandLandmarker object I get the following error: The model is not a valid Flatbuffer buffer ERROR: The model is not a valid Flatbuffer buffer

blaiseliou avatar Feb 12 '24 12:02 blaiseliou

Hi @blaiseliou,

Could you please provide additional information about the problem. Include the following details:

  • Outline the steps you are following to implement the Handlandmarker Task API based on the documentation.
  • Specify the operating system you are using, indicating whether it is an Intel or Apple Silicon-based macOS with macOS Version.
  • Provide the version of Xcode you are using.
  • Clarify whether you are testing the implementation on a simulator or a physical device. state the iOS version.

Providing this information will help us better understand and address the issue.

Thank you!!

kuaashish avatar Feb 13 '24 06:02 kuaashish

Hi @kuaashish , Thanks for coming back on it!

  • I took the following steps:

    • Added pod 'MediaPipeTasksVision' to the Podfile
    • Added hand_landmarker.task to the project and added to the target
    • Added the following code to my class:
     let modelPath = Bundle.main.path(forResource: "hand_landmarker", ofType: "task")

     let options = HandLandmarkerOptions()
     options.baseOptions.modelAssetPath = modelPath!
     options.runningMode = .image
     options.minHandDetectionConfidence = 0.5
     options.minHandPresenceConfidence = 0.5
     options.minTrackingConfidence = 0.5
     options.numHands = 1
     
     do {
         let handLandmarker = try HandLandmarker(options: options)
     } catch {
         print(error)
     }
  • I am using macOS Ventura 13.6 (Intel based)
  • XCode version 15.2
  • I am testing on a physical device, iPhone 13 17.2.1

blaiseliou avatar Feb 13 '24 09:02 blaiseliou

@schmidt-sebastian @kuaashish Let me know if you need any other information from my end.

blaiseliou avatar Feb 16 '24 12:02 blaiseliou

Hi @priankakariatyml,

Could you please take a look into this issue?

Thank you!!

kuaashish avatar Feb 22 '24 07:02 kuaashish

Have you solved this problem?

BaronWj avatar Jul 29 '24 09:07 BaronWj

Have you solved this problem?

We have not been able to reproduce this issue. Could you check if you are facing this with the latest version and if your model file is not corrupted?

We use https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/latest/hand_landmarker.task for our tests.

priankakariat avatar Jul 31 '24 05:07 priankakariat

Have you solved this problem?

We have not been able to reproduce this issue. Could you check if you are facing this with the latest version and if your model file is not corrupted?

We use https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/latest/hand_landmarker.task for our tests.

I have been able to reproduce this issue。 I also rely on MediaPipeTasksVision and MNNFaceDetection。 s.dependency 'MediaPipeTasksVision', '~> 0.10.14' s.dependency 'MNNFaceDetection', '~> 0.0.4'

As you can see, I don't know what caused it?

BaronWj avatar Aug 02 '24 07:08 BaronWj