Skip to content

Instantly share code, notes, and snippets.

@MeAmarP
Created February 9, 2022 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MeAmarP/787bcd0ddd2bc56341e519d64ecf1f2f to your computer and use it in GitHub Desktop.
Save MeAmarP/787bcd0ddd2bc56341e519d64ecf1f2f to your computer and use it in GitHub Desktop.
import argparse
import glob
import numpy as np
import cv2
# NOTE - This gist only to test Yolov2 model and New OpenCV DNN API
# https://pjreddie.com/darknet/yolov2/
path_to_model_weight = "yolov2-voc.weights"
path_to_model_config = "yolov2-voc.cfg"
yolov2_model = cv2.dnn_DetectionModel(path_to_model_weight, path_to_model_config)
yolov2_model.setInputSize(416,416)
yolov2_model.setInputScale(1.0 / 255.0)
yolov2_model.setInputSwapRB(True)
img = cv2.imread("iamimage.jpg")
print(img.shape)
cls_id, confid, bboxes = yolov2_model.detect(img, nmsThreshold=0.4)
print(cls_id, confid, bboxes)
@MeAmarP
Copy link
Author

MeAmarP commented Feb 9, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment