import torch


def load_pretrained(model, init_path):
    """ Loads a pretrained crowd counting network. """

    resume_state = torch.load(init_path, map_location=torch.device('cpu'))
    model.load_state_dict(resume_state['state_dict'])

    return model