How to build palm_detector.binarypb in Python?

86 views
Skip to first unread message

Danylo Ulianych

unread,
Feb 16, 2023, 9:24:07 AM2/16/23
to MediaPipe
I'd like to execute the palm detector module on Ubuntu in Python or CPP. I know there is the hand landmark module but I'm interested in palm detection only - I assume it's faster than the hand landmark graph (correct me if I'm wrong). It's strange that there is no tutorial on palm detection only and lots of hand landmark usages.
 I ran 
bazel --output_user_root=output_palm build --subcommands --verbose_failures -c opt --define MEDIAPIPE_DISABLE_GPU=1 --action_env PYTHON_BIN_PATH=/path/to/python mediapipe/modules/palm_detection:palm_detection_cpu --linkopt=-L/usr/local/lib
and copied the resulting "bazel-bin/mediapipe/modules/palm_detection/palm_detection_cpu.binarypb".
Then
I execute the following python script:

import cv2
from mediapipe.python.solution_base import SolutionBase

cap = cv2.VideoCapture(0)
with SolutionBase(
        binary_graph_path="palm_detection_cpu.binarypb",
        ) as palm_detector:
    while cap.isOpened():
        success, image = cap.read()
        if not success:
            continue
        image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        results = palm_detector.process(image_rgb)
        cv2.imshow('win', cv2.flip(image, 1))
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
cap.release()

and I'm getting this error:

packet.h:137 Check failed: typed_payload The Packet stores "tflite::ops::builtin::BuiltinOpResolver", but "tflite::OpResolver" was requested.

I'm not sure how to move forward. I would appreciate any help.

Thanks.
Reply all
Reply to author
Forward
0 new messages