KAPAO is an efficient single-stage human pose estimation model that detects keypoints and poses as objects and fuses the detections to predict human poses.
I've run into an issue where my kapao predictions use up more and more memory the longer a video is being processed. Below is some semi-reproducible code. The only parts that aren't is my custom Kapao class which is basically all the necessary pieces of the demos/video.py needed to just pass in an image and get objects out. If you think this is the part that is causing the issues, let me know and I can post that section of the code as well.
import cv2
import tracemalloc
from model import Kapao
from collections import deque
tracemalloc.start()
cap = cv2.VideoCapture(r"path/to/video.mp4")
people = Kapao(r"kapao_l_crowdpose.pt")
buffer = deque([None] * 10, 10)
grabbed, img = cap.read() # Line 13
frame_num = 0
while grabbed:
buffer.append(
people.predict(img)
)
buffer.popleft()
frame_num += 1
snap = tracemalloc.take_snapshot().statistics("lineno")[0]
print(f"Frame: {frame_num} Line: {snap.traceback._frames[0][1]} Size: {snap.size} Count: {snap.count}")
grabbed, img, = cap.read() # Line 23
This memory allocation continues to grow larger and larger as the video processing continues. Does anyone why these objects are continually being stored in memory despite them being removed from the buffer and thus should be picked up by the garbage collector? I have ran this test with Yolov7 as well and it fails to reproduce which makes me think it is a KAPAO specific issue.
I've run into an issue where my kapao predictions use up more and more memory the longer a video is being processed. Below is some semi-reproducible code. The only parts that aren't is my custom Kapao class which is basically all the necessary pieces of the demos/video.py needed to just pass in an image and get objects out. If you think this is the part that is causing the issues, let me know and I can post that section of the code as well.
The output looks something like this:
This memory allocation continues to grow larger and larger as the video processing continues. Does anyone why these objects are continually being stored in memory despite them being removed from the buffer and thus should be picked up by the garbage collector? I have ran this test with Yolov7 as well and it fails to reproduce which makes me think it is a KAPAO specific issue.