adumrewal / imageMatting

Simplified Deep Image Matting training code with keras on tensorflow
https://arxiv.org/abs/1703.03872
39 stars 6 forks source link

Run train.py ERROR #4

Closed kaikaigood closed 4 years ago

kaikaigood commented 4 years ago

Hi,adumrewal:

  1. When “loss=overall_loss”, "pretrained_path = None" and "num_gpu=1" are set, an error occurs when running “train.py”. The error situation is as follows:
    • code: final.compile(optimizer=sgd, loss=overall_loss, target_tensors=[decoder_target],options=run_opts)
    • error: Traceback (most recent call last): File "C:\Users\Administrator\anaconda3\envs\tensorflow1.15\lib\site-packages\tensorflow_core\python\client\session.py", line 1365, in _do_call return fn(*args) File "C:\Users\Administrator\anaconda3\envs\tensorflow1.15\lib\site-packages\tensorflow_core\python\client\session.py", line 1350, in _run_fn target_list, run_metadata) File "C:\Users\Administrator\anaconda3\envs\tensorflow1.15\lib\site-packages\tensorflow_core\python\client\session.py", line 1443, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found. (0) Invalid argument: Incompatible shapes: [8,320,320,0] vs. [0,320,320,3] [[{{node loss/refinement_pred_loss/sub_2}}]] [[loss/mul/_1021]] (1) Invalid argument: Incompatible shapes: [8,320,320,0] vs. [0,320,320,3] [[{{node loss/refinement_pred_loss/sub_2}}]] 0 successful operations. 0 derived errors ignored.
  2. When “loss=alpha_prediction_loss”is set, Training can run normally.
  3. overall_loss=0.5 alpha_prediction_loss(y_true, y_pred) + 0.5 compositional_loss(y_true, y_pred), so I doubt whether it is caused by the problem of compositional_loss. I wonder if you have encountered this problem during training? Thank you!
adumrewal commented 4 years ago

Hi @kaikaigood ,

If you are trying to use overall_loss/compositional_loss, you need to pass appropriate number of channels in batch_y data_generator. In the current implementation that would be 11 channels. I have updated the code and added appropriate comments/asserts to ensure next time a user gets stuck, they know how to overcome. Thanks for bringing this up.