Hello ,
I tried to apply similar logic as you mentioned in your github. But I could see noise after applying cv2.createBackgroundSubtractorMOG2.
(Even your screenshots looks more accurate and very less noise, please guide if you changed your code at later moments).