Unable to import ONNX model

I am trying to use an adult content detection ONNX model. This model was originally converted from a tensorflow model by the author. When importing the model using the following I get an error message. Here is the line throwing the error:

net = cv2.dnn.readNetFromONNX("/home/matt/.NudeNet/detector_v2_default_checkpoint.onnx")

Error Message:

[ERROR:0] global /tmp/pip-req-build-dzetuct2/opencv/modules/dnn/src/onnx/onnx_importer.cpp (2108) handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 4 outputs: [Split]:(clipped_boxes/unstack:0)
Traceback (most recent call last):
  File "cv.py", line 5, in <module>
    net = cv2.dnn.readNetFromONNX("/home/matt/.NudeNet/detector_v2_default_checkpoint.onnx")                                                                                     
cv2.error: OpenCV(4.5.2) /tmp/pip-req-build-dzetuct2/opencv/modules/dnn/src/onnx/onnx_importer.cpp:2129: error: (-2:Unspecified error) in function 'handleNode'                  
> Node [Split]:(clipped_boxes/unstack:0) parse error: OpenCV(4.5.2) /tmp/pip-req-build-dzetuct2/opencv/modules/dnn/src/layers/slice_layer.cpp:164: error: (-215:Assertion failed)
inputs.size() == 1 in function 'getMemoryShapes'

The model can be found here: https://github.com/notAI-tech/NudeNet/releases/download/v0/detector_v2_default_checkpoint.onnx

I’m running version 4.5.2 of OpenCV.

Steps to Reproduce:

  1. Download the model above.
  2. Run the following code:
import numpy as np
import cv2

net = cv2.dnn.readNetFromONNX("/home/matt/.NudeNet/detector_v2_default_checkpoint.onnx")

I’ve spent the day trying toi debug this and have read through lots of github issues anf foruym posts but can’t find out how I can go about fixing this.

I have checked the model itself and the order of the nodes seems OK as I’ve run it through this checker:

import onnx
onnx_model = onnx.load('/home/matt/.NudeNet/detector_v2_default_checkpoint.onnx')

# Check the model
except onnx.checker.ValidationError as e:
    print('The model is invalid: %s' % e)
    print('The model is valid!')

I can also confirm the model actually works using the onnxruntime:

from detector_utils import preprocess_image
import numpy as np
import onnxruntime as rt

image, scale = preprocess_image('./boobs.jpeg')
sample = np.expand_dims(image, axis=0)

onnx_path = '/home/matt/.NudeNet/detector_v2_default_checkpoint.onnx'
sess = rt.InferenceSession(onnx_path)
x_name = sess.get_inputs()[0].name
y1_name = sess.get_outputs()[0].name
y2_name = sess.get_outputs()[1].name
y3_name = sess.get_outputs()[2].name
outPred = sess.run([y1_name, y2_name, y3_name], {x_name: sample})


Any help would be appreciated!