We are fortunate in this day and age that there have been many Seforim published on the inyan of Shemiras Einayim and one can even listen to lectures on the topic. My question is, in reality, after all the reading and speeches, what does one do if he still stumbles? Reading and listening is great, but the real test is when a person is walking on the sidewalk and his being is just burning to look around and "gaze"!
In the Tanya it is written that a person has two types of neshama's "living" inside him, and our objective is to fight the "animal Neshama".
He says that because we have 2 Neshamos it normal and natural that our thoughts will run sometimes towards all kinds of directions; and one should not feel bad about that (he says if a person does feel bad it is גאווה) because that is the "animal Neshama".
So as an answer to your question the Tanya says that our job is not to make it that thoughts like these will enter our head. Our job is that when they enter our head and we notice it we should fight them off!
This is written from chapter 27 until chapter 32 (not included)