First - don't panic
Second - only make eye contact...no matter what
I go to a gym near my office, where I'm fortunate enough to have a corporate discount. So from time-to-time, I go into the gym after work and without paying attention, walk into a row of lockers and I'm greeted with the sight of a woman I work with who is buck naked getting ready to work out.
Now it would be rude to gasp and walk away so if I've committed to the row of lockers with my naked co-worker, I tend to offer a smile (so it's not awkward) and do not engage in conversation. Sometimes, if I know the person well, we'll engage in small talk while keeping our backs to one another (like in gym class), otherwise we do not acknowledge each other at all and play dumb.
Of course it's a little odd the next day, when I run into them in the lobby while getting water or in the kitchen because I can't help but think, "huh, I saw her naked yesterday, " and then go on with my day. As I said, this doesn't happen often, but when it does, it's always an interesting experience.