mdai / ml-lessons

Intro to deep learning for medical imaging lesson, by MD.ai
Apache License 2.0
258 stars 135 forks source link

InvalidArgumentError #6

Closed Telang8100 closed 6 years ago

Telang8100 commented 6 years ago

Hi I am trying to run the following cell

import warnings warnings.filterwarnings("ignore") model.train(dataset_train, dataset_val,learning_rate=config.LEARNING_RATE, epochs=NUM_EPOCHS, layers='all',augmentation=augmentation)

And I am getting this error

File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1335, in _do_call raise type(e)(node_def, op, message)

InvalidArgumentError: indices[553] = 960 is not in [0, 960) [[Node: ROI_4/GatherV2_20 = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ROI_4/strided_slice_42, ROI_4/strided_slice_43, training_5/SGD/gradients/roi_align_classifier_4/concat_grad/mod)]]

Caused by op 'ROI_4/GatherV2_20', defined at: File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 269, in main() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 265, in main kernel.start() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\kernelapp.py", line 486, in start self.io_loop.start() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tornado\platform\asyncio.py", line 127, in start self.asyncio_loop.run_forever() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\asyncio\base_events.py", line 422, in run_forever self._run_once() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\asyncio\base_events.py", line 1432, in _run_once handle._run() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\asyncio\events.py", line 145, in _run self._callback(self._args) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tornado\ioloop.py", line 759, in _run_callback ret = callback() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper return fn(args, kwargs) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 263, in enter_eventloop self.eventloop(self) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\eventloops.py", line 134, in loop_qt5 return loop_qt4(kernel) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\eventloops.py", line 122, in loop_qt4 _loop_qt(kernel.app) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\eventloops.py", line 106, in _loopqt app.exec() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\eventloops.py", line 39, in process_stream_events kernel.do_one_iteration() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 298, in do_one_iteration stream.flush(zmq.POLLIN, 1) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 357, in flush self._handle_recv() File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv self._run_callback(callback, msg) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback callback(*args, *kwargs) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tornado\stack_context.py", line 276, in null_wrapper return fn(args, kwargs) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher return self.dispatch_shell(stream, msg) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell handler(stream, idents, msg) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request user_expressions, allow_stdin) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\ipkernel.py", line 208, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\ipykernel\zmqshell.py", line 537, in run_cell return super(ZMQInteractiveShell, self).run_cell(args, kwargs) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2662, in run_cell raw_cell, store_history, silent, shell_futures) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2785, in _run_cell interactivity=interactivity, compiler=compiler, result=result) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2909, in run_ast_nodes if self.run_code(code, result): File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2963, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in runfile('E:/Spyder/pneumonia22.py', wdir='E:/Spyder') File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "E:/Spyder/pneumonia22.py", line 209, in model = modellib.MaskRCNN(mode='training', config=config, model_dir=MODEL_DIR) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\mask_rcnn-2.1-py3.6.egg\mrcnn\model.py", line 1845, in init self.keras_model = self.build(mode=mode, config=config) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\mask_rcnn-2.1-py3.6.egg\mrcnn\model.py", line 1973, in build config=config)([rpn_class, rpn_bbox, anchors]) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\keras\engine\topology.py", line 617, in call output = self.call(inputs, kwargs) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\mask_rcnn-2.1-py3.6.egg\mrcnn\model.py", line 296, in call names=["pre_nms_anchors"]) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\mask_rcnn-2.1-py3.6.egg\mrcnn\utils.py", line 829, in batch_slice output_slice = graph_fn(inputs_slice) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\mask_rcnn-2.1-py3.6.egg\mrcnn\model.py", line 294, in pre_nms_anchors = utils.batch_slice([anchors, ix], lambda a, x: tf.gather(a, x), File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 2666, in gather return gen_array_ops.gather_v2(params, indices, axis, name=name) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 3760, in gather_v2 "GatherV2", params=params, indices=indices, axis=axis, name=name) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3414, in create_op op_def=op_def) File "C:\Users\SIDDHESHWAR\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1740, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): indices[553] = 960 is not in [0, 960) [[Node: ROI_4/GatherV2_20 = GatherV2[Taxis=DT_INT32, Tindices=DT_INT32, Tparams=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ROI_4/strided_slice_42, ROI_4/strided_slice_43, training_5/SGD/gradients/roi_align_classifier_4/concat_grad/mod)]]

apyrros commented 6 years ago

Same here any solution?

Telang8100 commented 6 years ago

Same here any solution?

No solution yet. Do you have any luck with it?

transcranial commented 6 years ago

That is a cryptic error known to sometimes occur with https://github.com/matterport/Mask_RCNN/ running in CPU mode. Please make absolutely sure you're running in GPU mode.

apyrros commented 6 years ago

Actually this was answered already in another post - Comment out the following line in the DetectorConfig function.

RPN_ANCHOR_SCALES = (32, 64)

Should work then. But don't comment out TRAIN_ROIS_PER_IMAGE. https://github.com/mdai/ml-lessons/issues/2

Telang8100 commented 6 years ago

By commenting RPN_ANCHOR_SCALES = (32, 64) the coding is running properly. Thanks.