wgcban / ChangeFormer

[IGARSS'22]: A Transformer-Based Siamese Network for Change Detection
https://www.wgcban.com/research#h.e51z61ujhqim
MIT License
427 stars 57 forks source link

Missing key(s) in state_dict for BASE_Transformer. #64

Closed itstatev closed 1 year ago

itstatev commented 1 year ago

I am trying to test ChangeFormer on my own dataset and I get an error saying "I am trying to test the project on my own dataset, but I get an error saying "RuntimeError: Error(s) in loading state_dict for BASE_Transformer: Missing key(s) in state_dict: "pos_embedding", "resnet.conv1.weight", ...". How can I work this out? I downloaded the weights from the Dropbox link mentioned in the repo.

wgcban commented 1 year ago

@check could you pls check the model you specified and the downloaded wights belong to same model.

itstatev commented 1 year ago

@wgcban thank you! I changed the model to ChangeFormerV6, because the weights were ChangeFormerV6 weights, but now I want to run main_cd.py and I get this error.

'Traceback (most recent call last): File "main_cd.py", line 88, in test(args) File "main_cd.py", line 25, in test model.eval_models() File "/home/tatev/ChangeFormer/models/evaluator.py", line 174, in eval_models self._collect_running_batch_states() File "/home/tatev/ChangeFormer/models/evaluator.py", line 108, in _collect_running_batch_states running_acc = self._update_metric() File "/home/tatev/ChangeFormer/models/evaluator.py", line 103, in _update_metric current_score = self.running_metric.update_cm(pr=G_pred.cpu().numpy(), gt=target.cpu().numpy()) File "/home/tatev/ChangeFormer/misc/metric_tool.py", line 56, in update_cm val = get_confuse_matrix(num_classes=self.n_class, label_gts=gt, label_preds=pr) File "/home/tatev/ChangeFormer/misc/metric_tool.py", line 157, in get_confuse_matrix confusion_matrix += fast_hist(lt.flatten(), lp.flatten()) File "/home/tatev/ChangeFormer/misc/metric_tool.py", line 152, in fast_hist hist = np.bincount(num_classes * label_gt[mask].astype(int) + label_pred[mask], IndexError: boolean index did not match indexed array along dimension 0; dimension is 65536 but corresponding boolean dimension is 196608'