YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/model-cards#model-card-metadata)
>>> import easyocr
>>> import torch
>>> from huggingface_hub import hf_hub_download
>>> # Initialize default easyocr model
>>> reader = easyocr.Reader(['en', 'cs', 'sk', 'pl'])
>>> # Download weights of recognition module.
>>> model_dir = hf_hub_download(repo_id="fimu-docproc-research/standard_0.4.0_EasyOcrEngine", filename="weights.pth")
>>> # Load the weights
>>> state_dict = torch.load(model_dir, map_location="cuda")
>>> # Load the state dictionary into the model
>>> reader.recognizer.load_state_dict(state_dict)
>>> # Typical usage of easyocr model to get predictions
>>> res = reader.readtext(input_img)
Example usage (without GPU):
>>> from collections import OrderedDict
>>> import easyocr
>>> import torch
>>> from huggingface_hub import hf_hub_download
>>> # Initialize default easyocr model
>>> reader = easyocr.Reader(['en', 'cs', 'sk', 'pl'], quantize=False, gpu=False)
>>> # Download weights of recognition module.
>>> model_dir = hf_hub_download(repo_id="fimu-docproc-research/standard_0.4.0_EasyOcrEngine", filename="weights.pth")
>>> # Load the weights
>>> state_dict = torch.load(model_dir, map_location="cpu")
>>> # There is need to remove first 7 characters due to easyocr library
>>> new_state_dict = OrderedDict()
>>> for key, value in state_dict.items():
>>> new_key = key[7:]
>>> new_state_dict[new_key] = value
>>> # Load the state dictionary into the model
>>> reader.recognizer.load_state_dict(new_state_dict)
>>> # Typical usage of easyocr model to get predictions
>>> res = reader.readtext(input_img)