-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python Wrapper #955
Comments
Yes. You can use
For detection on the video try to use Python-code like this: def capture(thresh=.5, hier_thresh=.5, nms=.45, configPath = "./cfg/yolov3.cfg", weightPath = "yolov3.weights", metaPath= "./data/coco.data", showImage= True, makeImageOnly = False, initOnly= False):
global metaMain, netMain, altNames #pylint: disable=W0603
netMain = load_net_custom(configPath.encode("ascii"), weightPath.encode("ascii"), 0, 1) # batch size = 1
metaMain = load_meta(metaPath.encode("ascii"))
num = c_int(0)
pnum = pointer(num)
num = pnum[0]
capture = cv2.VideoCapture(0)
print(capture.get(cv2.CAP_PROP_FPS))
capture.set(cv2.CAP_PROP_FRAME_WIDTH, 1024)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 768)
while True:
ret, frame = capture.read()
im, arr = array_to_image(frame)
predict_image(netMain, im)
dets = get_network_boxes(netMain, im.w, im.h, thresh, hier_thresh, None, 0, pnum, 1)
if nms:
do_nms_sort(dets, num, metaMain.classes, nms)
res = []
for j in range(num):
for i in range(metaMain.classes):
if dets[j].prob[i] > 0:
b = dets[j].bbox
nameTag = metaMain.names[i]
res.append((nameTag, dets[j].prob[i], (b.x, b.y, b.w, b.h)))
print(res)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
capture.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
print(capture()) Perhaps you should optimize this function to avoid too much CPU-usage: Lines 195 to 205 in c1bb8c1
|
You're awesome, I will try this. |
The python wrapper does not have speed decrease? |
I haven't tried the AlexeyAB wrapper but I have the Yolo3-4-Py. With CPU it runs at max 1 FPS and with GPU it should near to 10 FPS(As suggested by developer). |
Hey Alex, I am back to bug you again. I compiled the yolo_cpp_dll without any errors but getting these errors when running darknet.py. python darknet.py Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): |
@sushant1727 What of these 2 files did you run?
Is |
@AlexeyAB: I copied the file Traceback (most recent call last): |
@sushant1727
|
Directory is C:\Users..\Desktop\darknet-master>python darknet.py 06/08/2018 03:52 PM 964,608 yolo_cpp_dll.dll |
@sushant1727 Run:
|
I've copypasted
When I ran this code, nothing was detected:
Here's the result from the same video using the executable:
The same thing happens when I use my custom model cfg and weights to test. ADD: Just to clarify, I understand that the image is supposed to be displayed without bounding box. I can just add couple of However, the program just doesn't detect anything at all - |
( If the following resolution is not related, please let me know and I will remove this comment ) Windows 7 + Visual Studio 2015 + OpenCV 2.4.13 |
@willSapgreen Hi, I have the same error on my PC, Win 10, x64, opencv 3.4.0, CUDA 10, python 3.5.4.
My Could you help me as well? thanks. |
@hj3yoo Hi! Have you solved this problem? I also got empty results... |
After successfully running darnknet.exe in windows now I am looking forward to use Python with your implementation.
Is there a way I can use Python wrapper in windows/ubuntu with/without GPU?
Thanks
Shan
The text was updated successfully, but these errors were encountered: