doctr.contrib#

Complementary modules for document analysis pipelines, running on ONNX Runtime (pip install "python-doctr[contrib]"). See Artefact detection.

class ArtefactDetector(
arch='yolov8_artefact',
batch_size=2,
model_path=None,
labels=None,
input_shape=None,
conf_threshold=0.5,
iou_threshold=0.5,
**kwargs,
)[source]#

A class to detect artefacts in images

>>> from doctr.io import DocumentFile
>>> from doctr.contrib.artefacts import ArtefactDetector
>>> doc = DocumentFile.from_images(["path/to/image.jpg"])
>>> detector = ArtefactDetector()
>>> results = detector(doc)
Parameters:
  • arch (str) – the architecture to use

  • batch_size (int) – the batch size to use

  • model_path (str | None) – the path to the model to use

  • labels (list[str] | None) – the labels to use

  • input_shape (tuple[int, int, int] | None) – the input shape to use

  • mask_labels – the mask labels to use

  • conf_threshold (float) – the confidence threshold to use

  • iou_threshold (float) – the intersection over union threshold to use

  • **kwargs (Any) – additional arguments to be passed to download_from_url

show(**kwargs)[source]#

Display the results

Parameters:

**kwargs (Any) – additional keyword arguments to be passed to plt.show