Can anybody suggest me how should I convert cv2 LINESTRING to RLE or masks?

I pretty new to this large tif images, i think for my segmentation models to work I have to convert the LINESTRING to masks or RLE, and dump all the data into Patches… . . has anybody any suggestion or references for the same?