Update app.py
Browse files
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
|
| 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 |
-
|
| 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
|
| 24 |
-
result =
|
| 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 |
|