Does he have to do ghusl if he only sees a non-mahram woman or talks to her?
Question

                1. My questions is do you have to make a ghusl when you see a girl in Shorts or tights or naked and thinking sexual things about that girl? I dont mean pleasuring my self or masterbating, I think of it in the moment and it happens. I cant stop it because a lot of girls in my school dress semi naked or very open. So do I lose ghusl if I just see the girls butt and think sexual things? No masterbation. No semen coming out. I just think of sexual things for a little then look away and think of something else. I know it's haram to think of the girl sexually but I don't do anything further than think about it. I don't talk to the girl, touch the girl, masterbate to the girls picture or anything. Most times I try to look away but sometimes it doesn't work and I think of the girl
2. Do I lose ghusl if I talk to a girl? Just a normal conversation, nothing sexual. Just a normal talk.
3. Do I lose ghusl when I see a picture of somebody naked? I don't do anything, like masterbating or Anything, I definitely don't do that because its a HUGE sin. I try to look away and it works but sometimes I think of the girl sexually. But I don't masterbate or pleasure myself,
Praise be to Allah.Firstly: 
What you have mentioned about widespread temptation because of free mixing is something shameful. How often has free mixing between the sexes (men and women) in educational establishments, workplaces or elsewhere, been the cause of temptation and widespread evil! The one who never spoke on the basis of his own whims and desires (i.e., the Prophet, peace and blessings of Allah be upon him) spoke the truth when he said: “I have not left behind me any fitnah (trial) that is more harmful to men than woman.” Narrated by al-Bukhaari (5096) and Muslim (2740). 
For more information, please see the answer to question no. 33651 
You should keep far away from fitnah (trial or temptation). If you stay in this mixed school, there is the fear that this may lead to bad consequences, for the one who grazes his flocks around a sanctuary will soon transgress upon it. 
You have to look for a school where you will be able to find what you want, without exposing yourself and your religious commitment to danger and things that may lead to your doom, even if that means that you have to study without attending the school (e. g., distance learning, online or otherwise). 
If that is not possible, and no school in your country is free of mixing, then you must adhere to the Islamic teachings of lowering the gaze, and not getting carried away when talking to women. May Allah help us and you to obey Him, and help us to avoid temptation both visible and hidden.
For more information, please see the answer to question no. 127946
Secondly: 
Ghusl does not become obligatory just because of seeing a non-mahram woman or speaking to her, so long as no maniy (semen) is emitted as a result of that. If maniy is emitted, then ghusl becomes obligatory. But if madhiy (prostatic fluid) is emitted because of thinking about desires or because of looking, then in this case it is obligatory to wash the penis and testicles, and to pour water over whatever has gotten onto one’s clothes. 
Thirdly: 
The Muslim must strive to control himself and make himself lower his gaze as much as he can. If his gaze happens to fall on a woman who is not permissible for him, without him intending to do that, then this is forgiven, but he is instructed to avert his gaze after that. This has been explained in the answer to question no. 1774 
What you must do is lower your gaze and block those bad thoughts that come to you; do not give them free rein. Blocking them is the best way of getting rid of them. For more information, please see question no. 20161.
And Allah knows best.