#5138·mediapipe

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

Author: blaiseliouCreated Feb 12, 2024Updated Sep 30, 2026
Labelstype:supportplatform:iosstat:awaiting responsetask:hand landmarker

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

bash
 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

Source: google-ai-edge/mediapipe