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

Update base_options.py Fix Windows Path Concatenation Issue with mode… #5722

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PeizhiYan
Copy link

Summary:
This PR addresses a bug in MediaPipe on Windows where specifying model_asset_path for MediaPipe tasks (such as FaceLandmarker) results in an invalid path concatenation. This error does not appear on Linux or macOS and occurs specifically when _TaskRunner concatenates the absolute model_asset_path with default internal paths, leading to issues such as errno=22 due to an invalid file path.

Issue Description:
When BaseOptions.model_asset_path is used on Windows, the underlying _TaskRunner component incorrectly concatenates the provided path with a directory in site-packages, leading to an inaccessible or incorrect path. This results in the error:

RuntimeError: Unable to open file at C:\Users\...\site-packages/C:\Users\...\face_landmarker.task, errno=22

The error occurs only on Windows, likely due to platform-specific handling of absolute paths.

Proposed Solution:

  1. Detecting the Windows platform.
  2. Attempting to load the model file directly into model_asset_buffer if model_asset_path is provided.
  3. Setting model_asset_path to None if the model is successfully loaded into model_asset_buffer, bypassing the problematic path concatenation in _TaskRunner.

…l_asset_path in MediaPipe Tasks

Summary:
This PR addresses a bug in MediaPipe on Windows where specifying model_asset_path for MediaPipe tasks (such as FaceLandmarker) results in an invalid path concatenation. This error does not appear on Linux or macOS and occurs specifically when _TaskRunner concatenates the absolute model_asset_path with default internal paths, leading to issues such as errno=22 due to an invalid file path.

Issue Description: 
When BaseOptions.model_asset_path is used on Windows, the underlying _TaskRunner component incorrectly concatenates the provided path with a directory in site-packages, leading to an inaccessible or incorrect path. This results in the error:

RuntimeError: Unable to open file at C:\Users\...\site-packages/C:\Users\...\face_landmarker.task, errno=22


The error occurs only on Windows, likely due to platform-specific handling of absolute paths.

Proposed Solution:
1)
Detecting the Windows platform.
2)
Attempting to load the model file directly into model_asset_buffer if model_asset_path is provided.
3)
Setting model_asset_path to None if the model is successfully loaded into model_asset_buffer, bypassing the problematic path concatenation in _TaskRunner.
Copy link

google-cla bot commented Nov 9, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant