Login using Social Account
     Continue with GoogleLogin using your credentials
Let's read the weights and config files. The .cfg file consists of a textual description of the network architecture. The .weights file is the file with learned network.
We then use cv2.dnn.readNetFromDarknet
function to build the network, as per the configurations and learned weights as mentioned in the .cfg and .weights files.
Read the model config and weights files using the readNetFromDarknet method in the OpenCV DNN module. Set weights
to /cxldata/projects/yolov4/yolov4.weights
and config
to /cxldata/projects/yolov4/yolov4.cfg
.
weights=<<your code comes here>>
config=<<your code comes here>>
Now build the model net
using cv2.dnn.readNetFromDarknet
function with config, weights
arguments.
net = <<your code comes here>>(config, weights)
Let us take a look at all the layers in the model. As you will there a total of 379 layers.
ln = net.getLayerNames()
print (len(ln), ln )
We will determine the output layers. The output layers are the last layers and therefore their output connections are open and unconnected.
net.getUnconnectedOutLayers()
Determine only the output layer names that we need from YOLOv4:
ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()]
print (ln)
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...