I got the same error as you , have you fix it? how can I do next? thanks.
Make your current path consistent with the path of the pre-trained model.
You can use
import os
print(os.path.abspath('.'))
to examine current path
------------------ 原始邮件 ------------------
发件人: "zhengxinvip"notifications@github.com;
发送时间: 2019年7月19日(星期五) 下午3:41
收件人: "jwyang/faster-rcnn.pytorch"faster-rcnn.pytorch@noreply.github.com;
抄送: "雨落烂漫"32668646@qq.com;"State change"state_change@noreply.github.com;
主题: Re: [jwyang/faster-rcnn.pytorch] ValueError: operands could not bebroadcast together with shapes (441,786,4) (1,1,3) (441,786,4) (#599)
I got the same error as you , have you fix it? how can I do next? thanks.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.
when I use the voc2007 dataset, there is no problem. but when I use my own dataset, I meet this problem, how did you deal with it, does your error is you don not consistent with the path of the pre-trained model?
before filtering, there are 8194 images...
after filtering, there are 8194 images...
8194 roidb entries
Loading pretrained weights from data/pretrained_model/resnet101_caffe.pth
Traceback (most recent call last):
File "trainval_net.py", line 310, in
data = next(data_iter)
File "/home/wuwenfu/.conda/envs/pytorch04/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 286, in __next__
return self._process_next_batch(batch)
File "/home/wuwenfu/.conda/envs/pytorch04/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
ValueError: Traceback (most recent call last):
File "/home/wuwenfu/.conda/envs/pytorch04/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/wuwenfu/.conda/envs/pytorch04/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 57, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/wuwenfu/faster-rcnn.pytorch-master/lib/roi_data_layer/roibatchLoader.py", line 67, in __getitem__
blobs = get_minibatch(minibatch_db, self._num_classes)
File "/home/wuwenfu/faster-rcnn.pytorch-master/lib/roi_data_layer/minibatch.py", line 30, in get_minibatch
im_blob, im_scales = _get_image_blob(roidb, random_scale_inds)
File "/home/wuwenfu/faster-rcnn.pytorch-master/lib/roi_data_layer/minibatch.py", line 79, in _get_image_blob
cfg.TRAIN.MAX_SIZE)
File "/home/wuwenfu/faster-rcnn.pytorch-master/lib/model/utils/blob.py", line 39, in prep_im_for_blob
im -= pixel_means
ValueError: operands could not be broadcast together with shapes (181,106,4) (1,1,3) (181,106,4)
this is my error.
I was encountered nearly this (and #616) problem.
This problem may come from a difference of color channel (expected 3 (rgb), but got 4 (rgba)).
So, I was removed alpha channel following issue comments (as just a workaround).
https://github.com/jwyang/faster-rcnn.pytorch/issues/527#issuecomment-495913202
I changed lib/model/utils/blob.py line 38-39 to followings.
im = im.astype(np.float32, copy=False)
if im.shape[2] == 4:
# in the event you have an image with alpha channels, drop it for now
im = im[:, :, :3]
im -= pixel_means
Update: I found above code has another issue.
It removes not alpha channel but another color channel (maybe green).
So, here is the fixed one.
im = im.astype(np.float32, copy=False)
if im.shape[2] == 4:
# in the event you have an image with alpha channels, drop it for now
im = im[:, :, 1:4]
im -= pixel_means
在$lib\model\util\blob.py的P39行前插入: if im.shape[2] == 4: im = im[:, :, :3]
Most helpful comment
Update: I found above code has another issue.
It removes not alpha channel but another color channel (maybe green).
So, here is the fixed one.