imgutils.detect.eye

Overview:

Detect eyes in anime images.

Trained on dataset deepghs/anime_eye_detection with YOLOv8.

../../_images/eye_detect_demo.plot.py.svg

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

../../_images/eye_detect_benchmark.plot.py.svg

detect_eyes

imgutils.detect.eye.detect_eyes(image: str | PathLike | bytes | bytearray | BinaryIO | Image, level: str = 's', version: str = 'v1.0', max_infer_size=640, conf_threshold: float = 0.3, iou_threshold: float = 0.3) List[Tuple[Tuple[int, int, int, int], str, float]][source]
Overview:

Detect human eyes in anime images.

Parameters:
  • image – Image to detect.

  • level – The model level being used can be either s or n. The n model runs faster with smaller system overhead, while the s model achieves higher accuracy. The default value is s.

  • version – Version of model, default is v1.0.

  • max_infer_size – The maximum image size used for model inference, if the image size exceeds this limit, the image will be resized and used for inference. The default value is 640 pixels.

  • conf_threshold – The confidence threshold, only detection results with confidence scores above this threshold will be returned. The default value is 0.3.

  • iou_threshold – The detection area coverage overlap threshold, areas with overlaps above this threshold will be discarded. The default value is 0.3.

Returns:

The detection results list, each item includes the detected area (x0, y0, x1, y1), the target type (always eye) and the target confidence score.

Examples::
>>> from imgutils.detect import detect_eyes, detection_visualize
>>>
>>> image = 'squat.jpg'
>>> result = detect_eyes(image)  # detect it
>>> result
[((297, 239, 341, 271), 'eye', 0.7760562896728516), ((230, 289, 263, 308), 'eye', 0.7682342529296875)]
>>>
>>> # visualize it
>>> from matplotlib import pyplot as plt
>>> plt.imshow(detection_visualize(image, result))
>>> plt.show()