paplhjak / Facial-Age-Estimation-Benchmark

Comparative Analysis of Deep Learning Approaches for Facial Age Estimation. Accepted to CVPR 2024
38 stars 2 forks source link

load pre-trained weights #15

Closed YYmmx21 closed 8 months ago

YYmmx21 commented 8 months ago

Hello, how to load 'resnet50-imdb-em-cnn.pt' into the model?

paplhjak commented 8 months ago

Hello, The model you are referencing is a JIT scripted backbone. To load it, use the following in your configuration file:

model:
  architecture: "jit"
  path: "resnet50-imdb-em-cnn.pt"
  nr_features: 2048
  backbone_trainable: True
  input_size: [256, 256]

For more information, please see doc/backbone_support.md.

YYmmx21 commented 8 months ago

Hello, I got this error when I loaded the weights, can you help me fix it? 微信图片_20240305214041

paplhjak commented 8 months ago

It is hard to say from this error alone. Have you made any modifications to the codebase? Are you using our benchmark? -> If so, we only define 5 cross-validation splits, so specifying 6 on the command line as in your screenshot would be incorrect. Are you able to run the code without the JIT model? Does the error only manifest once you use the JIT backbone?

YYmmx21 commented 8 months ago

Hello.

  1. I have made some modifications to the code, for example, I add a class head for gender
  2. For 6 cross-validation splits, which is my dataset
  3. There was an error when only use the code"torch.load('resnet50-imdb-em-cnn.pt')"
paplhjak commented 8 months ago

To use the JIT backbone, you do not need to modify the training code, e.g., by adding torch.load(...). You should modify the experiment configuration file as shown above. The JIT backbone is then loaded as torch.jit.load(...). For more information, please see the initialize_model function in lib/model.py.