cvNet = cv.dnn.readNetFromTensorflow argument error

asked 2018-02-01 07:08:44 -0600

updated 2018-02-01 08:33:35 -0600

berak gravatar image

Traceback (most recent call last):File "tf_opencv.py", line 3, in module cvNet = cv.dnn.readNetFromTensorflow('/home/hassaanrafique/train_drone_car/fine_tuned_model/frozen_inference_graph.pb', '/home/hassaanrafique/opencv_model/train.pbtxt') TypeError: readNetFromTensorflow() takes at most 1 argument (2 given)

My Code:

import cv2 as cv

cvNet = cv.dnn.readNetFromTensorflow('/home/hassaanrafique/train_drone_car/fine_tuned_model/frozen_inference_graph.pb', '/home/hassaanrafique/opencv_model/train.pbtxt')

img = cv.imread('/home/hassaanrafique/test.png')
rows = img.shape[0]
cols = img.shape[1]
cvNet.setInput(cv.dnn.blobFromImage(img, 1.0/127.5, (300, 300), (127.5, 127.5, 127.5), swapRB=True, crop=False))
cvOut = cvNet.forward()

for detection in cvOut[0,0,:,:]:
    score = float(detection[2])
    if score > 0.3:
        left = detection[3] * cols
        top = detection[4] * rows
        right = detection[5] * cols
        bottom = detection[6] * rows
        cv.rectangle(img, (int(left), int(top)), (int(right), int(bottom)), (23, 230, 210), thickness=2)

cv.imshow('img', img)
cv.waitKey()
edit retag flag offensive close merge delete

Comments

1

cv.__version__ ?

(might need to update to latest 3.4, versions before don't have this, which means, you cannot tweak the pbtxt)

berak gravatar imageberak ( 2018-02-01 07:31:26 -0600 )edit

I have this same error, have you fixed it?

pedrolima gravatar imagepedrolima ( 2018-02-07 11:00:28 -0600 )edit