Finding required layer in dnn module

asked 2019-10-11 03:33:23 -0600

Jorge Diaz gravatar image

updated 2019-10-11 03:55:25 -0600

berak gravatar image

I am having a problem with the dnn module when trying to implement a caffe project (

import cv2
import os
import argparse
from matplotlib import pyplot as plt
import numpy as np

net = cv2.dnn.readNetFromCaffe("deploy_vgg.prototxt", "FT_tid2013.caffemodel")

Num_Patch = 30
image_to_test = 'i04_18_2.bmp'
image = cv2.imread(image_to_test)
resized = cv2.resize(image, (224, 224))
blob = cv2.dnn.blobFromImage(resized, 1, (224, 224), (104, 117, 123))


preds = net.forward()

I get the following error when naively feeding the blob into the net.

error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\dnn\src\layers\fully_connected_layer.cpp:73: error: (-215:Assertion failed) 1 <= blobs.size() && blobs.size() <= 2 in function 'cv::dnn::FullyConnectedLayerImpl::FullyConnectedLayerImpl'

I am aware that this probably means that I have to declare a layer but I cannot understand which from the error itself. Is there a way to find which layer do I need to implement?

edit retag flag offensive close merge delete