Conversation
Closed
…ation Agent-Logs-Url: https://github.com/fourMs/MGT-python/sessions/37e34660-f746-453a-b428-74fc3f53285f Co-authored-by: alexarje <114316+alexarje@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fourMs/MGT-python/sessions/37e34660-f746-453a-b428-74fc3f53285f Co-authored-by: alexarje <114316+alexarje@users.noreply.github.com>
Agent-Logs-Url: https://github.com/fourMs/MGT-python/sessions/37e34660-f746-453a-b428-74fc3f53285f Co-authored-by: alexarje <114316+alexarje@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add GPU support for all functions
Implement GPU acceleration support across optical flow, face detection, and pose estimation
Apr 13, 2026
…ve imports to module level, add blur_faces and pose GPU tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GPU (CUDA) acceleration was only available for pose estimation. This adds opt-in GPU support to dense/sparse optical flow and face blurring, with automatic CPU fallback when CUDA is unavailable.
Changes
Shared utility
_utils.py: Addedget_cuda_device_count()— wrapscv2.cuda.getCudaEnabledDeviceCount()safely, returns 0 on failure. Exported from package root.GPU-accelerated functions
flow.dense(use_gpu=True): Usescv2.cuda.FarnebackOpticalFlowwhen available. Pre-allocates twocv2.cuda_GpuMatobjects and swaps references each frame to avoid per-frame GPU memory allocations.flow.sparse(use_gpu=True): Usescv2.cuda.SparsePyrLKOpticalFlowwith the same GpuMat reuse strategy for both frame buffers and tracked point arrays.blur_faces(use_gpu=True)/CenterFace(use_gpu=False): SetsDNN_BACKEND_CUDA/DNN_TARGET_CUDAon the ONNX network when CUDA is detected.pose(device='gpu'): Refactored to use the sharedget_cuda_device_count()instead of inline logic.All GPU paths fall back to CPU with an informative message if
cv2.cuda.FarnebackOpticalFlow/SparsePyrLKOpticalFloware absent (requireopencv-contribbuilt with CUDA) or no CUDA devices are found.Usage