Geek Culture
Published in

Geek Culture

Detect Nudes Using Python Programming and Deep AI

Can we detect Nudity in Images using Python and Deep AI? Let’s check it out

Nudity detection using python and deep ai

Hello, Python-dev..!!

My name is Rohit Kumar Thakur. Last night I was surfing the internet and trying to download a movie. But that movie site was full of personalized nude ads. I thought, is it possible to detect nudes using python? Do I have to use any library? After a lot of research, I come across a website called Deep AI. This website provides the API for detecting nude images. They trained the dataset of nude images of both men and women and provide the functionality to detect the nude images using API. So, without wasting any time. Let’s start..!!

If you are looking for a video tutorial then it’s here:

Nudes Detection using Deep AI and Python


Make a python file and open it in your favorite code editor. Oh! VS Code? Nice.

import requestsurl = ''headers = {
'api-key': 'quickstart-QUdJIGlzIGNvbWluZy4uLi4K'
response =
'image': open('img2.png', 'rb'),
  • Change the image file name with your test image. Make sure to write the path of the image correctly. I placed the image “img2.png” in the same directory as the python file.
  • This API key is free to use. But after you make several fetch requests the Deep AI guys will block you and gonna ask you to make an account and get your API key.
  • The code part is very simple and easily understandable.

Now Run the project. If you test this code with the nude images then the output will be something like this:

Nude images detection using python

You can see that the NSFW score is 99.4729%, which means that the image is nude. Here we can see that the output is showing both male and female breasts exposed. That’s not possible, right? Well, I used a random image of the girl with a flat chest. Don’t ask me why?

In the same way, you can test this code on non-nude images. You will get the desired output.

That’s it for this article.

If this article sounds informative to you then make sure to follow and clap. Share it with your geek community.

Thanks for reading.

Hello, My Name is Rohit Kumar Thakur. I am open to freelancing. I build react native projects and currently working on Python Django. Feel free to contact me (



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store