3a4a56e15dc30e5f7d9c4c7706f5710d1da73e52,run_placesCNN_unified.py,,load_model,#,86

Before Change


        os.system("wget http://places2.csail.mit.edu/models_places365/" + model_file)
        os.system("wget https://raw.githubusercontent.com/csailvision/places365/master/wideresnet.py")
    useGPU = 0
    if useGPU == 1:
        model = torch.load(model_file)
    else:
        model = torch.load(model_file, map_location=lambda storage, loc: storage) // allow cpu

    // the following is deprecated, everything is migrated to python36

    //// if you encounter the UnicodeDecodeError when use python3 to load the model, add the following line will fix it. Thanks to @soravux
    //from functools import partial
    //import pickle
    //pickle.load = partial(pickle.load, encoding="latin1")
    //pickle.Unpickler = partial(pickle.Unpickler, encoding="latin1")
    //model = torch.load(model_file, map_location=lambda storage, loc: storage, pickle_module=pickle)

    model.eval()
    // hook the feature extractor
    features_names = ["layer4","avgpool"] // this is the last conv layer of the resnet
    for name in features_names:

After Change


    import wideresnet
    model = wideresnet.resnet18(num_classes=365)
    checkpoint = torch.load(model_file, map_location=lambda storage, loc: storage)
    state_dict = {str.replace(k,"module.",""): v for k,v in checkpoint["state_dict"].items()}
    model.load_state_dict(state_dict)
    model.eval()

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: CSAILVision/places365
Commit Name: 3a4a56e15dc30e5f7d9c4c7706f5710d1da73e52
Time: 2018-05-02
Author: zhoubolei@gmail.com
File Name: run_placesCNN_unified.py
Class Name:
Method Name: load_model


Project Name: snipsco/snips-nlu
Commit Name: ab1b67c1e958c9a642f57095f3499a893ba0a5b2
Time: 2017-03-24
Author: adrien.ball@snips.net
File Name: snips_nlu/nlu_engine/nlu_engine.py
Class Name: SnipsNLUEngine
Method Name: load


Project Name: CSAILVision/places365
Commit Name: 3a4a56e15dc30e5f7d9c4c7706f5710d1da73e52
Time: 2018-05-02
Author: zhoubolei@gmail.com
File Name: run_placesCNN_basic.py
Class Name:
Method Name: