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: 5

Non-data size: 4

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: CSAILVision/places365
Commit Name: 3a4a56e15dc30e5f7d9c4c7706f5710d1da73e52
Time: 2018-05-02
Author: zhoubolei@gmail.com
File Name: run_placesCNN_basic.py
Class Name:
Method Name:


Project Name: pytorch/examples
Commit Name: 4af62f988aef58b076904ab0e8dffef1ea6b4840
Time: 2017-03-14
Author: bryan.mccann.is@gmail.com
File Name: OpenNMT/train.py
Class Name:
Method Name: main


Project Name: lcswillems/torch-rl
Commit Name: 3f196bcdd1e0310208e8978cf4f1fb590614568b
Time: 2018-04-15
Author: lcswillems@gmail.com
File Name: utils.py
Class Name:
Method Name: load_model


Project Name: astroML/astroML
Commit Name: a1292078d2016dff4228fff869430ab4ace79b6b
Time: 2019-01-04
Author: bsipocz@gmail.com
File Name: astroML/datasets/sdss_corrected_spectra.py
Class Name:
Method Name: fetch_sdss_corrected_spectra