def run(argv): for index in range(1, len(argv)): filename = str(argv[index]) n = Nude(filename) n.parse() print(filename, n.result, n.inspect()) return 0
def isnude(self, file): #图像压缩处理 imagePath = IMAGE_DIR + file nudeImg = IMAGE_DIR + "nude_" + file # print(nudeImg) # disImg = IMAGE_DIR +file self.resizeImg(ori_img=imagePath, dst_img=nudeImg, dst_w=600, dst_h=600, save_q=100) # faces = self.face("dis"+file) faces = self.face("nude_" + file) if (len(faces) < 1): print("no face") return -1 else: self.cropImg("nude_" + file, faces) n = Nude(nudeImg) # n = Nude(newImg) # n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result print(n.result, n.inspect(), '\n<br/>') print('stop waiting', time.strftime('%H:%M:%S'), '\n<br/>') return 1 if n.result else 0
def isnude(self, file): #图像压缩处理 imagePath = IMAGE_DIR + file nudeImg = IMAGE_DIR + "nude_" + file print nudeImg # disImg = IMAGE_DIR +file self.resizeImg(ori_img=imagePath, dst_img=nudeImg, dst_w=600, dst_h=600, save_q=100) # faces = self.face("dis"+file) faces = self.face("nude_" + file) if (len(faces) != 1): print("no face or lt 2") self.delImg(file) return -1 else: if (not self.cropImg("nude_" + file, faces)): return 0 n = Nude(nudeImg) # n = Nude(newImg) # n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result return 1 if n.result else 0
def process(self, profile_path): for root, dirs, files in os.walk(profile_path): for f in files: fp = os.path.join(root, f) if self.compat(fp): ai = Nude(fp) ai.parse() yield fp, ai.result
def detect_nudity(filename): if magic.from_file(filename, mime=True) == "image/jpeg": print("Check if the image contains nudity: %s" % (filename, )) n = Nude(filename) n.parse() nudity = str(n.result) helper.sqlite_insert("Nudity", nudity, os.path.basename(filename)) return nudity else: print "Nudity Detection works only with JPEG" return None
def main(): if len(sys.argv) < 2: print("Usage: {0} <image>".format(sys.argv[0])) return 1 # else fname = sys.argv[1] print(is_nude(fname)) n = Nude(fname) n.parse() print("{0}: {1} {2}".format(fname, n.result, n.inspect())) return 0
def isnude(file): #图像压缩处理 imagePath = IMAGE_DIR + file disImg = IMAGE_DIR +"dis"+file newImg = resizeImg(ori_img=imagePath,dst_img=disImg,dst_w=300,dst_h=300,save_q=100) faces = face("dis"+file) n = Nude(newImg) n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result return 1 if n.result else 0
def process(path): try: n = Nude(path) n.parse() logger.info('path:%s, result:%s, detail:%s', path, n.result, n.inspect()) if n.result: shutil.copy(path, porn_dir) else: shutil.copy(path, not_porn_dir) except Exception as err: logger.error('image error')
def isnude(self, file): #图像压缩处理 imagePath = IMAGE_DIR + file nudeImg = IMAGE_DIR + "nude_" + file # self.resizeImg(ori_img=imagePath,dst_img=nudeImg,dst_w=300,dst_h=300,save_q=100) # faces = self.face("nude_"+file) # self.cropImg("nude_"+file,faces) n = Nude(nudeImg) # n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result return 1 if n.result else 0
def isnude(self,file): #图像压缩处理 imagePath = IMAGE_DIR + file nudeImg = IMAGE_DIR +"nude_"+file # self.resizeImg(ori_img=imagePath,dst_img=nudeImg,dst_w=300,dst_h=300,save_q=100) # faces = self.face("nude_"+file) # self.cropImg("nude_"+file,faces) n = Nude(nudeImg) # n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result return 1 if n.result else 0
def run(self, task): try: tmp_image = str2image(task.get_file_data) n = Nude(tmp_image) # The resize is used to have although less accurate processing. # TODO: move this to options panel. n.resize(maxwidth=1000) n.parse() except Exception as e: logger.warning("[Task {0}]: Error detecting nude: {1}".format(task.id, e)) else: self.results["nude"]["nudepy"]["result"] = n.result self.results["nude"]["nudepy"]["msg"] = n.message return self.results
def check_image(pic): pic = os.path.join(current_app.root_path, 'static/profile_pics', pic) picsamp = pic.replace('\\', '/') client = SightengineClient('82714170', 'RT4oo9fZFDbNsrvV6VSp') output = client.check('nudity', 'wad', 'celebrities', 'scam', 'face-attributes').set_file(picsamp) invalidImage = False # contains nudity if output['nudity']['safe'] <= output['nudity']['partial'] and output[ 'nudity']['safe'] <= output['nudity']['raw']: invalidImage = True n = Nude(picsamp) n.parse() print(n.result, n.message) return invalidImage
def isnude(self,file): #图像压缩处理 imagePath = IMAGE_DIR + file nudeImg = IMAGE_DIR +"nude_"+file # disImg = IMAGE_DIR +file self.resizeImg(ori_img=imagePath,dst_img=nudeImg,dst_w=300,dst_h=300,save_q=100) # faces = self.face("dis"+file) faces = self.face(file) if(len(faces)<1): print("no face") return -1 else: self.cropImg(file, faces) n = Nude(nudeImg) # n = Nude(newImg) # n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result return 1 if n.result else 0
def main(): # 請插入媒體文件進行分析 __media_data = input("Please insert a media file for analysis: ") __isNude = Nude(__media_data) __isNude.parse() __isNudeInspection = __isNude.inspect() __isNudeResult = __isNude.result if "Nude!!" in __isNudeInspection: #print("result ", __isNude.result, __isNude.inspect()) # 結果: 該圖片包含色情數據 output = """ { "nude" = "true"; }; """ print(output) else: # 結果: 該圖片不包含色情數據 output = """ { "nude" = "false"; }; """ print(output)
def isnude(self,file): #图像压缩处理 imagePath = IMAGE_DIR + file nudeImg = IMAGE_DIR +"nude_"+file print nudeImg # disImg = IMAGE_DIR +file self.resizeImg(ori_img=imagePath,dst_img=nudeImg,dst_w=600,dst_h=600,save_q=100) # faces = self.face("dis"+file) faces = self.face("nude_"+file) if(len(faces)!=1): print("no face or lt 2") self.delImg(file) return -1 else: if(not self.cropImg("nude_"+file, faces)): return 0 n = Nude(nudeImg) # n = Nude(newImg) # n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result return 1 if n.result else 0
def run(self, task): try: tmp_image = str2image(task.get_file_data) n = Nude(tmp_image) # The resize is used to have although less accurate processing. # TODO: move this to options panel. n.resize(maxwidth=1000) n.parse() except Exception as e: logger.warning("[Task {0}]: Error detecting nude: {1}".format( task.id, e)) else: self.results["nude"]["nudepy"]["result"] = n.result self.results["nude"]["nudepy"]["msg"] = n.message return self.results
def isnude(file): #图像压缩处理 imagePath = IMAGE_DIR + file disImg = IMAGE_DIR + "dis" + file newImg = resizeImg(ori_img=imagePath, dst_img=disImg, dst_w=300, dst_h=300, save_q=100) faces = face("dis" + file) n = Nude(newImg) n.setFaces(faces) # n.resize(1000,1000) n.parse() # print n.result return 1 if n.result else 0
from __future__ import print_function import time import os from nude import Nude ROOT = os.path.dirname(os.path.abspath(__file__)) start = time.time() n = Nude(os.path.join(ROOT, 'images/damita.jpg')) n.parse() print(time.time() - start) print(n.result, n.inspect()) # start = time.time() # n = Nude(os.path.join(ROOT, 'images/damita2.jpg')) # n.parse() # print(time.time() - start) # print(n.result, n.inspect()) # # start = time.time() # n = Nude(os.path.join(ROOT, 'images/test6.jpg')) # n.parse() # print(time.time() - start) # print(n.result, n.inspect()) # # start = time.time() # n = Nude(os.path.join(ROOT, 'images/test2.jpg')) # n.parse() # print(time.time() - start) # print(n.result, n.inspect())
# for (x, y, w, h) in faces: # cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) return faces print('start waiting', time.strftime('%H:%M:%S')) # n = Nude("/Users/fengxuting/Downloads/testphoto/1464317011202A33605A.jpg") file = ROOT + "/public/uploads/nude/1464319781149AC72DF3.jpg" faces = facedetect(file) #计算人脸面积占整个图片的比例 im = Image.open(file) ori_w, ori_h = im.size area = 0 for (x, y, w, h) in faces: area = area + w * h print(file) print((float(area) / (ori_w * ori_h)) * 100) n = Nude(file) n.setFaces(faces) # n.resize(1000,1000) n.parse() # print "",time.strftime()('%H:%M:%S') print(n.result, n.inspect()) print('stop waiting', time.strftime('%H:%M:%S'))
# pylint: disable=C0103 # Example of usage # n = Nude('./images/filename.extension') # n.parse() # print(n.result, n.inspect()) #n = Nude('./images/p1.jpg') #n.parse() #images format images_format = ['jpg', 'png', 'gif', 'tiff'] #getting list of images in folder images in different format images_jpg = glob.glob("./images/*.jpg") images_png = glob.glob("./images/*.png") images_gif = glob.glob("./images/*.gif") images_tiff = glob.glob("./images/*.tiff") images_list = itertools.chain(images_jpg, images_png, images_gif, images_tiff) #loop for checking images nude or not #for index in range(len(images_list)): # n = Nude( images_list[index] ) for i in images_list: print(i) n = Nude(i) n.parse() print(n.result, n.inspect())
html = response.read() m = re.search("<img.+?src=[\"'](.+?)[\"'].*?>", html) if m is not None: lol = m.group(0) m = re.search("/(.+?)png", lol) if m is not None: lol2 = m.group(0) input = "https:" + lol2 urllib.urlretrieve( input, "/Users/julienmalka/Desktop/UplmgNudeLocator/images/" + mdr + ".png") n = Nude('/Users/julienmalka/Desktop/UplmgNudeLocator/images/' + mdr + ".png") n.parse() if n.result == False: print bcolors.OKGREEN + "No nude on this one" + bcolors.ENDC os.remove("/Users/julienmalka/Desktop/UplmgNudeLocator/images/" + mdr + ".png") else: print bcolors.OKBLUE + "Nude Found" + bcolors.ENDC except urllib2.HTTPError, e: print bcolors.FAIL + "URL est une 404" + bcolors.ENDC compteur = compteur + 1
def is_nude(path_or_io): nude = Nude(path_or_io) return nude.parse().result
# for (x, y, w, h) in faces: # cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) return faces print('start waiting', time.strftime('%H:%M:%S')) # n = Nude("/Users/fengxuting/Downloads/testphoto/1464317011202A33605A.jpg") file = ROOT+"/public/uploads/nude/1464319781149AC72DF3.jpg" faces = facedetect(file) #计算人脸面积占整个图片的比例 im = Image.open(file) ori_w, ori_h = im.size area = 0 for (x, y, w, h) in faces : area = area+w*h print(file) print((float(area)/(ori_w*ori_h))*100) n = Nude(file) n.setFaces(faces) # n.resize(1000,1000) n.parse() # print "",time.strftime()('%H:%M:%S') print(n.result, n.inspect()) print('stop waiting', time.strftime('%H:%M:%S'))
import nude from nude import Nude print(nude.is_nude('images.jpg')) m = Nude('img.webp') m.parse() print("damita_1 :", m.result, m.inspect()) n = Nude('images2.jpg') n.parse() print("damita_2 :", n.result, n.inspect())
def __init__(self, path): self.nude_image = Nude(path)
class OffensiveImage(): def __init__(self, path): self.nude_image = Nude(path) def is_nude(self): return self.nude_image.parse().result
__FILENAME__ = testnude import nude from nude import Nude #print("damita :", nude.is_nude('./images/damita.jpg')) #print("damita2:", nude.is_nude('./images/damita2.jpg')) #print("test6 :", nude.is_nude('./images/test6.jpg')) #print("test2 :", nude.is_nude('./images/test2.jpg')) n = Nude('./images/damita.jpg') n.parse() print(n.result, n.inspect()) n = Nude('./images/damita2.jpg') n.parse() print(n.result, n.inspect()) n = Nude('./images/test6.jpg') n.parse() print(n.result, n.inspect()) n = Nude('./images/test2.jpg') n.parse() print(n.result, n.inspect()) ########NEW FILE######## __FILENAME__ = nude #!/usr/bin/env python # encoding: utf-8 from __future__ import (absolute_import, division, print_function,
__author__ = "susmote" from nude import Nude import os IMAGE_ROOT = ROOT = os.path.dirname(os.path.abspath(__file__)) + "\\imags\\" for file_name in os.listdir(IMAGE_ROOT): file_path = os.path.join(IMAGE_ROOT, file_name) if os.path.isdir(file_name): continue n = Nude(file_path) n.parse() print(n.skin_map) if n.result is True: print(file_name, "可能是一张裸体照", n.message) elif n.result is False: print(file_name, "是一张正常的图片", n.message)
async def on_message(self, message): # If bot or Administrator if message.author.bot or message.author.guild_permissions.administrator is True: return if message.content == "" and len(message.attachments) == 0: return # Nudity check if (message.channel.nsfw is not True) and (len(message.attachments) > 0): # Used : https://github.com/hhatto/nude.py # Other option : https://github.com/notAI-tech/NudeNet (untested) for i in message.attachments: # Check if the attachment is an image if i.filename.endswith((".png", ".jpg", ".jpeg")): # Data with open("configuration.json", "r") as config: data = json.load(config) anti_nudity = data["antiNudity"] if anti_nudity is True: log_channel = data["logChannel"] # Get the image async with aiohttp.ClientSession() as session: async with session.get(i.url) as response: image_bytes = await response.read() # Convert the image to io image_bytes = BytesIO(image_bytes) # Check the image n = Nude(image_bytes) n.parse() if n.result is True: # Logs i.filename = f"SPOILER_{i.filename}" spoiler = await i.to_file() embed = discord.Embed(title=f"**{message.author}がわいせつな画像を送信しました。**", description=f"チャンネル:{message.channel.mention}\n\n" f"**ユーザー情報 :__**\n\n" f"**名前 :** {message.author}\n" f"**Id :** {message.author.id}\n\n" f"**該当の画像 :**", color=0xff0000) await sendLogMessage(self, event=message, channel=log_channel, embed=embed, messageFile=spoiler) # embed = discord.Embed(title = f"**{message.author} has sent a nudity image.**", # description = f"In {message.channel.mention}.\n\n**__User informations :__**\n\n**Name # :** {message.author}\n**Id :** {message.author.id}\n\n**The image :**", # color = 0xff0000) embed.set_image(url=i.url) await logChannel.send(embed = embed) # Delete await message.delete() await message.channel.send(f"{message.author.mention} わいせつな画像をそうしんしないで下さい!") # Data with open("configuration.json", "r") as config: data = json.load(config) anti_profanity = data["antiProfanity"] anti_spam = data["antiSpam"] allow_spam = data["allowSpam"] log_channel = data["logChannel"] # Anti profanity if anti_profanity is True: words = [message.content] profanity = predict(words) # profanity2 = predict_prob(words) if profanity[0] == 1: await message.delete() # Delete await message.channel.send(f"{message.author.mention} Do not insult!") # Logs if len(message.content) > 1600: message.content = message.content + "..." embed = discord.Embed(title=f"**{message.author}が侮辱を含んだメッセージを送信しました。**", description=f"チャンネル:{message.channel.mention}.\n\n" f"**__ユーザー情報 :__**\n\n" f"**名前 :** {message.author}\n" f"**Id :** {message.author.id}\n\n" f"**該当のメッセージ :**\n\n{message.content}", color=0xff0000) await sendLogMessage(self, event=message, channel=log_channel, embed=embed) # Anti spam if anti_spam is True: def check(passed_message): return passed_message.author == passed_message.author and \ (datetime.utcnow() - passed_message.created_at).seconds < 15 if message.author.guild_permissions.administrator: return if message.channel.id in allow_spam: return if len(list(filter(lambda m: check(m), self.bot.cached_messages))) >= 8 and len( list(filter(lambda m: check(m), self.bot.cached_messages))) < 12: await message.channel.send(f"{message.author.mention} Stop spam please!") elif len(list(filter(lambda m: check(m), self.bot.cached_messages))) >= 12: embed = discord.Embed(title=f"**YOU HAVE BEEN KICKED FROM {message.author.guild.name}**", description=f"Reason : You spammed.", color=0xff0000) await message.author.send(embed=embed) await message.author.kick() # Kick the user await message.channel.send(f"{message.author.mention} was kicked for spamming !") # Logs -> Create a hastbin file log_time = datetime.now().strftime("%m/%d/%Y at %H:%M:%S") logs = f"[LOGS] {self.bot.user.name.upper()} - ANTI-SPAM \n\n" \ f"{message.author} ({message.author.id}) spammed in \"{message.channel}\" the {log_time}\n\n" message_number = 0 # Get user messages user_cache_messages = [i for i in self.bot.cached_messages if i.author.id == message.author.id] for i in user_cache_messages[-10:]: message_number += 1 logs = f"{logs}\n[{message_number}] {i.content}" url = 'https://hastebin.com' async with aiohttp.ClientSession() as session: async with session.post(f'{url}/documents', data=logs) as hastbin: hastbin = await hastbin.json() hastbin_url = url + "/" + hastbin['key'] embed = discord.Embed(title=f"**{message.author}がキックされました。**", description=f"**理由 :**{message.channel.mention}でスパムを行いました。\n\n" f"**__ユーザー情報 :__**\n\n" f"**名前 :** {message.author}\n" f"**Id :** {message.author.id}\n\n" f"**ログ :** {hastbin_url}", color=0xff0000) await sendLogMessage(self, event=message, channel=log_channel, embed=embed)
#coding:utf-8 ''' 基于肤色的裸体图像检测 ''' import nude from nude import Nude print(nude.is_nude('datas/images/test2.jpg')) n = Nude('datas/images/test2.jpg') n.parse() print("damita :", n.result, n.inspect())
html = response.read() m = re.search("<img.+?src=[\"'](.+?)[\"'].*?>",html) if m is not None: lol= m.group(0) m = re.search("/(.+?)png",lol) if m is not None: lol2= m.group(0) input = "https:"+lol2 urllib.urlretrieve(input, "/Users/julienmalka/Desktop/UplmgNudeLocator/images/"+mdr+".png") n = Nude('/Users/julienmalka/Desktop/UplmgNudeLocator/images/'+mdr+".png") n.parse() if n.result==False: print bcolors.OKGREEN + "No nude on this one" + bcolors.ENDC os.remove("/Users/julienmalka/Desktop/UplmgNudeLocator/images/"+mdr+".png") else: print bcolors.OKBLUE + "Nude Found" + bcolors.ENDC except urllib2.HTTPError, e: