mobulan / IELT

Source code of the paper Fine-Grained Visual Classification via Internal Ensemble Learning Transformer
MIT License
41 stars 5 forks source link

string indices must be integers #1

Closed ChengFengGu closed 1 year ago

ChengFengGu commented 1 year ago

Thans for your excellent work! But when using pet dataset training model, got error string indices must be integers.

Traceback (most recent call last):
  File "main.py", line 409, in <module>
    main(config)
  File "main.py", line 66, in main
    model, model_without_ddp = build_model(config, num_classes)
  File "main.py", line 16, in build_model
    model = build_models(config, num_classes)
  File "/home/guojiao/codes/disease_or_excellent_v2/methods/IELT/models/build.py", line 32, in build_models
    model.load_from(config.model.pretrained)
  File "/home/guojiao/codes/disease_or_excellent_v2/methods/IELT/models/IELT.py", line 93, in load_from
    np2th(weights["embedding/kernel"], conv=True)
TypeError: string indices must be integers

And the pretrained npz file has already been downloaded, renamed and moved to pretrained dir.

mobulan commented 1 year ago

I forget the model parameters should be loaded by numpy. You should change the models/build.py Line 32 to model.load_from(np.load(config.model.pretrained)) and add the numpy. In addition, the models/IELT.py Line 92 should delete the if branch and use the 'token' branch. I have updated the code, thanks you for your mention.