Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

预训练模型加载出现问题 #29

Open
jpyjpr opened this issue Feb 5, 2024 · 1 comment
Open

预训练模型加载出现问题 #29

jpyjpr opened this issue Feb 5, 2024 · 1 comment

Comments

@jpyjpr
Copy link

jpyjpr commented Feb 5, 2024

你好,我下载了reademe 中提供的预训练模型(sphereface2_vggface2_sfnet20、SphereFacePlus_ms1m_sfnet64bn),放到代码中执行main_inference.py ,其中parse_args的设置如下

def parse_args():
    parser = argparse.ArgumentParser(
            description='A PyTorch project for face recognition.')
    parser.add_argument('--image_dir', default='./face_alignment/test_images/',
            help='path to the image directory')
    parser.add_argument('--proj_dir', default='/workspace/SphereFacePlus_ms1m_sfnet64bn/20220429_154144',
            help='the directory to load model')
    args = parser.parse_args()

但是我试了两个模型都报相同的错误,错误信息如下:

(opensphere) root@8ecda7dba6bf:/workspace# python main_inference.py 
Traceback (most recent call last):
  File "main_inference.py", line 32, in <module>
    model = Model(config['model'])
  File "/workspace/opensphere/model.py", line 25, in __init__
    self.backbone = self.build_module(args['backbone']).to(self.rank)
  File "/workspace/opensphere/model.py", line 33, in build_module
    return build_from_args(args, 'opensphere.module')
  File "/workspace/opensphere/utils/build_helper.py", line 15, in build_from_args
    raise KeyError('Missing key "type" in `args`', args)
KeyError: ('Missing key "type" in `args`', {'net': {'type': 'sfnet64', 'in_channel': 3, 'channels': [64, 128, 256, 512], 'out_channel': 512}, 'optimizer': {'type': 'SGD', 'lr': 0.1, 'momentum': 0.9, 'weight_decay': 0.0005}, 'scheduler': {'type': 'MultiStepLR', 'milestones': [150000, 270000, 320000, 360000], 'gamma': 0.1}, 'clip_grad_norm': 100000.0})

是哪里出现了问题呢?我发现是build_from_args函数在检查arg时 和 提供的预训练模型中的config.yaml不一致。我按照错误进行了一些修正,但是后续还是会报其他的关于net的错误,我不知道是哪里出现了问题

另外,我想知道符合最新提交代码的config.yaml是怎么样子的?和readme中提供的预训练模型中的config.yaml是否存在不一致现象?非常感谢!!!

@ydwen
Copy link
Owner

ydwen commented Mar 21, 2024

你好,readme中提供的确实是之前版本的,可能存在不一致。最新版本的config.yaml可以参考https://github.com/ydwen/opensphere/blob/main/config/train/ms1m_iresnet100_simple.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants