I would recommend switching to the asynchronous MediaPipe interface. I've been working on a similar (but fundamentally different) effect and I found that CPU usage dropped dramatically when switching to MediaPipe's new segment_async.
As an example, here's htop output when running Linux-Fake-Background-Webcam script doing no composition whatsoever (just segmenting) 1280x720, 30FPS, MJPG colour:

And here's the htop result when I'm running my own effect that uses segment_async (same input/output):

I would recommend switching to the asynchronous MediaPipe interface. I've been working on a similar (but fundamentally different) effect and I found that CPU usage dropped dramatically when switching to MediaPipe's new
segment_async.As an example, here's
htopoutput when running Linux-Fake-Background-Webcam script doing no composition whatsoever (just segmenting) 1280x720, 30FPS, MJPG colour:And here's the
htopresult when I'm running my own effect that usessegment_async(same input/output):