ValueError: could not broadcast input array from shape (32,29) into shape (32,32)
parsibox opened this issue · 20 comments
python3.6 main.py
Using TensorFlow backend.
(32, 32)
[2.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 32)
[0.]
(32, 29)
Traceback (most recent call last):
File "main.py", line 53, in <module>
prediction = classifier.knn_classify(number)
File "/home/mohsen/Desktop/python/farsi-car-number-plate-recognition/classifier.py", line 68, in knn_classify
test_data[0] = img
ValueError: could not broadcast input array from shape (32,29) into shape (32,32)
i do not change any thing
i run your sample code
did you try it?
ok i wait for you
the bug is from the detector.
it should not detect the blue part of the flag but it does!
I will try to fix this.
thanks
i need this code
i am still waiting for you
@parsibox could you please upload your testing image somewhere and give me a download link?
i am still waiting for you
i am still waiting for you
did you solve this problem? i had same problem
no
no
i think we can rewrite this resize function
tarfget is to resize any image to 32*32
def __resize_image(src_image, dst_image_height, dst_image_width):
src_image_height = src_image.shape[0]
src_image_width = src_image.shape[1]
if src_image_height > dst_image_height or src_image_width > dst_image_width:
height_scale = dst_image_height / src_image_height
width_scale = dst_image_width / src_image_width
scale = min(height_scale, width_scale)
img = cv2.resize(src=src_image, dsize=(0, 0), fx=scale, fy=scale, interpolation=cv2.INTER_CUBIC)
else:
img = src_image
img_height = img.shape[0]
img_width = img.shape[1]
dst_image = np.zeros(shape=[dst_image_height, dst_image_width], dtype=np.uint8)
y_offset = (dst_image_height - img_height) // 2
x_offset = (dst_image_width - img_width) // 2
dst_image[y_offset:y_offset+img_height, x_offset:x_offset+img_width] = img
return dst_image
@parsibox @sabrabano0 I was far from this subject for years. let me read the principles used in this project and try to fix this bug.
maybe I should refactor or rebase this project. because it is not funny to deal with this problem with knn
or a simple cnn
it should be under sth like YOLO
or SSD
hand!
@parsibox @sabrabano0 I was far from this subject for years. let me read the principles used in this project and try to fix this bug.
maybe I should refactor or rebase this project. because it is not funny to deal with this problem withknn
or a simplecnn
it should be under sth likeYOLO
orSSD
hand!
Not so complicated, as I mentioned above the problem is in the function resize. You have included resizing for bigger image than 32 x 32 but not for smaller like 24 x 32.