Skip to content

Commit cd03646

Browse files
rebase and add requires
1 parent 7258481 commit cd03646

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

.github/workflows/public_docker_images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
matrix:
2424
# Must match version at https://www.python.org/ftp/python/
2525
python: ["3.9.18", "3.10.13", "3.11.8"]
26-
framework: ["tf", "torch", "tf,viz,html", "torch,viz,html"]
26+
framework: ["tf", "torch", "tf,viz,html,contrib", "torch,viz,html,contrib"]
2727
system: ["cpu", "gpu"]
2828

2929
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.

docs/source/getting_started/installing.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ We strive towards reducing framework-specific dependencies to a minimum, but som
3838
.. code:: bash
3939
4040
pip install "python-doctr[tf]"
41-
# or with preinstalled packages for visualization & html support
42-
pip install "python-doctr[tf,viz,html]"
41+
# or with preinstalled packages for visualization & html & contrib module support
42+
pip install "python-doctr[tf,viz,html,contib]"
4343
4444
.. tab:: PyTorch
4545

4646
.. code:: bash
4747
4848
pip install "python-doctr[torch]"
49-
# or with preinstalled packages for visualization & html support
50-
pip install "python-doctr[torch,viz,html]"
49+
# or with preinstalled packages for visualization & html & contrib module support
50+
pip install "python-doctr[torch,viz,html,contrib]"
5151
5252
5353

docs/source/using_doctr/using_contrib_modules.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Available contribution modules
1414

1515
.. code:: bash
1616
17-
pip install onnxruntime
17+
pip install python-doctr[contrib]
18+
# Or
19+
pip install onnxruntime # pip install onnxruntime-gpu
1820
1921
Here are all contribution modules that are available through docTR:
2022

doctr/contrib/artefacts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import cv2
99
import numpy as np
1010

11+
from doctr.file_utils import requires_package
12+
1113
from .base import _BasePredictor
1214

1315
__all__ = ["ArtefactDetector"]
@@ -110,7 +112,7 @@ def show(self, **kwargs: Any) -> None:
110112
----
111113
**kwargs: additional keyword arguments to be passed to `plt.show`
112114
"""
113-
# TODO: requires check for matplotlib
115+
requires_package("matplotlib", "`.show()` requires matplotlib installed")
114116
import matplotlib.pyplot as plt
115117
from matplotlib.patches import Rectangle
116118

doctr/contrib/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import numpy as np
99

10+
from doctr.file_utils import requires_package
1011
from doctr.utils.data import download_from_url
1112

1213

@@ -41,10 +42,9 @@ def _init_model(self, url: Optional[str] = None, model_path: Optional[str] = Non
4142
4243
Returns:
4344
-------
44-
str: the path to the model
45+
Any: the ONNX loaded model
4546
"""
46-
# TODO: requires check
47-
47+
requires_package("onnxruntime", "`.contrib` module requires `onnxruntime` to be installed.")
4848
import onnxruntime as ort
4949

5050
if not url and not model_path:

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ viz = [
6969
"matplotlib>=3.1.0",
7070
"mplcursors>=0.3",
7171
]
72+
contrib = [
73+
"onnxruntime>=1.11.0",
74+
]
7275
testing = [
7376
"pytest>=5.3.2",
7477
"coverage[toml]>=4.5.4",

0 commit comments

Comments
 (0)