dimension mismatch in forward.py
ygrayson opened this issue · 1 comments
ygrayson commented
Hi,
Here's a problem that I run into while running the python script in trained_models/forward.py. Since my input pictures are gray, I changed the variable isColor as following:
inputs = load_img(imgdir, resize = (256, 256), isColor = False, crop_size = batch_shape[3], crop_type = 'center_crop', raw_scale = 255, means = means)
Then while running the code, I encounter the error:
File "forward.py", line 85, in load_img img -= means ValueError: non-broadcastable output operand with shape (1,224,224) doesn't match the broadcast shape (3,224,224)
It looks like the size of means
and the size of img
doesn't match. How should I change the code correspondingly?
Thanks in advance.
RojunLin commented
Hi, guys,
the meanfile is in the shape of (3, 224, 224), and the image shape is in (1, 224, 224).
For the shape consistency with input images, you can average the channels of meanfile by adding "means = np.mean(mean_npy, axis=0)" in the get_mean_npyfunction.
You can find the details on the new uploaded "forward.py".
Further, it seems that grayscale images would cause performance reduction, and I suggest you use raw RGB images to train models.
The more training details have been added and presented in README, and you can refer to it.
Best regards,
Luojun Lin
At 2019-07-10 15:20:52, "Qianbo Yin" <notifications@github.com> wrote:
Hi,
Here's a problem that I run into while running the python script in trained_models/forward.py. Since my input pictures are gray, I changed the variable isColor as following:
inputs = load_img(imgdir, resize = (256, 256), **isColor = False**, crop_size = batch_shape[3], crop_type = 'center_crop', raw_scale = 255, means = means)
Then while running the code, I encounter the error:
File "forward.py", line 85, in load_img img -= means ValueError: non-broadcastable output operand with shape (1,224,224) doesn't match the broadcast shape (3,224,224)
**It looks like the size of means and the size of img doesn't match. How should I change the code correspondingly?
Thanks in advance.**
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.