Aklavya commited on
Commit
c14d4ec
·
verified ·
1 Parent(s): e753508

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import streamlit as st
4
  import insightface
5
  from insightface.app import FaceAnalysis
6
  from PIL import Image
7
- from nudenet import NudeNet
8
 
9
  # Initialize the FaceAnalysis model
10
  app = FaceAnalysis(name='buffalo_l')
@@ -14,14 +14,14 @@ app.prepare(ctx_id=0, det_size=(640, 640)) # Ensure the model runs on the CPU i
14
  swapper = insightface.model_zoo.get_model('insightface/inswapper_128.onnx', download=True)
15
 
16
  # Initialize the NudeNet model for nudity detection
17
- nudenet = NudeNet()
18
 
19
  # Function to detect adult content in images
20
  def check_for_adult_content(image):
21
  # Convert PIL image to numpy array
22
  img = np.array(image)
23
- # Run the NudNet model
24
- result = nudenet.predict(img)
25
  # If the image contains nudity or explicit content, return True
26
  return result['label'] == 'Porn'
27
 
 
4
  import insightface
5
  from insightface.app import FaceAnalysis
6
  from PIL import Image
7
+ from nudenet import NudeClassifier
8
 
9
  # Initialize the FaceAnalysis model
10
  app = FaceAnalysis(name='buffalo_l')
 
14
  swapper = insightface.model_zoo.get_model('insightface/inswapper_128.onnx', download=True)
15
 
16
  # Initialize the NudeNet model for nudity detection
17
+ classifier = NudeClassifier()
18
 
19
  # Function to detect adult content in images
20
  def check_for_adult_content(image):
21
  # Convert PIL image to numpy array
22
  img = np.array(image)
23
+ # Run the NudeClassifier model
24
+ result = classifier.predict(img)
25
  # If the image contains nudity or explicit content, return True
26
  return result['label'] == 'Porn'
27