Keras-retinanet: ReTrain resnet50_coco_best on another dataset

Created on 16 Jan 2018  路  4Comments  路  Source: fizyr/keras-retinanet

Hi,
Is there anyway to train the model with resnet50_coco_best weights initialization, but with different class numbers and names? in other words how can I load the weights except top of the model?

Most helpful comment

Yes you can, but only using Keras 2.1.3 (at the time of writing, 2.1.3 is released 4 hours ago and I have not yet tested it with keras-retinanet).

If you add the flag skip_mismatch=True to load_model it should print warnings when layers cannot be copied, rather than throwing an error.

All 4 comments

Yes you can, but only using Keras 2.1.3 (at the time of writing, 2.1.3 is released 4 hours ago and I have not yet tested it with keras-retinanet).

If you add the flag skip_mismatch=True to load_model it should print warnings when layers cannot be copied, rather than throwing an error.

can you point out exactly where to put this skip_mismatch flag? I couldn't find flag like that in keras documents,

thanks

In models/resnet.py you can find a line which consists model.loadweights, you should just add this flag there.
Model.loadweights(..., skip_mismatch=True)

For future reference, the skip_mismatch flag got added in https://github.com/keras-team/keras/pull/8462 on this line.

Which can be added here.

In addition, PR https://github.com/fizyr/keras-retinanet/pull/232 changes the default behaviour of keras-retinanet weight loading such that it should skip mismatching layers (and therefore allow something like COCO weights to be loaded for PascalVOC training).

Was this page helpful?
0 / 5 - 0 ratings