we0091234 / Car_recognition

yolov5 车辆检测 车牌检测 车牌识别
244 stars 43 forks source link

running on a CPU-only machine #3

Open Mushero opened 1 year ago

Mushero commented 1 year ago

When I running on a CPU-only machine, error for that

"RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU."

Mushero commented 1 year ago

change the function def init_car_rec_model(model_path, device): in car_recognition/car_rec.py to

def init_car_rec_model(model_path, device):
    check_point = torch.load(model_path, map_location=device)
    cfg = check_point['cfg']
    model = myNet(num_classes=11, cfg=cfg)
    model.load_state_dict(check_point['state_dict'])
    model.to(device)
    model.eval()
    return model

Successfully resolved🎆