Failed to parse NetParameter

I am getting the following error when OpenCV(4.6.0) /io/opencv/modules/dnn/src/caffe/caffe_io.cpp:1176: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse NetParameter file: weights/gender_net.caffemodel in function 'ReadNetParamsFromBinaryFileOrDie'
when I run these 3 commands:

GENDER_MODEL = 'weights/deploy_gender.prototxt'
GENDER_PROTO = 'weights/gender_net.caffemodel'
gender_net = cv2.dnn.readNetFromCaffe(GENDER_MODEL, GENDER_PROTO)

the first two commands are running fine, and I have saved the files in the weights folder, but the last line
gender_net = cv2.dnn.readNetFromCaffe(GENDER_MODEL, GENDER_PROTO)
is throwing an error
OpenCV(4.6.0) /io/opencv/modules/dnn/src/caffe/caffe_io.cpp:1176: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse NetParameter file: weights/gender_net.caffemodel in function 'ReadNetParamsFromBinaryFileOrDie'.
Please help

things to try:

  • use an absolute path to the model / proto
    (python noobs always get relative pathes wrong …)
  • check the integrity of your data
    ( md5 of the model, look at the proto with a text editor)