Loading docs/source/api_doc/utils/cache.rst 0 → 100644 +16 −0 Original line number Diff line number Diff line imgutils.utils.cache ==================================== .. currentmodule:: imgutils.utils.cache .. automodule:: imgutils.utils.cache ts_lru_cache ------------------------------ .. autofunction:: ts_lru_cache docs/source/api_doc/utils/index.rst +1 −0 Original line number Diff line number Diff line Loading @@ -9,5 +9,6 @@ imgutils.utils .. toctree:: :maxdepth: 3 cache func onnxruntime imgutils/detect/nudenet.py +3 −4 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ Overview: This module requires onnxruntime version 1.18 or higher. """ from functools import lru_cache from typing import Tuple, List import numpy as np Loading @@ -83,7 +82,7 @@ from hbutils.testing.requires.version import VersionInfo from huggingface_hub import hf_hub_download from imgutils.data import ImageTyping from imgutils.utils import open_onnx_model from imgutils.utils import open_onnx_model, ts_lru_cache from ..data import load_image Loading @@ -104,7 +103,7 @@ def _check_compatibility() -> bool: _REPO_ID = 'deepghs/nudenet_onnx' @lru_cache() @ts_lru_cache() def _open_nudenet_yolo(): """ Open and cache the NudeNet YOLO ONNX model. Loading @@ -118,7 +117,7 @@ def _open_nudenet_yolo(): )) @lru_cache() @ts_lru_cache() def _open_nudenet_nms(): """ Open and cache the NudeNet NMS ONNX model. Loading imgutils/detect/text.py +2 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ Overview: :align: center """ from functools import lru_cache from typing import List, Tuple, Optional import cv2 Loading @@ -33,12 +32,12 @@ from huggingface_hub import hf_hub_download from ..config.meta import __VERSION__ from ..data import ImageTyping, load_image from ..utils import open_onnx_model from ..utils import open_onnx_model, ts_lru_cache _DEFAULT_MODEL = 'dbnetpp_resnet50_fpnc_1200e_icdar2015' @lru_cache() @ts_lru_cache() def _open_text_detect_model(model: str): """ Get an ONNX session for the specified DBNET or DBNET++ model. Loading imgutils/edge/lineart.py +3 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ Overview: Having the **best effect**, closest to the drawing lines, but consuming a large amount of memory and computing power at runtime. """ from functools import lru_cache, partial from functools import partial from typing import Optional import numpy as np Loading @@ -14,7 +14,7 @@ from huggingface_hub import hf_hub_download from ._base import resize_image, cv2_resize, _get_image_edge from ..data import ImageTyping, load_image from ..utils import open_onnx_model from ..utils import open_onnx_model, ts_lru_cache def _preprocess(input_image: Image.Image, detect_resolution: int = 512): Loading @@ -23,7 +23,7 @@ def _preprocess(input_image: Image.Image, detect_resolution: int = 512): return (input_image / 255.0).transpose(2, 0, 1)[None, ...].astype(np.float32) @lru_cache() @ts_lru_cache() def _open_la_model(coarse: bool): return open_onnx_model(hf_hub_download( 'deepghs/imgutils-models', Loading Loading
docs/source/api_doc/utils/cache.rst 0 → 100644 +16 −0 Original line number Diff line number Diff line imgutils.utils.cache ==================================== .. currentmodule:: imgutils.utils.cache .. automodule:: imgutils.utils.cache ts_lru_cache ------------------------------ .. autofunction:: ts_lru_cache
docs/source/api_doc/utils/index.rst +1 −0 Original line number Diff line number Diff line Loading @@ -9,5 +9,6 @@ imgutils.utils .. toctree:: :maxdepth: 3 cache func onnxruntime
imgutils/detect/nudenet.py +3 −4 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ Overview: This module requires onnxruntime version 1.18 or higher. """ from functools import lru_cache from typing import Tuple, List import numpy as np Loading @@ -83,7 +82,7 @@ from hbutils.testing.requires.version import VersionInfo from huggingface_hub import hf_hub_download from imgutils.data import ImageTyping from imgutils.utils import open_onnx_model from imgutils.utils import open_onnx_model, ts_lru_cache from ..data import load_image Loading @@ -104,7 +103,7 @@ def _check_compatibility() -> bool: _REPO_ID = 'deepghs/nudenet_onnx' @lru_cache() @ts_lru_cache() def _open_nudenet_yolo(): """ Open and cache the NudeNet YOLO ONNX model. Loading @@ -118,7 +117,7 @@ def _open_nudenet_yolo(): )) @lru_cache() @ts_lru_cache() def _open_nudenet_nms(): """ Open and cache the NudeNet NMS ONNX model. Loading
imgutils/detect/text.py +2 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ Overview: :align: center """ from functools import lru_cache from typing import List, Tuple, Optional import cv2 Loading @@ -33,12 +32,12 @@ from huggingface_hub import hf_hub_download from ..config.meta import __VERSION__ from ..data import ImageTyping, load_image from ..utils import open_onnx_model from ..utils import open_onnx_model, ts_lru_cache _DEFAULT_MODEL = 'dbnetpp_resnet50_fpnc_1200e_icdar2015' @lru_cache() @ts_lru_cache() def _open_text_detect_model(model: str): """ Get an ONNX session for the specified DBNET or DBNET++ model. Loading
imgutils/edge/lineart.py +3 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ Overview: Having the **best effect**, closest to the drawing lines, but consuming a large amount of memory and computing power at runtime. """ from functools import lru_cache, partial from functools import partial from typing import Optional import numpy as np Loading @@ -14,7 +14,7 @@ from huggingface_hub import hf_hub_download from ._base import resize_image, cv2_resize, _get_image_edge from ..data import ImageTyping, load_image from ..utils import open_onnx_model from ..utils import open_onnx_model, ts_lru_cache def _preprocess(input_image: Image.Image, detect_resolution: int = 512): Loading @@ -23,7 +23,7 @@ def _preprocess(input_image: Image.Image, detect_resolution: int = 512): return (input_image / 255.0).transpose(2, 0, 1)[None, ...].astype(np.float32) @lru_cache() @ts_lru_cache() def _open_la_model(coarse: bool): return open_onnx_model(hf_hub_download( 'deepghs/imgutils-models', Loading