NVlabs / few_shot_gaze

Pytorch implementation and demo of FAZE: Few-Shot Adaptive Gaze Estimation (ICCV 2019, oral)
https://research.nvidia.com/publication/2019-10_Few-Shot-Adaptive-Gaze
Other
325 stars 76 forks source link

Missing key(s) in state_dict: "encoder.initial.conv1.weight" #19

Open rogeriochaves opened 3 years ago

rogeriochaves commented 3 years ago

I'm trying to run the demo on an ubuntu (no GPU), but I'm getting this:

(venv) rchaves@rchaves-VirtualBox:~/Desktop/few_shot_gaze/demo$ python run_demo.py 
/bin/sh: 1: v4l2-ctl: not found
/bin/sh: 1: v4l2-ctl: not found
/bin/sh: 1: v4l2-ctl: not found
> Loading: demo_weights/weights_ted.pth.tar
> Loading: demo_weights/weights_maml/09.pth.tar
Traceback (most recent call last):
  File "run_demo.py", line 98, in <module>
    gaze_network.load_state_dict(ted_weights)
  File "/home/rchaves/Desktop/few_shot_gaze/demo/venv/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for DTED:
    Missing key(s) in state_dict: "encoder.initial.conv1.weight", "encoder.initial.conv2.weight", "encoder.block1.compo1.conv.weight", "encoder.block1.compo2.conv.weight", "encoder.block1.compo3.conv.weight", "encoder.block1.compo4.conv.weight", "encoder.trans1.composite.conv.weight", "encoder.block2.compo1.conv.weight", "encoder.block2.compo2.conv.weight", "encoder.block2.compo3.conv.weight", "encoder.block2.compo4.conv.weight", "encoder.trans2.composite.conv.weight", "encoder.block3.compo1.conv.weight", "encoder.block3.compo2.conv.weight", "encoder.block3.compo3.conv.weight", "encoder.block3.compo4.conv.weight", "encoder.trans3.composite.conv.weight", "encoder.block4.compo1.conv.weight", "encoder.block4.compo2.conv.weight", "encoder.block4.compo3.conv.weight", "encoder.block4.compo4.conv.weight", "decoder.block1.compo1.conv.weight", "decoder.block1.compo2.conv.weight", "decoder.block1.compo3.conv.weight", "decoder.block1.compo4.conv.weight", "decoder.trans1.conv.weight", "decoder.block2.compo1.conv.weight", "decoder.block2.compo2.conv.weight", "decoder.block2.compo3.conv.weight", "decoder.block2.compo4.conv.weight", "decoder.trans2.conv.weight", "decoder.block3.compo1.conv.weight", "decoder.block3.compo2.conv.weight", "decoder.block3.compo3.conv.weight", "decoder.block3.compo4.conv.weight", "decoder.trans3.conv.weight", "decoder.block4.compo1.conv.weight", "decoder.block4.compo2.conv.weight", "decoder.block4.compo3.conv.weight", "decoder.block4.compo4.conv.weight", "decoder.last.conv1.weight", "decoder.last.conv2.weight", "decoder.last.conv3.weight", "fc_enc.weight", "fc_enc.bias", "fc_dec.weight", "fc_dec.bias". 
    Unexpected key(s) in state_dict: "module.encoder.initial.conv1.weight", "module.encoder.initial.conv2.weight", "module.encoder.block1.compo1.conv.weight", "module.encoder.block1.compo2.conv.weight", "module.encoder.block1.compo3.conv.weight", "module.encoder.block1.compo4.conv.weight", "module.encoder.trans1.composite.conv.weight", "module.encoder.block2.compo1.conv.weight", "module.encoder.block2.compo2.conv.weight", "module.encoder.block2.compo3.conv.weight", "module.encoder.block2.compo4.conv.weight", "module.encoder.trans2.composite.conv.weight", "module.encoder.block3.compo1.conv.weight", "module.encoder.block3.compo2.conv.weight", "module.encoder.block3.compo3.conv.weight", "module.encoder.block3.compo4.conv.weight", "module.encoder.trans3.composite.conv.weight", "module.encoder.block4.compo1.conv.weight", "module.encoder.block4.compo2.conv.weight", "module.encoder.block4.compo3.conv.weight", "module.encoder.block4.compo4.conv.weight", "module.decoder.block1.compo1.conv.weight", "module.decoder.block1.compo2.conv.weight", "module.decoder.block1.compo3.conv.weight", "module.decoder.block1.compo4.conv.weight", "module.decoder.trans1.conv.weight", "module.decoder.block2.compo1.conv.weight", "module.decoder.block2.compo2.conv.weight", "module.decoder.block2.compo3.conv.weight", "module.decoder.block2.compo4.conv.weight", "module.decoder.trans2.conv.weight", "module.decoder.block3.compo1.conv.weight", "module.decoder.block3.compo2.conv.weight", "module.decoder.block3.compo3.conv.weight", "module.decoder.block3.compo4.conv.weight", "module.decoder.trans3.conv.weight", "module.decoder.block4.compo1.conv.weight", "module.decoder.block4.compo2.conv.weight", "module.decoder.block4.compo3.conv.weight", "module.decoder.block4.compo4.conv.weight", "module.decoder.last.conv1.weight", "module.decoder.last.conv2.weight", "module.decoder.last.conv3.weight", "module.fc_enc.weight", "module.fc_enc.bias", "module.fc_dec.weight", "module.fc_dec.bias", "module.gaze1.weight", "module.gaze1.bias", "module.gaze2.weight", "module.gaze2.bias". 

what am I doing wrong? Maybe because I don't have CUDA?

rogeriochaves commented 3 years ago

nervmind, I just commented line 81 in run_demo.py:

if torch.cuda.device_count() == 1:

now this error is gone, but still I cannot run it without GPU, even if I try to work around all the error messages, it freezes when opening the webcam

rogeriochaves commented 3 years ago

It worked eventually!

BTW I could make it fully work on Mac OSX too https://github.com/rogeriochaves/few_shot_gaze/commit/bcb8fa7dc4fc3ab7d65a6cfe8e815ed3290546cd

swook commented 3 years ago

Sorry about the late response! It is indeed tricky to get things working in a different environment...

The module. error you encountered occurs due to the original model being trained with torch.DataParallel and a simple renaming of keys should resolve it.

Thank you for sharing the exact steps you took to address this issue. I hope others in the future will find this information helpful.

anthonyyacovone commented 3 years ago

Hi all,

Did anyone ever get FAZE to work fully on Mac OSX (not ubuntu)? If so, would you be willing to share the scripts? Thanks so much!

@rogeriochaves @swook

It worked eventually!

BTW I could make it fully work on Mac OSX too rogeriochaves@bcb8fa7