ria-com/nomeroff-net

KeyError: 'pytorch-lightning_version'

abdalkaderhajjouz opened this issue · 3 comments

C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\torchvision\models_utils.py:252: UserWarning: Accessing the model URLs via the internal dictionary of the module is deprecated since 0.13 and may be removed in the future. Please access them via the appropriate Weights Enum instead.
warnings.warn(
C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\torchvision\models_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
warnings.warn(
C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\torchvision\models_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=None.
warnings.warn(msg)
Lightning automatically upgraded your loaded checkpoint from v1.5.10 to v1.9.4. To apply the upgrade to your files permanently, run python -m pytorch_lightning.utilities.upgrade_checkpoint --file C:\Users\abdul\smartparking\Project_smartparking\data\models\OptionsDetector\numberplate_options\numberplate_options_2023_02_22_pytorch_lightning.ckpt
C:\Users\abdul\smartparking\Project_smartparking\project_yolo_craft_resnet\lib\site-packages\torchvision\models_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=ResNet18_Weights.IMAGENET1K_V1. You can also use weights=ResNet18_Weights.DEFAULT to get the most up-to-date weights.
warnings.warn(msg)
Lightning automatically upgraded your loaded checkpoint from v1.5.10 to v1.9.4. To apply the upgrade to your files permanently, run python -m pytorch_lightning.utilities.upgrade_checkpoint --file C:\Users\abdul\smartparking\Project_smartparking\data\models\TextDetector\eu_ua_2004_2015\anpr_ocr_eu_2004_2015_2023_01_23_resnet18.ckpt
Lightning automatically upgraded your loaded checkpoint from v1.5.10 to v1.9.4. To apply the upgrade to your files permanently, run python -m pytorch_lightning.utilities.upgrade_checkpoint --file C:\Users\abdul\smartparking\Project_smartparking\data\models\TextDetector\eu_ua_1995\anpr_ocr_eu_ua_1995_2023_01_26_resnet18.ckpt
Lightning automatically upgraded your loaded checkpoint from v1.5.10 to v1.9.4. To apply the upgrade to your files permanently, run python -m pytorch_lightning.utilities.upgrade_checkpoint --file C:\Users\abdul\smartparking\Project_smartparking\data\models\TextDetector\eu\anpr_ocr_eu_2023_01_30_resnet18.ckpt
Lightning automatically upgraded your loaded checkpoint from v1.5.10 to v1.9.4. To apply the upgrade to your files permanently, run python -m pytorch_lightning.utilities.upgrade_checkpoint --file C:\Users\abdul\smartparking\Project_smartparking\data\models\TextDetector\ru\anpr_ocr_ru_2023_02_01_resnet18.ckpt
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'

Process finished with exit code 1

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.

I want to ask you another question

CER (Character Error Rate) and WER (Word Error Rate) for OCR in russian car plate ,What are their values

CER WER on test set:

model CER WER
ru 0.000502 0.003866

Code to reproduce
https://github.com/ria-com/nomeroff-net/blob/master/examples/ju/train/ocr/evaluate-metrics.ipynb