There are so many ways, here are some that I usually do:
1, Take a break at least every hour. Just the time to walk around somewhere refreshing or a little bit longer for buying a cup of coffee.
2, Play a piece that you love very much before leaving your seat, so that you'll want to go back to your seat after the break!
3, Try to practise the piece of music in different ways. Explore new ways to practise. Be inventive. Practising piano should not be boring; it should be an interesting process!
4, Be determined. Never give up. Be patient.
In the end, the world is not all about music. Never be one-tracked mind which will eventually drives people crazy.