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


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

Non-data size: 6

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: richzhang/colorization-pytorch
Commit Name: 9ba91fa13cbb1e7bc4069e46469b34abb5ca4869
Time: 2018-05-22
Author: tongzhou.wang.1994@gmail.com
File Name: models/base_model.py
Class Name: BaseModel
Method Name: load_networks