Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing in

  Enroll Now

Getting the Model and Pre-trained Weights

  • 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.

INSTRUCTIONS
  • 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)
    

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...