mediappeのface_meshでエラー発生
python で下記のコードでエラーが出た。
import mediapipe as mp
import cv2
mp_face_mesh = mp.solutions.face_mesh
with mp_face_mesh.FaceMesh(max_num_faces=1, min_detection_confidence=0.5, static_image_mode=True) as face_mesh:
エラー出力
with mp_face_mesh.FaceMesh(max_num_faces=1, min_detection_confidence=0.5, static_image_mode=True) as face_mesh:
File "/opt/anaconda3/envs/pj_mp_cv/lib/python3.8/site-packages/mediapipe/python/solutions/face_mesh.py", line 95, in __init__
super().__init__(
File "/opt/anaconda3/envs/pj_mp_cv/lib/python3.8/site-packages/mediapipe/python/solution_base.py", line 248, in __init__
self._graph = calculator_graph.CalculatorGraph(
RuntimeError: ValidatedGraphConfig Initialization failed.
ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options.
ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options.
ImageToTensorCalculator: ; RET_CHECK failure (mediapipe/calculators/tensor/image_to_tensor_calculator.cc:144) ValidateOptionOutputDims(options) returned INTERNAL: ; RET_CHECK failure (./mediapipe/calculators/tensor/image_to_tensor_utils.h:136) options.has_output_tensor_float_range() || options.has_output_tensor_int_range() || options.has_output_tensor_uint_range()Output tensor range is required.
SplitTensorVectorCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions.
SplitTensorVectorCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions.
SplitTensorVectorCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions.
環境
ソフト
macOS 14.3
python 3.8.18 (3.11.8に上げても同じエラーが出た)
mediapipe 0.10.10
ハード
MacBook Air 2024
解決策
いろいろ調べた結果、mediapipeのバージョンを落とすとうまく動いた
エラーが発生するバージョン: 0.10.10, 0.10.11
エラーが発生しないバージョン: 0.10.9
mediapipe のバージョン確認
> pip list | grep mediapipe
mediapipe 0.10.11
バージョン0.10.9をインストール
> pip install mediapipe==0.10.9