py-faster-rcnn icon indicating copy to clipboard operation
py-faster-rcnn copied to clipboard

ValueError: could not broadcast input array from shape (4) into shape (0)

Open harora opened this issue 9 years ago • 13 comments

Hi I was training model on my own dataset. I am facing error ValueError: could not broadcast input array from shape (4) into shape (0) and this occurs after iteration 120 . So its probably a problem because of inappropriate data. Can someone help me on this ? Kindle tell me a way to trace that image so i can remove it from my dataset.

I0825 06:35:20.970911 30024 solver.cpp:245] Train net output #3: rpn_loss_bbox = 0.0442318 (* 1 = 0.0442318 loss) I0825 06:35:20.970918 30024 sgd_solver.cpp:106] Iteration 120, lr = 0.001 Traceback (most recent call last): File "tools/train_net.py", line 112, in max_iters=args.max_iters) File "/home/harora/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 160, in train_net model_paths = sw.train_model(max_iters) File "/home/harora/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 101, in train_model self.solver.step(1) File "/home/harora/py-faster-rcnn/tools/../lib/rpn/proposal_target_layer.py", line 66, in forward rois_per_image, self._num_classes) File "/home/harora/py-faster-rcnn/tools/../lib/rpn/proposal_target_layer.py", line 191, in _sample_rois _get_bbox_regression_labels(bbox_target_data, num_classes) File "/home/harora/py-faster-rcnn/tools/../lib/rpn/proposal_target_layer.py", line 127, in _get_bbox_regression_labels bbox_targets[ind, start:end] = bbox_target_data[ind, 1:] ValueError: could not broadcast input array from shape (4) into shape (0)

harora avatar Aug 25 '16 10:08 harora

Please show the files you modified, Especially the training proto files.

twmht avatar Aug 27 '16 15:08 twmht

Hi @harora, did you make any changes to your training prototxt files ?

Sai-Manikantha avatar Aug 29 '16 18:08 Sai-Manikantha

same quesrion . and I'm mad now

macqueen09 avatar Dec 01 '16 14:12 macqueen09

Can you share your training prototxt file? This error is due to dimension mismatch.

The size of "bbox_pred" layer should be 4*"num_classes". Also, make sure that the "cls_score" layer is the same size as "num_classes" layer.

dopplesoldner avatar Dec 01 '16 19:12 dopplesoldner

Did you solve it? I have the same quession

unfir225 avatar Dec 28 '16 14:12 unfir225

I also had a similar problem and realized that I changed the num_classes to 19 instead of adding one background class. Changing num_classes to 20 solved my problem for a dataset of 19 object classes. Don't forget the background class!

metehandoyran avatar May 06 '17 10:05 metehandoyran

@metehandoyran Thank you so much! This was the answer for me too, we forgot to add the background class.

telwell avatar Mar 10 '18 20:03 telwell

Thank you very much. The key is the background

xlturing avatar Apr 28 '18 12:04 xlturing

For me the problem was solved by removing the cached .pkl files from ./data/cache/_train_gt.pkl

NightFury13 avatar Jun 19 '18 06:06 NightFury13

I also had a similar problem and realized that I changed the num_classes at /models/imagenet/VGG16/faster_rcnn_end2end/train.prototex instead of /models/pascal_voc/VGG16/faster_rcnn_end2end/train.prototxt

chenqingbin avatar Oct 25 '18 07:10 chenqingbin

I also had a similar problem and realized that I changed the num_classes to 19 instead of adding one background class. Changing num_classes to 20 solved my problem for a dataset of 19 object classes. Don't forget the background class! @metehandoyran thank you for your suggestion,it helps me a lot . my fault is because of that the key "id" in category in json begins with “zero",the real value should starts with "1".

rudy-letote avatar Nov 27 '18 09:11 rudy-letote

but I have change the file of pascal_voc ,when I training ,they also give me the Error

I hope i can get your help very much and give you my best wishes Uploading QV0J5$OXEM%7NG$H@3NB`OI.png…

foxpandar avatar May 26 '20 10:05 foxpandar

For me the problem was solved by removing the cached .pkl files from ./data/cache/_train_gt.pkl

I fix the problem by doing the same with you

AlphaJia avatar Oct 01 '20 08:10 AlphaJia