KeyError: 'pytorch-lightning_version'

Traceback (most recent call last):
File "C:\Users\abdul\smartparking\Project_smartparking\m.py", line 4, in
number_plate_detection_and_reading = pipeline("number_plate_detection_and_reading",
File "C:\Users\abdul\smartparking\Project_smartparking\nomeroff_net\pipelines_init_.py", line 115, in pipeline
return pipeline_class(task, image_loader, **pipeline_kwargs, **kwargs)
File "C:\Users\abdul\smartparking\Project_smartparking\nomeroff_net\pipelines\number_plate_detection_and_reading.py", line 52, in init
self.number_plate_text_reading = NumberPlateTextReading(
File "C:\Users\abdul\smartparking\Project_smartparking\nomeroff_net\pipelines\number_plate_text_reading.py", line 70, in init
self.detector = class_detector(presets, default_label, default_lines_count)
File "C:\Users\abdul\smartparking\Project_smartparking\nomeroff_net\pipes\number_plate_text_readers\text_detector.py", line 45, in init
self.load()
File "C:\Users\abdul\smartparking\Project_smartparking\nomeroff_net\pipes\number_plate_text_readers\text_detector.py", line 60, in load
detector.load(self.presets[detector_name]['model_path'])
File "C:\Users\abdul\smartparking\Project_smartparking\nomeroff_net\pipes\number_plate_text_readers\base\ocr.py", line 314, in load
return self.load_model(path_to_model, nn_class=nn_class)
File "C:\Users\abdul\smartparking\Project_smartparking\nomeroff_net\pipes\number_plate_text_readers\base\ocr.py", line 284, in load_model
self.model = nn_class.load_from_checkpoint(path_to_model,
File "C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\pytorch_lightning\core\saving.py", line 139, in load_from_checkpoint
return _load_from_checkpoint(
File "C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\pytorch_lightning\core\saving.py", line 163, in _load_from_checkpoint
checkpoint = _pl_migrate_checkpoint(
File "C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\pytorch_lightning\utilities\migration\utils.py", line 113, in _pl_migrate_checkpoint
old_version = _get_version(checkpoint)
File "C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\pytorch_lightning\utilities\migration\utils.py", line 136, in _get_version
return checkpoint["pytorch-lightning_version"]
KeyError: 'pytorch-lightning_version'
1 Like

Your Lightning version seems to expect a 'pytorch-lightning_version' key in the state_dict whcih is missing. I don’t know if this is caused by a version mismatch between the lightning release which was used to create the checkpoints vs. the one used to load it, but maybe adding this key to your state_dict with a fake version (e.g. 0.0.0) might fix it.