EasyOCR#

About this page

This is an API reference for EasyOCR in BentoML. Please refer to EasyOCR guide for more information about how to use EasyOCR in BentoML.

bentoml.easyocr.save_model(name: Tag | str, reader: easyocr.Reader, *, signatures: ModelSignaturesType | None = None, labels: dict[str, str] | None = None, custom_objects: dict[str, t.Any] | None = None, external_modules: t.List[ModuleType] | None = None, metadata: dict[str, t.Any] | None = None) bentoml.Model[source]#

Save a model instance to BentoML modelstore.

Parameters:
  • name – Name for given model instance. This should pass Python identifier check.

  • reader – The EasyOCR model to be saved. Currently only supports pre-trained models from easyocr. Custom models are not yet supported.

  • signatures – Methods to expose for running inference on the target model. Signatures are used for creating Runner instances when serving model with Service

  • labels – User-defined labels for managing models, e.g. team=nlp, stage=dev.

  • custom_objects – Custom objects to be saved with the model. An example is {"my-normalizer": normalizer}. Custom objects are currently serialized with cloudpickle, but this implementation is subject to change.

  • external_modules – user-defined additional python modules to be saved alongside the model or custom objects, e.g. a tokenizer module, preprocessor module, model configuration module

  • metadata – Custom metadata for given model.

Returns:

A tag with a format name:version where name is the user-defined model’s name, and a generated version.

Return type:

Tag

Examples:

import bentoml
import easyocr

reader = easyocr.Reader(['en'])
bento_model = bentoml.easyocr.save_model('en_reader', reader)
bentoml.easyocr.load_model(bento_model: str | Tag | Model) easyocr.Reader[source]#

Load the EasyOCR model from BentoML local model store with given name.

Parameters:

bento_model – Either the tag of the model to get from the store, or a BentoML Model instance to load the model from.

Returns:

The EasyOCR model from the model store.

Return type:

easyocr.Reader

Example:

import bentoml
reader = bentoml.easyocr.load_model('en_reader:latest')
bentoml.easyocr.get(tag_like: str | Tag) Model[source]#

Get the BentoML model with the given tag.

Parameters:

tag_like – The tag of the model to retrieve from the model store.

Returns:

A BentoML Model with the matching tag.

Return type:

Model

Example:

import bentoml
# target model must be from the BentoML model store
model = bentoml.easyocr.get("en_reader:latest")