endernewton / tf-faster-rcnn

Tensorflow Faster RCNN for Object Detection
https://arxiv.org/pdf/1702.02138.pdf
MIT License
3.65k stars 1.58k forks source link

Demo.py ERROR #387

Open BubbleTea51 opened 5 years ago

BubbleTea51 commented 5 years ago

Hi guys, I ve run the demo.py and it got error, saying

"Traceback (most recent call last): File "D:/tf-faster-rcnn-master/tf-faster-rcnn-master/tools/demo.py", line 153, in demo(sess, net, im_name) File "D:/tf-faster-rcnn-master/tf-faster-rcnn-master/tools/demo.py", line 85, in demo scores, boxes = im_detect(sess, net, im) File "D:\tf-faster-rcnn-master\tf-faster-rcnn-master\tools..\lib\model\test.py", line 93, in imdetect , scores, bbox_pred, rois = net.test_image(sess, blobs['data'], blobs['im_info']) File "D:\tf-faster-rcnn-master\tf-faster-rcnn-master\tools..\lib\nets\network.py", line 478, in test_image feed_dict=feed_dict) File "C:\Users\PC\Anaconda3\envs\tf-faster-rcnn-master\lib\site-packages\tensorflow\python\client\session.py", line 877, in run run_metadata_ptr) File "C:\Users\PC\Anaconda3\envs\tf-faster-rcnn-master\lib\site-packages\tensorflow\python\client\session.py", line 1076, in _run str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (1, 3, 600, 800) for Tensor 'Placeholder:0', which has shape '(1, ?, ?, 3)')'"

I have no idea what I was massing.

My machine is Windows 10 (64 bit) : Python 3.6

If anyone faced this error before, please share me how to solve this. Thank very much.

rnsandeep commented 5 years ago

The dimensions of your image are altered. change it to (1, height, width, 3) instead of (1, 3, height, width).

You can do that with im = np.reshape(im, (im.shape[2], im.shape[0], im.shape[1])) after reading the image. I guess you are reading the image with libraries other than opencv. better use opencv then no need to reshape.