'Is there a way to split a lined paper scan for model training

I am experimenting with this HTR repo on github https://github.com/githubharald/SimpleHTR, but the model can only recognize and train from single word and line scans. I have scans of lined paper and would like to split the image on those lines. I understand I can do this manually with screenshots but programmatically would be better.

Example image: Handwritten scan

expected output: sample output



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source