YijinHuang / SSiT

SSiT: Saliency-guided Self-supervised Image Transformer for Diabetic Retinopathy Grading
23 stars 4 forks source link

kNN-classification (knn.py) #7

Closed Wadha-Almattar closed 1 year ago

Wadha-Almattar commented 1 year ago

One of the solution to the following error is to downgrade the torchvision version, but when I do it I faced incompatibility with the available CUDA version in my machine. So, I keep the torchvision versions as it is 0.15.2. After a couple of reading, some refers to saving either the model + weights or weights only? I'm not certain about how the model is saved previously. the error poped up when the state_dict is retrieved from the checkpoint object.

Data loaded with 2562 train and 369 test imgs. Traceback (most recent call last): File "knn.py", line 220, in train_features, test_features, train_labels, test_labels = extract_feature_pipeline(args) File "knn.py", line 79, in extract_feature_pipeline load_checkpoint(model, args.checkpoint, checkpoint_key, linear_key) File "/home/guser1/SSiT/funcs.py", line 77, in load_checkpoint state_dict = checkpoint.state_dict() AttributeError: 'collections.OrderedDict' object has no attribute 'state_dict'

YijinHuang commented 1 year ago

Removing ".state_dict()" may work for this case.