question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Caffe2_checkpoint is integer when loading pre-train models

See original GitHub issue

Hello. I’m testing different pre-train networks you offer on MODEL_ZOO.md. When I’m loading different model using pickle (as they are in caffe2), it returns an integer; this later results in an error as an integer doesn’t have key-values.

My environment corresponds to a docker container, generated from pytorch/pytorch:1.7.0-cuda11.0-cudnn8-runtime image available in Docker Hub, running Ubuntu 18.04.5 LTS and with the needed dependencies stated in the INSTALL.md. Important dependencies version to mention:

  • pickle == 4.0
  • python == 3.8.3
  • torch == 1.7.0

My hardware is:

  • Nvidia GeForce GTX 1050Ti
  • Intel i7-7700HQ CPU @ 2.80GHz

This happens specifically in the lines 213-215 from the slowfast/utils/checkpoint.py, in the load_checkpoint function.

213    if convert_from_caffe2:
214        with g_pathmgr.open(path_to_checkpoint, "rb") as f:
215            caffe2_checkpoint = pickle.load(f, encoding="latin1")

caffe2_checkpoint is an int, so when it tries access the keys from the dictionary, it fails (line 218):

218        for key in caffe2_checkpoint["blobs"].keys():

The caffe2_checkpoint is an integer for some model. Among the tested models with this behavior, are:

  • SLOWFAST_64x2_R101_50_50.pkl (AVA)
  • SLOWFAST_32x2_R101_50_50.pkl (AVA)
  • SLOWFAST_8x8_R50_stepwise_multigrid.pkl (Kinetics)
  • SLOWFAST_8x8_R50_stepwise.pkl (Kinetics)

Other tested model that return the correct object (dictionary), are:

  • SLOWFAST_8x8_R50.pkl (Kinetics)
  • SLOWFAST_4x16_R50.pkl (Kinetics)
  • SLOWFAST_32x2_R101_50_50_v2.1.pkl (AVA)

The command I’m using is:

python3 slowfast/tools/run_net.py \
--cfg \ 
slowfast/configs/AVA/c2/SLOWFAST_64x2_R101_50_50.yaml \
TEST.DATASET ava \
DATA.PATH_TO_DATA_DIR PATH_TO_DATA_DIR \
AVA.ANNOTATION_DIR annotations \
AVA.LABEL_MAP_FILE ava_action_list_v2.2.pbtxt \
AVA.GROUNDTRUTH_FILE ava_val_v2.2.csv \
AVA.EXCLUSION_FILE ava_val_excluded_timestamps_v2.2.csv \
AVA.TEST_PREDICT_BOX_LISTS [' "ava_val_predicted_boxes.csv" ']
AVA.FRAME_DIR frames \
AVA.FRAME_LIST_DIR frame_lists \
AVA.TEST_LISTS [' "val.csv" '] \
TEST.CHECKPOINT_FILE_PATH path/to/SLOWFAST_64x2_R101_50_50.pkl \
TEST.CHECKPOINT_TYPE caffe2
TRAIN.ENABLE False \
TEST.ENABLE True \
DATA.NUM_FRAMES 16 \
NUM_GPUS 1

I would like to confirm if the problem is only on my end or the .pkl files have the problem.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

4reactions
huang-chenhaicommented, Nov 19, 2021

I encountered the same problem as you, and it has been solved. The reason is that the Pretrained Model should be downloaded instead of downloading the model.Their names are the same.

1reaction
exnxcommented, Apr 9, 2021

I had the same problems, see this post:

https://github.com/facebookresearch/SlowFast/issues/85

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading Pre-Trained Models - Caffe2
You'll find that loading pre-trained model is really simple and is accomplished in just a few lines of code. Here we show those...
Read more >
detectron2/checkpoint/clip_model_loading.py · CVPR/regionclip ...
regionclip-demo / detectron2 /checkpoint /clip_model_loading.py ... It only deals with typical backbone models. ... load pretrained oai clip.
Read more >
How to load checkpoints across different versions of pytorch ...
if type(v) == list or type(v) == int: v = torch.tensor(v) own_state[k].copy_(v) model.load_state_dict(own_state) print('Model loaded').
Read more >
Source code for mmaction.models.backbones.resnet
[docs]@BACKBONES.register_module() class ResNet(nn.Module): """ResNet backbone. Args: depth (int): Depth of resnet, from {18, 34, 50, 101, 152}. pretrained ...
Read more >
ImageNet Pretrained Network (ResNet-152)-checkpoint
We will create a set of Lasagne layers corresponding to the Caffe model specification (prototxt), ... We need caffe to load weights and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found