TypeError: 'int' object is not iterable
River-mao opened this issue · 3 comments
Hello, thanks for work!
I have some problem when I try to train the model with pascal set. I follow the step show in the github page, and run:
sh tool/train.sh pascal asgnet split0_resnet50
but I get the error as follow:
[2022-02-22 16:10:06,166 INFO train.py line 329 19996] >>>>>>>>>>>>>>>> Start Evaluation >>>>>>>>>>>>>>>> Traceback (most recent call last): File "/opt/conda/envs/dual_learning/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/opt/conda/envs/dual_learning/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/tool/train.py", line 450, in <module> main() File "/home/tool/train.py", line 91, in main main_worker(args.train_gpu, args.ngpus_per_node, args) File "/home/tool/train.py", line 207, in main_worker loss_val, mIoU_val, mAcc_val, allAcc_val, class_miou = validate(val_loader, model, criterion) File "/home/tool/train.py", line 421, in validate allAcc = sum(intersection_meter.sum) / (sum(target_meter.sum) + 1e-10) TypeError: 'int' object is not iterable
I try to solve this, and I found the "intersection_meter.sum" belongs to "int" type, which leads to the error. As normal, the 'intersection_meter.sum' should be a list or array? Where ma'y I go wrong?
Thanks a lot1
You can check this function, which computes the area of intersection, and then the value will be updated in the intersection_meter.
Normally, the intersection_meter.sum should be a numpy array, and its shape should equal the number of classes.
You can check this function, which computes the area of intersection, and then the value will be updated in the intersection_meter.
Normally, the intersection_meter.sum should be a numpy array, and its shape should equal the number of classes.
Thanks a lot, I found I made the mistake in the train.txt, so there were some data mismatched, which caused the error. And I have solved this problem.
Hello, I meet the same problem and wonder how you managed to resolve it. Any insights you could share would be greatly appreciated. Thank you!