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

  Enroll Now

Getting the image

  • We will read the image using an OpenCV method. We will resize it for making it easier to be viewed.

  • Then, we will make it into a blob which is a 4-dimensional array of images using cv2.dnn.blobFromImage.

  • We also do the following steps

    • Normalising pixel values by dividing by 255
    • Fixing the size to 608x608 required by Yolo
    • Swapping OpenCV's default BGR format to RGB
  • Read the image using cv2.imread():

    img=<< your code comes here >>("/cxldata/projects/yolov4/soccer.jpg")
  • Resize the image using cv2.resize().

    img=<< your code comes here >>(img, (608, 608))
  • Print the image size and get H,W the height and width of the image:

    print (img.shape)
    (H, W) = img.shape[:2]
  • Show the image:

  • Use the cv2.dnn.blobFromImage to read the image as a blob, normalize it, fix the size of the image, and set the image channels as or OpenCV.

    blob = cv2.dnn.blobFromImage(img, 1 / 255.0, (608, 608), swapRB=True, crop=False)
  • Print the blob shape:

    print ("Shape of blob", blob.shape)
  • We can see the individual color streams of the image:

    split_blob=np.hstack([ blob[0, 0, :, :],blob[0, 1, :, :], blob[0, 2, :, :],])

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