mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

FPS issue in pose tracker solution

Open Gojo1729 opened this issue 3 years ago • 10 comments

System information (Please provide as much relevant information as possible)

  • Have I written custom code (as opposed to using a stock example script provided in MediaPipe): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04, Android 11, iOS 14.4): Android 12
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: Realme X7 5G
  • Programming Language and version ( e.g. C++, Python, Java): Kotlin
  • MediaPipe version: v0.8.10
  • Bazel version (if compiling from source): bazel 5.2.0
  • Solution ( e.g. FaceMesh, Pose, Holistic ): Pose tracker

Describe the expected behavior: I'm running pose tracker on my device, the Android phone is pretty new one and is capable of 30fps processing. The issue is I'm not getting 30fps on my phone for pose tracker, so when I profiled I'm can see the fps is too low for each calculator (8 FPS).

Trace file - 9.zip My graph looks like this -

input_stream: "image"

# Output image with rendered results. (GpuBuffer)
# output_stream: "output_video"
# Pose landmarks. (NormalizedLandmarkList)
output_stream: "pose_landmarks"

output_stream: "throttled_input_video"

node {
  calculator: "FromImageCalculator"
  input_stream: "IMAGE:image"
  output_stream: "IMAGE_GPU:input_video"
  output_stream: "SOURCE_ON_GPU:is_gpu_image"
}

# Throttles the images flowing downstream for flow control. It passes through
# the very first incoming image unaltered, and waits for downstream nodes
# (calculators and subgraphs) in the graph to finish their tasks before it
# passes through another image. All images that come in while waiting are
# dropped, limiting the number of in-flight images in most part of the graph to
# 1. This prevents the downstream nodes from queuing up incoming images and data
# excessively, which leads to increased latency and memory usage, unwanted in
# real-time mobile applications. It also eliminates unnecessarily computation,
# e.g., the output produced by a node may get dropped downstream if the
# subsequent nodes are still busy processing previous inputs.

# https://github.com/google/mediapipe/blob/4a20e9909d55838d5630366ce719844cf06ae85c/mediapipe/calculators/core/flow_limiter_calculator.cc#L39
node {
  calculator: "FlowLimiterCalculator"
  input_stream: "input_video"
  input_stream: "FINISHED:pose_landmarks"
  input_stream_info: {
    tag_index: "FINISHED"
    back_edge: true
  }
  output_stream: "throttled_input_video"
  options: {
    [mediapipe.FlowLimiterCalculatorOptions.ext] {
      max_in_flight: 1
      max_in_queue: 1
    }
  }
}


# Subgraph that detects poses and corresponding landmarks.
node {
  calculator: "PoseLandmarkGpu"
  input_side_packet: "ENABLE_SEGMENTATION:enable_segmentation"
  input_side_packet: "MODEL_COMPLEXITY:model_complexity"
  input_side_packet: "SMOOTH_LANDMARKS:smooth_landmarks"
  input_side_packet: "USE_PREV_LANDMARKS:use_prev_landmarks"
  input_stream: "IMAGE:throttled_input_video"
  output_stream: "LANDMARKS:pose_landmarks"
  output_stream: "SEGMENTATION_MASK:segmentation_mask"
  output_stream: "DETECTION:pose_detection"
  output_stream: "ROI_FROM_LANDMARKS:roi_from_landmarks"
}

I'm using pose_detection.tflite and pose_landmark_litetflite.

Other info / Complete Logs :

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached:

Trace file - 9.zip

Gojo1729 avatar Jul 20 '22 12:07 Gojo1729

@kostyaby Any insights on this ?

Gojo1729 avatar Jul 20 '22 12:07 Gojo1729

Hey @Gojo1729,

Unfortunately I'm not involved in the pose tracker development, so it's hard to tell why is it giving you 9 FPS. I agree that Realme X7 5G is a decent Android phone (geekbench), so I'd be expecting 30 FPS from it too - but I'm not sure I fully understand the current performance profile for the pose tracker

@ivan-grishchenko any ideas?

kostyaby avatar Jul 20 '22 20:07 kostyaby

Hey @ivan-grishchenko any suggestions ?

Gojo1729 avatar Jul 21 '22 17:07 Gojo1729

@ivan-grishchenko any suggestions on this ?

Gojo1729 avatar Jul 25 '22 05:07 Gojo1729

Hi @Gojo1729 , MediaPipe graphs will queue/drop frames when the input is faster than the system can handle. The more powerful the device (or more simple the graph), the less frames dropped/queued, the higher fps can be achieved.

sureshdagooglecom avatar Jul 25 '22 05:07 sureshdagooglecom

Hi @sureshdagooglecom , I know that Medipipe handles the FPS based on the device it's running on, but my device is a new one and it's capable to handle 30fps easily. https://browser.geekbench.com/android_devices/realme-7-5g, I am able to run face detection in 30fps

Gojo1729 avatar Jul 25 '22 09:07 Gojo1729

Hi @kostyaby , is there anyone else who can provide some insights on this ?

Gojo1729 avatar Jul 26 '22 07:07 Gojo1729

bazel build -c opt. Add "-c opt" when build.

luan78zaoha avatar Aug 03 '22 05:08 luan78zaoha

@luan78zaoha You mean while building AAR file ? I am already using that - bazel build -c opt --strip=ALWAYS --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --fat_apk_cpu=arm64-v8a,armeabi-v7a --legacy_whole_archive=0 --features=-legacy_whole_archive --copt=-fvisibility=hidden --copt=-ffunction-sections --copt=-fdata-sections --copt=-fstack-protector --copt=-Oz --copt=-fomit-frame-pointer --copt=-DABSL_MIN_LOG_LEVEL=2 --linkopt=-Wl,--gc-sections,--strip-all //mediapipe/java/com/google/mediapipe/solutioncore:solution_core.aar

and even while building the graph - bazel build -c opt mediapipe/graphs/pose_tracking:pose_tracking_gpu

Gojo1729 avatar Aug 03 '22 09:08 Gojo1729

@ivan-grishchenko Any updates on this ? 🙏

Gojo1729 avatar Aug 09 '22 08:08 Gojo1729

We are also having around 5-10fps, with a very similar graph to @Gojo1729 's, across multiple decent Android devices (samsung A11, samsung A70 etc). (Same model runs quite fine on iOS; around 60fps on XR). Is this expected?

metin-ozturk avatar Jan 16 '23 11:01 metin-ozturk

Hello @Gojo1729, We are upgrading the MediaPipe Legacy Solutions to new MediaPipe solutions However, the libraries, documentation, and source code for all the MediapPipe Legacy Solutions will continue to be available in our GitHub repository and through library distribution services, such as Maven and NPM.

You can continue to use those legacy solutions in your applications if you choose. Though, we would request you to check new MediaPipe solutions which can help you more easily build and customize ML solutions for your applications. These new solutions will provide a superset of capabilities available in the legacy solutions. Thank you

kuaashish avatar Apr 26 '23 11:04 kuaashish

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar May 04 '23 01:05 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar May 12 '23 01:05 github-actions[bot]

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

google-ml-butler[bot] avatar May 12 '23 01:05 google-ml-butler[bot]