hezar.models.text_detection.craft.craft_text_detection module

class hezar.models.text_detection.craft.craft_text_detection.CraftTextDetection(config: CraftTextDetectionConfig, **kwargs)[source]

Bases: Model

CRAFT for text detection. Copied from the original implementation at https://github.com/clovaai/CRAFT-pytorch

basenet

U network

forward(pixel_values, ratio_values=None)[source]

Base network

post_process(model_outputs: dict, text_threshold: float | None = None, link_threshold: float | None = None, low_text: float | None = None, poly: bool = False)[source]

Process model outputs and return human-readable results. Called in self.predict()

Parameters:
  • model_outputs – model outputs to process

  • **kwargs – extra arguments specific to the derived class

Returns:

Processed model output values and converted to human-readable results

preprocess(inputs, **kwargs)[source]

Given raw inputs, preprocess the inputs and prepare them for model’s forward().

Parameters:
  • raw_inputs – Raw model inputs

  • **kwargs – Extra kwargs specific to the model. See the model’s specific class for more info

Returns:

A dict of inputs for model forward

required_backends: List[Backends | str] = [Backends.OPENCV, Backends.PILLOW, Backends.TORCHVISION]
class hezar.models.text_detection.craft.craft_text_detection.DoubleConv(in_ch, mid_ch, out_ch)[source]

Bases: Module

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class hezar.models.text_detection.craft.craft_text_detection.VGG16BN[source]

Bases: Module

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

hezar.models.text_detection.craft.craft_text_detection.init_weights(modules)[source]