rbgirshick / py-faster-rcnn

Faster R-CNN (Python implementation) -- see https://github.com/ShaoqingRen/faster_rcnn for the official MATLAB version
Other
8.11k stars 4.11k forks source link

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

Open harora opened 8 years ago

harora commented 8 years ago

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)

twmht commented 8 years ago

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

Sai-Manikantha commented 8 years ago

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

macqueen09 commented 7 years ago

same quesrion . and I'm mad now

dopplesoldner commented 7 years ago

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.

unfir225 commented 7 years ago

Did you solve it? I have the same quession

metehandoyran commented 7 years ago

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!

telwell commented 6 years ago

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

xlturing commented 6 years ago

Thank you very much. The key is the background

NightFury13 commented 6 years ago

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

chenqingbin commented 5 years ago

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

rudy-letote commented 5 years ago

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".

foxpandar commented 4 years ago

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…]()

AlphaJia commented 4 years ago

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