tum-vision / tandem

[CoRL 21'] TANDEM: Tracking and Dense Mapping in Real-time using Deep Multi-view Stereo
912 stars 146 forks source link

RuntimeError: Freezing is currently only implemented for modules for modules in eval mode #42

Open Nekomiya-fubuki opened 1 year ago

Nekomiya-fubuki commented 1 year ago

Thank you for sharing this great paper and excellent code. I followed the README file in CVA-MMVSNET.When I tried to run the code to export to C++, there was a runtimeerroe.Could you please help me? Thank you for your time.

python export_model.py --data_dir tandem_replica --out_dir cpp_exported_models --model pretrained/ablation/abl04_fewer_depth_planes.ckpt --height 480 --width 640 --view_num 7 --jit_freeze --jit_run_frozen_optimizations

/mnt/b7074bde-e07b-4bc7-8b24-a7b759401d85/Ji/tandem-master/cva_mvsnet/models/module.py:1498: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! assert (depth > 0).all(), f"Depth min = {torch.min(depth)}" /mnt/b7074bde-e07b-4bc7-8b24-a7b759401d85/Ji/tandem-master/cva_mvsnet/models/module.py:24: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if nans.any() or infs.any(): /mnt/b7074bde-e07b-4bc7-8b24-a7b759401d85/Ji/tandem-master/cva_mvsnet/models/module.py:27: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! assert not (nans.any() or infs.any()), msg /mnt/b7074bde-e07b-4bc7-8b24-a7b759401d85/Ji/tandem-master/cva_mvsnet/models/module.py:1561: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! assert (depth_range > 0).all( --- jit_freeze Traceback (most recent call last): File "export_model.py", line 230, in main(parser.parse_args()) File "export_model.py", line 196, in main traced_script_module = torch.jit.freeze(traced_script_module) File "/home/u/anaconda3/envs/tandem/lib/python3.7/site-packages/torch/jit/_freeze.py", line 92, in freeze "Freezing is currently only implemented for modules in eval mode. " RuntimeError: Freezing is currently only implemented for modules in eval mode. Please call .eval() on your module before freezing.