Created
February 9, 2022 11:06
-
-
Save MeAmarP/787bcd0ddd2bc56341e519d64ecf1f2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To Read more about opencv-dnn-api
https://docs.opencv.org/4.x/d3/df1/classcv_1_1dnn_1_1DetectionModel.html