Commit 6517b92e authored by narugo1992's avatar narugo1992
Browse files

dev(narugo): add docs

parent 6c88aa3a
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
from imgutils.pose import dwpose_estimate, op18_visualize
from plot import image_plot


def _detect(img, **kwargs):
    return op18_visualize(img, dwpose_estimate(img), **kwargs)


if __name__ == '__main__':
    image_plot(
        ('dwpose/lie.jpg', 'lie (original)'),
        (_detect('dwpose/lie.jpg'), 'lie (keypoints)'),
        ('dwpose/squat.jpg', 'squat (original)'),
        (_detect('dwpose/squat.jpg'), 'squat (keypoints)'),
        columns=2,
        figsize=(9, 9),
        autocensor=False,
    )
+7 −0
Original line number Diff line number Diff line
"""
Overview:
    Utilities to detect human keypoints in anime images.

    .. image:: pose_demo.plot.py.svg
        :align: center
"""
from .dwpose import dwpose_estimate
from .format import OP18KeyPointSet, OP18_BODY_MAX, OP18_BODY_MIN, OP18_FACE_MAX, OP18_FACE_MIN, \
    OP18_LEFT_FOOT_MAX, OP18_LEFT_FOOT_MIN, OP18_LEFT_HAND_MAX, OP18_LEFT_HAND_MIN, \
+43 −8
Original line number Diff line number Diff line
"""
Overview:
    Detect human keypoints in anime images.

    The model is from `https://github.com/IDEA-Research/DWPose <https://github.com/IDEA-Research/DWPose>`_.

    .. image:: dwpose_demo.plot.py.svg
        :align: center

    This is an overall benchmark of all the keypoint detect models:

    .. image:: dwpose_benchmark.plot.py.svg
        :align: center

"""
import warnings
from functools import lru_cache
from typing import Tuple, List
@@ -381,14 +396,34 @@ def dwpose_estimate(image: ImageTyping, auto_detect: bool = True,
    """
    Performs inference on the RTMPose model and returns keypoints and scores.

    Args:
        image (ImageTyping): Input image.
        auto_detect: Auto detect person with :func:`imgutils.detect.detect_person`.
        out_bboxes (List[Tuple[int, int, int, int]], optional): Bounding boxes.
        person_detect_cfgs: Config arguments for :func:`imgutils.detect.detect_person`.

    Returns:
        List of mapping of different parts, including ``all``, ``head``, ``body``, ``foot``, ``hand1`` and ``hand2``.
    :param image: Input image.
    :type image: ImageTyping
    :param auto_detect: Auto detect person with :func:`imgutils.detect.person.detect_person`.
    :type auto_detect: bool
    :param out_bboxes: Bounding boxes.
    :type out_bboxes: Optional[List[Tuple[int, int, int, int]]]
    :param person_detect_cfgs: Config arguments for :func:`imgutils.detect.person.detect_person`.
    :type person_detect_cfgs: Optional[Dict]

    :return: List of mapping of different parts, including ``all``, ``head``, ``body``, ``foot``, ``hand1`` and ``hand2``.
    :rtype: List[OP18KeyPointSet]

    Examples:
        >>> from imgutils.data import load_image
        >>> from imgutils.pose import dwpose_estimate, op18_visualize
        >>>
        >>> image = load_image('dwpose/squat.jpg')
        >>> keypoints = dwpose_estimate(image)
        >>> keypoints
        [<imgutils.pose.format.OP18KeyPointSet object at 0x7f5ca933f3d0>]
        >>>
        >>> from matplotlib import pyplot as plt
        >>> plt.imshow(op18_visualize(image, keypoints))
        <matplotlib.image.AxesImage object at 0x7f5c98069790>
        >>> plt.show()

        .. note::
            Function :func:`imgutils.pose.visual.op18_visualize` can be used to visualize this result.
    """
    session = _open_dwpose_model()
    h, w = session.get_inputs()[0].shape[-2:]
+2 −2
Original line number Diff line number Diff line
Jinja2~=3.0.0
sphinx~=3.2.0
sphinx_rtd_theme~=0.4.3
sphinx>=3.2.0
sphinx_rtd_theme>=0.4.3
enum_tools~=0.9.0
sphinx-toolbox
plantumlcli>=0.0.2
+111 KiB
Loading image diff...