I am trying to use yahoo nsfw model with OpenCV. Here is what I have tried. I just copied deploy.prototxt and resnet_50_1by2_nsfw.caffemodel from the repository.
import cv2 as cv
cvNet = cv.dnn.readNetFromCaffe('deploy.prototxt','resnet_50_1by2_nsfw.caffemodel')
image_path = 'adult.jpg'
image = cv.imread(image_path)
blob = cv.dnn.blobFromImage(image, 1, (224,224), (0,0,0), True, crop=False)
cvNet.setInput(blob)
detections = cvNet.forward()
print(detections)
Whatever image I have as an input I get an output like this [[0.9855554 0.01444463]], the first value is always larger.
I chose the image size (224, 224) because in deploy.prototxt, I found the following:
name: "ResNet_50_1by2_nsfw"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 1 dim: 3 dim: 224 dim: 224 } }
}
What did I do wrong?