One thing that I've started doing is requiring myself, before looking at someone (with intent to look/gaze) to say aloud, "I'm going to look at Ploni." It doesn't have to be loud, but it has to be audible.
For whatever reason, this can stop me from giving in to the yetzer hara. Maybe it's forcing me to examine my motives; maybe it's just a delay tactic; maybe I just start to think, "It's not worth that glance". I guess that we might think of a glance as an almost involuntary action, but saying it out loud can maybe place it in the realm of mindfulness (to use the lingo.)
Of course, there are times I recite my incantation and plow right ahead with my eyes. That becomes my choice. But it's more of a choice and less automatic.
Another thing: when I do refrain from looking at someone (mostly on the street), I award myself a dime. (Yeah, I'm a cheapskate. But it can add up fast at times!) I have to judge whether the split second I saw someone ahead of me so that I don't bump into them is a necessary look or whether I'm stretching it out at all. If I've taken even a fraction of a second too long, I lose my chance at the dime, and I can't get it again for this person-glance.
If these can help anyone, I'm glad to share.