Quick viewing(Text Mode)

A Novel Nudity Detection Algorithm for Web and Mobile Application Development

A Novel Nudity Detection Algorithm for Web and Mobile Application Development

A Novel Nudity Detection Algorithm for Web and Mobile Application Development

Rahat Yeasin Emon Department of Computer Science and Engineering Chittagong University of Engineering and Technology Chittagong-4349, Bangladesh [email protected]

Abstract— In our current web and mobile application The paper presents a runtime nudity detection technique development runtime nude image content detection is very for web and mobile application development. To detect important. This paper presents a runtime nudity detection nudity two important parameters of the human body are used method for web and mobile application development. We use one is skin color another is face region. Raw RGB and HSV two parameters to detect the nude content of an image. One is color spaces are used to detect skin color. Google vision api the number of skin another is face region. A skin color or google firebase ML kit is used to detect face region. By model based on RGB, HSV color spaces are used to detect skin the ratio of total number of skin pixels and the number of pixels in an image. Google vision api is used to detect the face skin pixels in the face region, we detect whether the input region. By the percentage of skin regions and face regions an image contains nude content or not. image is identified nude or not. The success of this algorithm exists in detecting skin regions and face regions. The skin detection algorithm can detect skin 95% accurately with a low II. BACKGROUND false-positive rate and the google vision api for web and mobile To detect the nudity of an image there exists several applications can detect face 99% accurately with less than 1 theoretical and practical research work they are mainly based second time. From the experimental analysis, we have seen that on body-shape or object-detection, detection of skin color the proposed algorithm can detect 95% percent accurately the nudity of an image. and pre-classified database is used [1]. In [3,9] only skin pixels are considered to detect nudity. A skin Keywords—, nudity, non-nudity, skin-color- based on RGB, Normalized RGB, HSV, and YCbCr is used model, skin-detection, face-detection to detect skin color pixels. By the percentage of skin color pixels and skin regions, an image is classified nude or not. The disadvantage of this method is that it does not classify I. INTRODUCTION images containing a large amount of skin color that does not Pornographic images in the web and mobile applications have any nudity for example images containing only faces have become a great concern in our society. Nude images are have a high ratio of skin color for the whole image and this offensive for some kind of people [1]. It can be used as some method mistakenly identified those images as nude image. type of crime, such as child pornography [2]. Pornographic images affect children's and teenagers' mental and physical An updated version of paper [3] is discussed in [6,7]. health. Parents are afraid and discourage their children to use They proposed machine learning-based training and learning the internet. Again pornographic content often contains rule for nude image classification. However, machine misleading information such as malicious threats. learning-based nudity detection is very time consuming and will not discuss in this paper. In today’s internet world videos and images are the most important phenomenon. The vast development of web and In [4,5] skin color region is detected and then the mobile applications, it is often affected by pornographic detected regions are converted into body shape structures to content. To protect the internet from pornographic image detect nudity of image. In [8], the body shape was extracted content, theirs need a nudity checker. and fed into a classifier based on skin color detection it decides whether or not the body-skin regions represented Filtering an image to detect whether it contains nude nudity. Fu and Wang [10] proposed a method where ROI content is a vast research area. Often image nudity is very (Region of Interest) is located by identifying skin-like pixels difficult to be described [6]. Different people have different using YCbCr color spaces. Then ROI is classified into SVM about which images nude which are not. classifiers to detect the pornographic image. The Yang [11] Machine learning is the most reliable technique for image method also determines the ROI with skin information. The processing. But machine learning technique needs a huge image was classified into different regions and points. Based amount of data set and time. Concerning space and time on the ROI this method obtains some features for image currently available method to detect nude image is still classification. In [12], the property of an image such as color crude. Technology companies demands new pornography and texture is obtained and then a pattern classifier is used to detection method. detect nudity. However, the body-shape method discussed in this paragraph failed to detect nudity in images with facial In our modern era, web and mobile applications are content, partial explicit content, and a high level of mostly used technology. Internet images often uploaded from illumination. To resolve these issues in this paper we the web and mobile devices. In our internet server-client separately calculate the face regions. model, to protect server busy theirs need a fastest front-end validation technique which can protect the nude images In [13], a pre-classified database is used to match an being uploaded into an internet server. image. When the number of pre-classified images from the

database reaches a threshold for an image, then it is labeled To detect skin , we need a decision rule to identify as a nude image. This pre-classified database image detection whether a pixel is skin or not. Decision rules to cannot be used in real-time applications such as web and detect skin pixels can be simple threshold-based color spaces mobile applications front-end validation. [25,26] or can be complex as neural networks [27], Bayesian [28], maximum entropy [29] or k-means clustering [30]. The In [14], face-body based nudity detection is used where skin color boundary method in certain color spaces is the face and body are mandatorily detected first with object most popular technique to detect skin because it is shape detection method then compare it with a threshold that lightweight and easy to implement [3-7]. is relative to the face-body ratio of the current body area. Kosesoy [15] proposed a face based nudity technique where a ratio is obtained from dividing the total number of nude A.2. Color Spaces pixels by the total number of faces. In this study, after Color spaces are a tool for representing color information detecting faces body region calculated for each face region usually consists of three or four color information. It is a according to the ideal face-body ratio [16]. However, this system where each color represented by a single point. method cannot detect the nudity in non-face images and the Different types of Color spaces are used in computer face-body ratio is not the ideal ratio to detect nudity. , image processing, TV broadcasting, and computer vision [18]. One- is appropriate in one application The face-body skin ratio based nudity detection is might be inappropriate in other applications. Color space discussed in [17]. In this study, they detect face bounding selection is the primary process to detect skin color model box and body skin pixels. The ratio of the face bounding box and classification. RGB based color spaces (RGB, and body skin pixels determine the image nudity. In the case Normalized RGB), based color spaces (HIS, HSV an of skin detection and nudity detection, this method provides HSL) and luminance based (YCbCr, YIQ and YUV) are low accuracy results. popular color spaces for skin color modeling [18]. In our In our nudity detection method, we are focusing on two- proposed algorithm we used RGB, and HSV color space to parameter of human body one is detecting skin region and detect skin pixels. another is face region. In this algorithm, the face region is not mandatory. But if face exists it gives a higher accuracy to A.3. The RGB Color Spaces detect nudity of an image. By the percentage of skin region The RGB color space is the default color space in digital pixels, face regions skin-pixel, and the total pixels of an image processing. Any other color spaces can be generated image we detect whether the image contains nudity or not. from this RGB spaces [3]. This color spaces have three basic colors , , and . All color is the mixture of these A. Skin Detection three base color. Every color has Red, Green, and Blue color Skin color detection is our key point to detect the nudity of component. In RGB color spaces Red, Green, and Blue an image. To detect the skin region, we have used a values are ranging from 0 to 255 (256 different value). It combination of research methods. We proposed a new skin makes 256 * 256 * 256 = 16777216 possible unique colors. detection model which is based on Kolkur [18] and Osman However, this RGB color space cannot alone classify skin for that case Normalized RGB, HSV are also used to [19] skin color model. Now will see few terminologies generate a skin detection system. related skin detection. A.1. Skin color A.4. The Normalized RGB Skin is the largest organ of the human body [20]. Skin The Normalized RGB is another method to detect skin color is our key point to detect the nudity of an image. Color pixels. It removes the image luminance through is lightweight and inexpensive therefore it is suitable for real- normalization. The normalized Red(r), Blue(b) and Green(g) time object characterization [21]. The nude image has a large obtained after dividing the component by summation of RGB number of skin regions, so skin color is the basic feature to value. detect nudity. Today skin detection is used in face detection, nude image detection, human detection, and hand gesture r = R / (R+G+B) analysis [19]. The color-based skin detection has a g = G / (R+G+B) disadvantage that it will not work in and images. However, back an white images are rarely existed in our web b = B / (R+G+B) and mobile application system. Skin color is produced from melanin, hemoglobin, A.5. The HSV color spaces carotene, and bilirubin. Hemoglobin gives the blood a The RGB color space is not so reliable for human skin reddish color or bluish color while carotene and bilirubin interpretation. Researchers use hue, saturation, and give skin a yellowish appearance [19]. The or to describe human body color objects [3]. Here, of skin depends on the amount of melanin in the hue describes an angle between 0 to 300 degrees, saturation skin [3]. describes the grayness ranging from 0 to 100%, and the The simplest methods in skin detection assume skin color value represents the brightness or intensity of color ranging have a certain range in a color space [3]. Different color from 0 to 100%. spaces are used to detect skin. The study [22] indicates that skin tones have similar in value and they differ mainly in their intensity value. The researcher Bosson [23] and Chan [24] agreed that the color spaces selection is not so critical if proper training and data set are used. 3. Check every pixel whether it is skin pixel or not. 4. Calculate the number of skin pixels in that image. 5. Calculate the skin pixels in the face regions. 6. If the face region exists a. If (number of face skin pixels / total number of skin pixels) < 0.15 flag the image as nude image. b. Else flag the image as non-nude image. B. Face Detection 7. Else no face region exists Face detection is our second parameter to detect image a. If (number of skin pixels / total number nudity. In this paper, we will discuss the practical nudity pixels of that) > 0.38 flag the image as checker implementation for web and mobile applications. nude image. We used google-vision face api to detect face region. b. Else flag the image as non-nude image. B.1. Google Vision Face Api 8. End. Google vision face api is a powerful tool for face Now, we will discuss the practical demonstration of the detection for web and mobile application development where algorithm. powerful machine learning tool is used [32,33]. This api is lightweight and easy to implement. For the implementation purpose of web and mobile applications here, we used this face api to detect the bounding box of the face region.

B.2. Cloud Vision Face Api for Web Application Google cloud vision face api for web application is lightweight, reliable, and it is easy to implement. For the web application, it is not totally free.

B.3. Face Api for Mobile Application Detect face Android and IOS are the two popular mobile application platform. Google has a mobile vision face or ML kit api to detect faces region in android and ios based device application system. For device-based api, the face detection system is free. Detect skin

III. THE ALGORITHM In our nudity detection system, we detect total skin pixels, face region, and skin pixels in the face region of an Fig. 1. The proposed algorithm, detect face and skin pixels image. There are many skin color model rule exists, there are The above figure describes the procedure of our algorithm. mainly based on Kovac rule [31], Swift rule [39], Saleh The skin pixels depicted as color. In our nudity model [40], and Kolkur method [18]. We experimentally detection algorithm, we first detect face region (if exists) analyze every method, after combining those methods here then detect skin pixels of face region and the total image we propose a skin detection rule for web and mobile area. If face region exists, then the ratio of face skin region applications. Our Skin detection rule: and the total skin region detect the nudity of the image. If the Detect skin using RGB, HSV color spaces, Here (R) for ratio is above a threshold value, then we flag that image as Red, (G) for Green, (B) for Blue, (H) for Hue, and (S) for nude image. Again if the face region does not exist, then Saturation value. ratio of total skin pixels and total image pixels determine the nudity of that image. If R > 95 and G > 40 and B > 20 and R > G and R > B

and |R –G| > 15 and 0.0 <= H <= 50.0 IV. RESULTS and 0.23 <= S <= 0.78 We used separate data sets to test our skin detection algorithm and nudity detection algorithm. For skin detection, then that pixel is skin pixel. we take 5,582,768 manually labeled skin pixels and 30,724,928 After the detect skin, we detect the face region. We used manually labeled non-skin pixels. From this testing we have google vision tool to detect face regions. Now the overall seen that our skin pixels’ detection algorithm detect skin algorithm works in the following manner. 94.89% with 7.24% false positive rate. The following table we will show a comparison between our proposed skin 1. Scan the image and get the pixels of the image. detection rule with some popular skin detection model. 2. Detect face regions if it exists. TABLE I. COMPARISON OF SKIN COLOR MODELS Image 4:

Color Model Correct Detection False Positives

Kovac 10 42.5 Solina 98 14 Ghazali 94.91 33.07 Rigan 94.32 5.98 Proposed skin color 94.89 7.24 model Fig. 5. Image 4, after detect face and skin pixels

Image 5: Again, for testing nudity detection we used 435 nude images and 345 non-nude images. From that testing, we have seen that the proposed nudity detection algorithm can 97% accurately detect the nude content of an image. Now, we will show the experimental analysis of some nude images for testing our algorithm. Nude image without face region is rare, in the following section we will study some nude images with faces. Image 1:

Fig. 6. Image 5, after detect face and skin pixels

TABLE II. NUDITY ANALYSIS OF IMAGES Face Skin region Ratio(b/a) False-positive Image pixels skin / Nudity (skinDetection) pixels Image 292900 23411 0.07 / True 5% 1 Fig. 2. Image 1, after detect face and skin pixels Image 67037 1875 0.02 / True 1% 2 Image 2: Image 229369 18404 0.08 / True 0.03% 3 Image 109218 10790 0.09 / True 0.02% 4 Image 209464 12935 0.06 / True 3% 5

Here, we take five nude images, calculate their skin pixels, and face region. The ratio of face region pixels and total skin pixels of all the testing image is below our nudity threshold of 0.15%. Hence, all the five testing images flagged as nude-image. For skin detection, the false positive Fig. 3. Image 2, after detect face and skin pixels rate is also very low. When the false positive in the skin detection method is low, our proposed method can detect Image 3: image nudity 99% accurately. On average, our nudity algorithm can detect 95% accurately the image nudity.

V. CONCLUSIONS This paper presents a face-skin based lightweight and fast-frontend nudity detection technique for web and mobile application. The nudity concept can easily be used in any other system after applying a reliable face detection technique. Two human body parameters skin regions and face-skin regions are used. If the ratio of that parameters is above a threshold, then the input image is flagged as nude- image. A powerful RGB and HSV color-based skin detection are used to detect skin regions which false-positive rate is low Fig. 4. Image 3, after detect face and skin pixels compare to other color-based skin detection method. For detecting face regions, google cloud vision api is used for testing web application images and mobile vision api is used [16] I. P. Herman, of the Human Body, New York: Springer, in mobile application images. 2007, p. 18. [17] R. Balamurali and A. Chandrasekar, “Multiple parameter algorithm From the experimental result, the proposed nudity approach for adult image identification,” Cluster Computing, vol. 22, detection algorithm can detect image nudity 95% accurately no. S5, pp. 11909–11917, 2018. with a low false-positive rate. [18] Kolkur, S. & Kalbande, Dhananjay & Shimpi, P. & Bapat, C. & Jatakia, Janvi. (2017). Human Skin Detection Using RGB, HSV and YCbCr Color Models. 10.2991/iccasp-16.2017.51. REFERENCES [19] Osman, G., Hitam, M.S., Ismail, M.N.: Enhanced Skin Colour Classifier Using RGB Ratio Model. IJSC. Computer Vision andPattern Recognition, vol. 3, pp. 1–14 Nov. (2012). [1] J. Zhang, L. Zhuo, Z. Li and Y. Yang, “An approach of bag-of-words based on visualattention model for pornographic images recognition [20] J. G. Marks and F. Miller, Lookingbill and marks' principles of in compressed domain,” Neurocomputing, pp. vol. 110, pp.145-152. dermatology, 4th ed.: Elservier Inc., 2006. [2] D. I. Oddis, “Combating Child Pornography on the Internet: The [21] Martinkauppi, B. 2002. “Face Colour Under varying Illumination,” Council of Europe’s Convention on Cybercrime,” Computer Crime, [online].Available:http://herkules.oulu.fi/isbn9514267885/isbn951426 pp. 285–326, May 2017. 7885.pdf. (02 October 2003). [3] R. Ap-Apid, “An algorithm for nudity detection”, College of [22] Waibel, A., Yang, J., & Lu, W. Skin-color modeling and Adaptation. Computer Studies, De La Salle University. In Proc. Of ACCV1998, 687-694, 1998. [4] M. M. Fleck and D. A. Forsyth, “Identifying nude pictures,” Proc. [23] Bosson, Alison, et al. “Non-Retrieval: Blocking Pornographic Third IEEE Work. Appl. Comput. Vision. WACV’96, no. 1, p. pp. Images.” Lecture Notes in Computer Science Image and Video 103–108, 1996. Retrieval, 2002, pp. 50–60., doi:10.1007/3-540-45479-9_6. [5] M. M. Fleck and D. A. Forsyth, “Finding naked people,” Proceedings [24] Chan, Yi, et al. “Building Systems to Block Pornography.” Jan. 1999, of European Conference on Computer Vision, vol. 0214350618, p. doi:10.14236/ewic/cir1999.8. pp. 593–602, 1996. [25] A. A.-S. Saleh, "A simple and novel method for skin detection [6] D. C. Moreira and J. M. Fechine, “A Machine Learning-based and face locating and tracking," in Asia-Pacific Conference on Forensic Discriminator of Pornographic and Bikini Images,” 2018 Computer-Human Interaction 2004 (APCHI 2004), LNCS 3101, International Joint Conference on Neural Networks (IJCNN), 2018. 2004, pp. 1-8. [7] C. Platzer, M. Stuetz, and M. Lindorfer, “Skin sheriff,” Proceedings [26] D. B. Swift, "Evaluating graphic image files for objectionable of the 2nd international workshop on Security and forensics in content," US Patent US 6895111 B1, 2006. communication systems - SFCS '14, 2014. [27] N. Bourbakis, P. Kakumanu, S. Makrogiannis, R. Bryll, and S. [8] Zheng, Q.-F., Zeng, W., Wen, G., Wang, W.-Q.: Shape-based adult Panchanathan, "Neural network approach for image chromatic images detection. IEEE International Conference on Image and adaptation for skin color detection," Int J Neural Syst, vol. 17, pp. 1- Graphics, CAS, Beijing, China, Dec. 18–20, pp. 150–153 (2004). 12, Feb 2007. [9] Yin, H., Xu, X., Ye, L.: Big skin regions detection for adult image [28] D. Chai, S. L. Phung, and A. Bouzerdoum, "A bayesian identification. IEEE workshop on Digital Media and Digital Content skin/non-skin color classifier using non-parametric density Management, Hangzhou, Zhejiang, China, May 15–16, pp. 242–247 estimation," in IEEE Int. Symposium on Circuits and Systems (2011). 2003, Bangkok, Thailand, 2003, pp. 464-467. [10] Fu, Y., Wang, W.: Fast and effectively identify pornographic images. [29] B. Jedynak, H. Zheng, M. Daoudi, and D. Barret, "Maximum IEEE International conference on Computer intelligence and security, entropy models for skin detection," Universite des Science et Beijing, China, Dec. 3–4, 1122–1126 (2011). Technology de Lille, France, Technical report2002. [11] Yang, J., Fu, Z., , T., Hu, W.: A novel approach to detecting adult [30] K. S. Ravichandran and B. Ananthi, "Color skin segmentation images. IEEE Int. conf. Pattern Recognition, Beijing, China, Aug. 23– using k-means cluster," International Journal of Computational and 26, vol. 4, pp. 479–482 (2004). Applied Mathematics, vol. 4, pp. 153–157, 2009. [12] H. Zheng, M. Daoudi and B. Jedynak, “Blocking Adult Images Based [31] J. Kovac, P. Peer, and F. Solina, "Human skin colour clustering for on Statistical Skin Detection,” Electron. Lett. Comput. Vis. Image face detection," in Proceeding of EUROCON 2003. Computer as a Anal., vol. 4, no. 2, p. pp. 1–14, 2004. Tool. The IEEE Region 8, 2003, pp. 144-148. [13] J. Wang, J. Li, G. Wiederhold and O. Firschein, “System for [32] “AutoML Vision documentation | Cloud AutoML Vision | Google Screening Objectionable Images,” Comput. Commun., vol. 21, no. 5, Cloud,” Google. [Online]. Available: p. pp. 1355–1360, 1998. https://cloud.google.com/vision/automl/docs. [Accessed: 14-May- 2020]. [14] “Nudity Detection Using Face-Body Ratio,” semanticscholar.org. [Online].Available:https://pdfs.semanticscholar.org/f96e/d761220a70 [33] “Introduction to Mobile Vision | Google Developers,” Google. 98c4eb37e69072e33a03ec6e34.pdf. [Online]. Available: https://developers.google.com/vision/introduction. [Accessed: 14- [15] I. Kosesoy and F. Aslan, “Face-Based Nudity Detection From Skin May-2020]. Color,” in International Conference on Innovative Trends in Science, Engineering and Management, Dubai, 2014.