Detectron: AssertionError:

Created on 26 Jul 2018  ·  3Comments  ·  Source: facebookresearch/Detectron

Expected results

Running

Actual results

Workspace blob cls_score_w with shape (21, 2048) does not match weights file shape (81, 2048)

Detailed steps to reproduce

E.g.:

 python tools/train_net.py --cfg /root/Detectron/tmp/e2e_faster_rcnn_R-50-C4_1x.yaml OUTPUT_DIR tmp/det

System information

  • Operating system: Ubuntu
  • Compiler version: caffe2
  • CUDA version: 9
  • cuDNN version: 7
  • NVIDIA driver version: Titanx
  • GPU models (for all devices if they are not all the same): ?
  • PYTHONPATH environment variable: /root/anaconda
  • python --version output: 2.7
  • Anything else that seems relevant: ?

Most helpful comment

You've probably set the NUM_CLASSES: 21 in your config file, whereas you weights file has 81 classes. One way to get around that is to just load it and delete the conflicting blobs.

import cPickle as pkl 

with open('model.pkl', 'rb') as f:
    wts = pkl.load(f)

for blob in wts['blobs'].keys():
    if blob.startswith('cls_score_') or blob.startswith('bbox_pred_'):
        del wts['blobs'][blob]

with open('new_model.pkl', 'wb') as f:
    pkl.dump(wts, f)

Hope this helps.

All 3 comments

You've probably set the NUM_CLASSES: 21 in your config file, whereas you weights file has 81 classes. One way to get around that is to just load it and delete the conflicting blobs.

import cPickle as pkl 

with open('model.pkl', 'rb') as f:
    wts = pkl.load(f)

for blob in wts['blobs'].keys():
    if blob.startswith('cls_score_') or blob.startswith('bbox_pred_'):
        del wts['blobs'][blob]

with open('new_model.pkl', 'wb') as f:
    pkl.dump(wts, f)

Hope this helps.

thx have done it

You've probably set the NUM_CLASSES: 21 in your config file, whereas you weights file has 81 classes. One way to get around that is to just load it and delete the conflicting blobs.

import cPickle as pkl 

with open('model.pkl', 'rb') as f:
    wts = pkl.load(f)

for blob in wts['blobs'].keys():
    if blob.startswith('cls_score_') or blob.startswith('bbox_pred_'):
        del wts['blobs'][blob]

with open('new_model.pkl', 'wb') as f:
    pkl.dump(wts, f)

Hope this helps.

In which file do I need to add this details

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kampelmuehler picture kampelmuehler  ·  4Comments

gaopeng-eugene picture gaopeng-eugene  ·  4Comments

kampelmuehler picture kampelmuehler  ·  4Comments

olgaliak picture olgaliak  ·  4Comments

kleingeo picture kleingeo  ·  3Comments