I’m not sure, if you would like to use a neural network for it, as you are posting in the PyTorch forum, but you could use standard image processing to get these lines.
To do so you could use a horizontal edge detection, e.g. using a sobel operator, and afterwards filter the image for these two lines (e.g. using a matched filter).
This could also be done using a neural network (which might be a bit overkill, but seems to be a fun task), so let me know, which approach you would like to take.