Can you please suggest how to replace this code with OpenCV's darknet implementation ?

asked 2019-03-26 20:49:45 -0600

coolcoder001 gravatar image

updated 2019-03-27 02:51:22 -0600

Hi , I came across a code which uses custom YoLo model.

argv['LABELS']        = self.LABELS
        argv['BATCH_SIZE']    = self.BATCH_SIZE * self.SEQUENCE_LENGTH
        argv['IMAGE_H']       = self.IMAGE_H
        argv['IMAGE_W']       = self.IMAGE_W
        argv['GRID_H']        = self.GRID_H
        argv['GRID_W']        = self.GRID_W

    self.detector = KerasYOLO(argv)

 self.model_detector = Model( inputs=self.detector.model.input[0],
                                     outputs=[ self.detector.model.get_layer('conv_23').output,
                                               self.detector.model.get_layer('conv_feat').output])

Now, I want to replace this self.detector object with readNetFromDarknet

I could not find out functions, which could replace self.detector.model.input[0] and self.detector.model.get_layer('<layer_id>').output

All I found out was this documented function [getLayerShapes]. (https://docs.opencv.org/3.4/db/d30/cl...)

But , I am not able to use it. the functioin getLayerShapes takes netInputShape as parameter. How can I get that ?

Can anyone please help ?

Thanks in advance.

edit retag flag offensive close merge delete

Comments

believe it or not, it's unclear, where the problem is. you don't understand, which params are needed, and what for ?

what about looking at the python sample ?

berak gravatar imageberak ( 2019-03-27 02:08:58 -0600 )edit

Hi @berak , thanks for reply. the functioin getLayerShapes takes netInputShape as parameter. How can I get that ?

coolcoder001 gravatar imagecoolcoder001 ( 2019-03-27 02:38:34 -0600 )edit

hey, you're probably looking at the wrong place in the c++ code (far too deep !)

again, if you're interested in doin that from python, you have to look at the python samples, and functions like blobFromImage (for the input) and getUnconnectedLayers() for the output

berak gravatar imageberak ( 2019-03-27 03:04:10 -0600 )edit

Try OpenCV's object detection sample first.

dkurt gravatar imagedkurt ( 2019-03-27 03:15:23 -0600 )edit