DOsinga / deep_learning_cookbook

Deep Learning Cookbox
Apache License 2.0
686 stars 335 forks source link

11.2 Detecting Multiple Images -- Issue with the format_img function #84

Open ValentinDelpy opened 3 years ago

ValentinDelpy commented 3 years ago

Hi, We are trying to implement the Notebook, and we have the error following : "NameError: name 'format_img' is not defined", at the line "X, ratio = format_img(img,c)", of the following code,

`img = cv2.imread('data/cat_dog.jpg') X, ratio = format_img(img, c)

if K.image_dim_ordering() == 'tf': X = np.transpose(X, (0, 2, 3, 1))

y1, y2, f = model_rpn.predict(X) r = keras_frcnn.roi_helpers.rpn_to_roi(y1, y2, c, K.image_dim_ordering(), overlap_thresh=0.7) roi_count = R.shape[0] // c.num_rois r2 = np.zeros((roi_count * c.num_rois, r.shape[1])) r2 = r[:r2.shape[0],:r2.shape[1]] r2 = np.reshape(r2, (roi_count, c.num_rois, r.shape[1])) `

Is the function defined somewhere in the project ? We can't retrieve it, and can't solve this issue.

mikechen66 commented 3 years ago

I tried the the methods as follows. All the new methods could not work. I thought that format_img() might be either CV2 or PIL methods. However, I could not find the trackback in the web.

# -X, ratio = format_img(img, c)
X, ratio = format.img(img, c)
AttributeError: 'builtin_function_or_method' object has no attribute 'img'

# -X, ratio = format_img(img, c)
X, ratio = format(img, c)
TypeError: format() argument 2 must be str, not Config

# -X, ratio = format_img(img, c)
X, ratio = im.format(img, c)
NameError: name 'im' is not defined
mikechen66 commented 3 years ago

format_img() is included in the library keras_frcnn. Please import the function of format_img() as follows.

from measure_map import format_img

Cheers