Kemo-Huang / JMODT

Joint Multi-Object Detection and Tracking with Camera-LiDAR Fusion for Autonomous Driving
MIT License
97 stars 25 forks source link

UnboundLocalError: local variable 'val_loss_epoch' referenced before assignment #2

Open minho8849 opened 3 years ago

minho8849 commented 3 years ago

I want to train this code for dataset, following as

$ python tools/train.py --data_root /home/my_com/dataset/KITTI/ --batch_size 4

when first epoch is done, I got error

Traceback (most recent call last):
File "tools/train.py", line 164, in main() File "tools/train.py", line 157, in main val_loader File "/home/my_com/virtualenv/JMODT/jmodt/utils/train_utils.py", line 198, in train prev_val_loss = val_loss_epoch

Can I get some solution from this problem?

Thanks.

Bruce-Si commented 3 years ago

I want to train this code for dataset, following as

$ python tools/train.py --data_root /home/my_com/dataset/KITTI/ --batch_size 4

when first epoch is done, I got error

Traceback (most recent call last): File "tools/train.py", line 164, in main() File "tools/train.py", line 157, in main val_loader File "/home/my_com/virtualenv/JMODT/jmodt/utils/train_utils.py", line 198, in train prev_val_loss = val_loss_epoch

Can I get some solution from this problem?

Thanks.

I get the same error. Is there any progress?

Lemon-L7 commented 3 years ago

I want to train this code for dataset, following as $ python tools/train.py --data_root /home/my_com/dataset/KITTI/ --batch_size 4 when first epoch is done, I got error Traceback (most recent call last): File "tools/train.py", line 164, in main() File "tools/train.py", line 157, in main val_loader File "/home/my_com/virtualenv/JMODT/jmodt/utils/train_utils.py", line 198, in train prev_val_loss = val_loss_epoch Can I get some solution from this problem? Thanks.

I get the same error. Is there any progress?

I get the same error. Is there any progress? I means how to get the sample2frame.txt & seq2sample.txt in TESTING file

@Bruce-Si

Bruce-Si commented 3 years ago

I have not noticed this problem... The script kitti_converter.py just creates TRAINING file. Maybe we have to create TESTING file by imitating the kitti_converter.py. @Lemon-L7

Lemon-L7 commented 3 years ago

yeap,I check the files, if author‘s code didn't has any trouble, we should create TESTING file, like he sets in his constructor. @Bruce-Si

ferrari700 commented 3 years ago

yeap,I check the files, if author‘s code didn't has any trouble, we should create TESTING file, like he sets in his constructor. @Bruce-Si

Hello, I also encountered the same problem, have you solved it? How is the testing file created?

zzm-hl commented 2 years ago

我想为数据集训练此代码,如下所示

$ python 工具/train.py --data_root /home/my_com/dataset/KITTI/ --batch_size 4

当第一个时代完成时,我得到了错误

回溯(最后一次调用): 文件“tools/train.py”,第 164 行,在 main() 文件“tools/train.py”,第 157 行,在 main val_loader 文件“/home/my_com/virtualenv/JMODT/ jmodt/utils/train_utils.py",第 198 行,在火车 prev_val_loss = val_loss_epoch

我可以从这个问题中得到一些解决方案吗?

谢谢。

I have the same problem ,have you solved it? @Kemo-Huang @minho8849

lx-ynu commented 2 years ago

After I assigned an initial value to "val_loss_epoch", the network can be trained, but there is another problem, the "best_model" will not be updated after the first epoch is trained.

zkp0113 commented 2 years ago

@Kemo-Huang Excuse me,I meet same problems. No.1 ”UnboundLocalError: local variable 'val_loss_epoch' referenced before assignment“; For this problem I change some code then the problem fixed,but it comes new problem that same with this.

No.2 “best_model.path” is not update.

对不起,我也遇到同样的问题。 第1条问 “UnboundLocalError:赋值前引用的局部变量‘val_loss_epoch’”;对于这个问题,我更改了一些代码,然后问题得到了解决,但随之而来的是新问题。 第2条 “best_model.path”未更新。

sazanali commented 2 years ago

add the following line for solution def train(self, start_it, start_epoch, n_epochs, train_loader, val_loader=None, stop_thres=5): eval_frequency = self.eval_frequency if self.eval_frequency > 0 else 1 global val_loss_epoch global prev_train_loss global prev_val_loss

in the bottom

else: prev_train_loss = train_loss_epoch prev_val_loss = val_loss_epoch

            val_loss_epoch =1
            if val_loss_epoch < min_val_loss:
                min_val_loss = val_loss_epoch
sazanali commented 2 years ago

Any solution for best_model.path???