Open mikechen66 opened 4 years ago
During running the example application, I found out the outstanding 'scipy.misc' issues. I am pleased to give the related solutions ad follows.
ImportError: cannot import name 'imread' and 'imsave 'from 'scipy.misc'
First, install imageio
$ conda install imageio or $ pip install imageio
Second, change from scipy.misc import imread, imsave to: from imageio import imread, imsave
imageio at conda: https://github.com/conda-forge/imageio-feedstock
ImportError: cannot import name 'imresize' from 'scipy.misc'
First, install scikit-image
$ conda install -c conda-forge scikit-image or $ pip install scikit-image
Second, change from scipy.misc import imresize to: from skimage.transform import resize
scikit-image: https://scikit-image.org/docs/dev/install.html pypi: https://pypi.org/project/skimage/ example: https://scikit-image.org/docs/stable/auto_examples/transform/plot_rescale.html
ImportError: cannot import name 'fromimage' from 'scipy.misc' ImportError: cannot import name 'toimage' from 'scipy.misc'
Aopt the numpy method: fromimage(im) -> np.asarray(im)
Adopt the pillow method Image.fromarray(): toimage() -> Image.fromarray()
stackoverflow: https://stackoverflow.com/questions/57796368/attributeerror-importerror-on-scipy-misc-image-functions-e-x-imread-imresize
Hi Douwe:
It is a long journey.
A good news is that I have gotten through the error: TypeError: add_weight() got multiple values for argument 'name' by correcting FixedBatchNormalization.py and other scripts related to the library of keras_frcnn.
However, I have not yet completed to run the application due to the function of format_img. It shows: NameError: name 'format_img' is not defined. I check both CV2 and PIL, there is no traceback for such an error.
Since keras_rfcnn is a classical case called by the application of 11.1 Detecting Multiple Images. I want to figure out it. Hope you can give a help.
Appreciate for your reply,
import cv2
import PIL
from PIL import Image
img = cv2.imread('/home/mike/Documents/dl-cookbook/data/cat_dog.jpg')
X, ratio = format_img(img, c)
# -if K.image_dim_ordering() == 'tf':
if K.image_data_format() == 'channels_last':
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)
r = keras_frcnn.roi_helpers.rpn_to_roi(y1, y2, c, K.image_data_format(), 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]))
NameError Traceback (most recent call last)
After adding the following code "from measure_map import format_img", there is no TypeError: add_weight() got multiple values for argument 'name'.
However, it has the TypeError: Object of type 'NoneType' has no len(). So I have added the issue 11.2
Hi Douwe:
I adopted the code of kbardool/keras-frcnn after yhenon/keras-frcnn was deprecated and deleted in the Github. While running the script of train_frcnn.py, the system raised TypeError: add_weight() got multiple values for argument 'name'.
I am pleased to provide the Snippet of the code, detailed TypeError Message and related environment code of lines for your information.
1. Snippet of the code
Since Keras was updated, I have changed the line of code from" if K.image_dim_ordering() == 'th':" to "if K.image_data_format() == 'channels_first':"
2. TypeError Message
TypeError Traceback (most recent call last)