Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on Windows 11: mediapipe version 0.10.18 and 0.10.20 #5838

Open
creativival opened this issue Jan 24, 2025 · 8 comments
Open

Not working on Windows 11: mediapipe version 0.10.18 and 0.10.20 #5838

creativival opened this issue Jan 24, 2025 · 8 comments
Assignees
Labels
os:windows MediaPipe issues on Windows platform:python MediaPipe Python issues stat:awaiting googler Waiting for Google Engineer's Response type:bug Bug in the Source Code of MediaPipe Solution

Comments

@creativival
Copy link

I have experimented with pip installation of MediaPipe to Windows 11.

  1. factory reset the laptop and boot Pure Windows 11
  2. install Python 3.12.8 from the Python official website
  3. install MediaPipe by "pip install mediapipe==0.10.14"
  4. run the app and get error “Import Error: DLL load failed while importing _framework_bindings"
  5. pip install msvc-runtime
  6. re-run the app and it launches normally

Now, when I upgrade MediaPipe, I get the same error.

  1. pip uninstall mediapipe
  2. pip install mediapipe=0.10.18
  3. when I start the app, I get the error “Import Error: DLL load failed while importing _framework_bindings”
  4. pip uninstall mediapipe
  5. pip install mediapipe== 0.10.20
  6. When you start the app, the error “Import Error: DLL load failed while importing _framework_bindings”
  7. pip uninstall mediapipe
  8. pip install mediapipe=0.10.14
  9. when the application is launched, it launches normally.

Based on the above verification, the new version cannot be launched on Windows 11.
In addition, the same problem occurs after installing the Visual C++ redistributable package.

Has anyone successfully installed and launched in a Windows 11 environment? Please let me know if there is a workaround.

@kuaashish kuaashish assigned kuaashish and unassigned kalyan2789g Jan 27, 2025
@kuaashish kuaashish added os:windows MediaPipe issues on Windows platform:python MediaPipe Python issues type:bug Bug in the Source Code of MediaPipe Solution labels Jan 27, 2025
@kuaashish
Copy link
Collaborator

Hi @creativival,

We attempted to reproduce the issue by installing MediaPipe versions 0.10.14, 0.10.18, and 0.10.20 on Windows 11 with Python 3.12.8. While the installation was successful, we encountered the same error as you when attempting to import MediaPipe.
Image

However, after installing msvc-runtime using pip install msvc-runtime, we were able to successfully import MediaPipe.

Image Image

Could you please try installing msvc-runtime and check if the issue is resolved? If the problem persists, kindly provide the complete error logs along with your Windows version details.

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Jan 28, 2025
@creativival
Copy link
Author

creativival commented Jan 28, 2025

Hi @kuaashish

Thanks for your reply.

As you said, “import mediapipe” is possible in the latest version (0.10.20), but the following Pose Landmarks sample code gives an error “Import Error: DLL load failed while importing _framework_bindings".

Image

It worked fine in the older version (0.10.14).

Image

Please try the following code with “image.jpg” and “pose_landmarker.task” in the same directory.

I installed the following libraries: "pip install mediapipe opencv-python msvc-runtime"

My environment: Windows 11 Pro 23H2 + Python 3.12.8 (Official) + VS Code

Thank you!!

Sample code is a modified version of the official python sample code for colab to work locally.

import mediapipe as mp
from mediapipe.tasks import python
from mediapipe.tasks.python import vision
from mediapipe.framework.formats import landmark_pb2
import numpy as np
import cv2


def draw_landmarks_on_image(rgb_image, detection_result):
  # RGB → BGRに変換
  bgr_image = cv2.cvtColor(rgb_image, cv2.COLOR_RGB2BGR)
  annotated_image = np.copy(bgr_image)

  pose_landmarks_list = detection_result.pose_landmarks

  # Loop through the detected poses to visualize.
  for idx in range(len(pose_landmarks_list)):
    pose_landmarks = pose_landmarks_list[idx]

    # Draw the pose landmarks.
    pose_landmarks_proto = landmark_pb2.NormalizedLandmarkList()
    pose_landmarks_proto.landmark.extend([
      landmark_pb2.NormalizedLandmark(x=landmark.x, y=landmark.y, z=landmark.z) for landmark in pose_landmarks
    ])
    mp.solutions.drawing_utils.draw_landmarks(
      annotated_image,
      pose_landmarks_proto,
      mp.solutions.pose.POSE_CONNECTIONS,
      mp.solutions.drawing_styles.get_default_pose_landmarks_style())

  # BGR → RGBに変換
  annotated_image_rgb = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
  return annotated_image_rgb

# STEP 2: Create an PoseLandmarker object.
# base_options = python.BaseOptions(model_asset_path='pose_landmarker.task')  # macOS
base_options = python.BaseOptions(model_asset_buffer=open('pose_landmarker.task', "rb").read())  # Windows
options = vision.PoseLandmarkerOptions(
    base_options=base_options,
    output_segmentation_masks=True)
detector = vision.PoseLandmarker.create_from_options(options)

# STEP 3: Load the input image.
image = mp.Image.create_from_file("image.jpg")

# STEP 4: Detect pose landmarks from the input image.
detection_result = detector.detect(image)

# STEP 5: Process the detection result. In this case, visualize it.
annotated_image = draw_landmarks_on_image(image.numpy_view(), detection_result)
cv2.imshow('', cv2.cvtColor(annotated_image, cv2.COLOR_RGB2BGR))
cv2.waitKey(0)
cv2.destroyAllWindows()

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting for user response label Jan 28, 2025
@kuaashish
Copy link
Collaborator

Hi @creativival,

Thank you for sharing the modified code. However, we are still unable to reproduce the issue. The sample code is working fine in my VS Code environment when using image.jpg and the task file in the same directory and this code.

import mediapipe as mp
from mediapipe.tasks import python
from mediapipe.tasks.python import vision
from mediapipe.framework.formats import landmark_pb2
import numpy as np
import cv2


def draw_landmarks_on_image(rgb_image, detection_result):
  # RGB → BGRに変換
  bgr_image = cv2.cvtColor(rgb_image, cv2.COLOR_RGB2BGR)
  annotated_image = np.copy(bgr_image)

  pose_landmarks_list = detection_result.pose_landmarks

  # Loop through the detected poses to visualize.
  for idx in range(len(pose_landmarks_list)):
    pose_landmarks = pose_landmarks_list[idx]

    # Draw the pose landmarks.
    pose_landmarks_proto = landmark_pb2.NormalizedLandmarkList()
    pose_landmarks_proto.landmark.extend([
      landmark_pb2.NormalizedLandmark(x=landmark.x, y=landmark.y, z=landmark.z) for landmark in pose_landmarks
    ])
    mp.solutions.drawing_utils.draw_landmarks(
      annotated_image,
      pose_landmarks_proto,
      mp.solutions.pose.POSE_CONNECTIONS,
      mp.solutions.drawing_styles.get_default_pose_landmarks_style())

  # BGR → RGBに変換
  annotated_image_rgb = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
  return annotated_image_rgb

# STEP 2: Create an PoseLandmarker object.
# base_options = python.BaseOptions(model_asset_path='pose_landmarker.task')  # macOS
base_options = python.BaseOptions(model_asset_buffer=open('C:\Users\kuaashish\Downloads\pose_landmarker_full.task', "rb").read())  # Windows
options = vision.PoseLandmarkerOptions(
    base_options=base_options,
    output_segmentation_masks=True)
detector = vision.PoseLandmarker.create_from_options(options)

# STEP 3: Load the input image.
image = mp.Image.create_from_file("C:\Users\kuaashish\Downloads\Pose.jpg")

# STEP 4: Detect pose landmarks from the input image.
detection_result = detector.detect(image)

# STEP 5: Process the detection result. In this case, visualize it.
annotated_image = draw_landmarks_on_image(image.numpy_view(), detection_result)
cv2.imshow('', cv2.cvtColor(annotated_image, cv2.COLOR_RGB2BGR))
cv2.waitKey(0)
cv2.destroyAllWindows()

As shown in the attached screenshot

Image

Could you try creating a new Python environment and reinstalling MediaPipe from scratch?

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Jan 29, 2025
@creativival
Copy link
Author

Hi @kuaashish

I found the cause of the bug.

When reinstalling Windows 11, if I choose “Local reinstall”, I get the error “Import Error: DLL load failed while importing _framework_bindings” when I run the above Issue.py
If I choose “Cloud download”, it works fine.

Image

Another Isuue

There is another issue that may be related to this: the same error occurs in the import order with the Panda3D library.

Steps to reproduce

Install the library with “pip install mediapipe panda3d”.
Run interactive mode

>> from direct.showbase.ShowBase import ShowBase
>> import mediapipe

Error “Import Error: DLL load failed while importing _framework_bindings

Image

This occurs with “0.10.18” and “0.10.20” and not with “0.10.14”. Please verify.

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting for user response label Jan 30, 2025
@kuaashish
Copy link
Collaborator

Hi @creativival,

We have identified another issue and will bring it to our team's attention. However, if you previously had no issues importing MediaPipe and later imported other dependencies, you can avoid the error by using versions 0.10.18 or 0.10.20, as shown below.

Image

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Jan 31, 2025
@creativival
Copy link
Author

Hi @kuaashish

For the time being, we will be using version 0.10.14. We will not be changing the order of loading the libraries at this time, as it would complicate the code.

We hope that the _frame_work_bildings error will be resolved in the next version.

Thank you for your response. We will now close the Issue.

Bye!!

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting for user response label Jan 31, 2025
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@kuaashish kuaashish reopened this Feb 4, 2025
@kuaashish
Copy link
Collaborator

Hi @schmidt-sebastian,

We have reproduced the issue on our end, and it appears to be specific to Windows. The issue does not occur on macOS or Linux.

When importing one of the Pandas3D libraries first, followed by MediaPipe (version 0.10.20), the issue arises (as shown in the attached screenshot). However, everything works fine in version 0.10.14. Importing MediaPipe first resolves the issue in 0.10.20, but due to the complexity of our code structure, reordering imports is not a feasible solution.

Could you review this issue and check if a fix is possible?

Thank you!!

@kuaashish kuaashish added the stat:awaiting googler Waiting for Google Engineer's Response label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:windows MediaPipe issues on Windows platform:python MediaPipe Python issues stat:awaiting googler Waiting for Google Engineer's Response type:bug Bug in the Source Code of MediaPipe Solution
Projects
None yet
Development

No branches or pull requests

4 participants