zjjMaiMai / TinyHITNet

HITNet: Hierarchical Iterative Tile Refinement Network for Real-time Stereo Matching
152 stars 21 forks source link

Training with custom datasets #7

Closed williamhyin closed 2 years ago

williamhyin commented 2 years ago

Hi I am training the hitnet with custom datasets, which has size (720 464). I prepared custom datasets like kitti-stereo datasets and di preprocess like kitti2015. But I faced a problem bellow:

result = self.forward(*input, kwargs) File "/root/miniconda3/lib/python3.6/site-packages/torch/nn/parallel/distributed.py", line 705, in forward output = self.module(*inputs[0], *kwargs[0]) File "/root/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(input, kwargs) File "/root/miniconda3/lib/python3.6/site-packages/pytorch_lightning/overrides/base.py", line 81, in forward output = self.module.training_step(*inputs, **kwargs) File "/workspace/TinyHITNet/train.py", line 49, in training_step self.hparams, File "/workspace/TinyHITNet/losses.py", line 133, in calc_loss tile_size=tile_size, File "/workspace/TinyHITNet/losses.py", line 64, in calc_multi_scale_loss diff = (pred - target).abs() RuntimeError: The size of tensor a (8) must match the size of tensor b (7) at non-singleton dimension 2

I dont know why this happend. Should I changed the plane_fitting code?

x = HitnetModule.plane_fitting(x, 1024, 1, 9, 1e-3, 1e5)

Or should I changed the kitti model?

I am looking forward to your reply.

Thanks

zjjMaiMai commented 2 years ago

you must crop image size multiple of 64 when training if you use kitti model. https://github.com/zjjMaiMai/TinyHITNet/blob/6a78b3453bef927f66f04ca3f8949a15509cf3fc/script/hitnet_kitti.sh#L23

williamhyin commented 2 years ago

you must crop image size multiple of 64 when training if you use kitti model.

https://github.com/zjjMaiMai/TinyHITNet/blob/6a78b3453bef927f66f04ca3f8949a15509cf3fc/script/hitnet_kitti.sh#L23

Thanks! It has solved my problem. Another question, how can i use pre-weights model from kitti dataset to train my custom data?

zjjMaiMai commented 2 years ago

Another question, how can i use pre-weights model from kitti dataset to train my custom data?

there is no command line to support it. but you can load weights before fine-tune by modify train.py.