imgutils Documentation

repository·main·Indexed 19 days ago

https://github.com/deepghs/imgutils

A specialized Python image processing library for anime-style imagery. It provides high-level tools for character, face, head, and person detection, as well as difference detection (Tachie), clustering via CCIP and lpips_clustering, and tagging using the wd14-v2 model. Additional features include lineart generation, monochrome and truncated file validation, RGBA segmentation with isnetis, and ASCII art rendering.

Tokens
28.6K
Snippets
175
Records
219
Agent score
59%

What's inside imgutils

  1. Overview of imgutils

    main
    imgutils is a user-friendly Python library designed for anime-style image data processing. It integrates various advanced models specifically optimized for anime-style imagery, including features like Tachie (difference) detection, clustering, and contrastive character image pretraining.
  2. Use imgutils.metadata for image metadata extraction

    main

    The imgutils.metadata module provides utilities for extracting and managing metadata from images. It includes specialized functions for retrieving general image information, as well as specific metadata formats like EXIF, IPTC, and XMP.

    Key sub-modules include:

    • geninfo: General image information extraction.
    • lsb: Least Significant Bit (LSB) related metadata or steganography detection/extraction.
  3. Explore imgutils.preprocess modules

    main

    The imgutils.preprocess module provides a collection of tools for image preprocessing. It is organized into several sub-modules based on the underlying backend or functional category:

    • base: Core preprocessing utilities.
    • pillow: Preprocessing functions leveraging the Pillow library.
    • torchvision: Preprocessing functions leveraging the torchvision library (typically for PyTorch-based workflows).
    • transformers: Preprocessing functions leveraging the Hugging Face transformers library.

    Use these sub-modules to prepare images for various computer vision tasks, such as model inference or data augmentation.

  4. Explore imgutils.detect detection modules

    main

    The imgutils.detect module provides a collection of specialized detection tools for identifying various elements within images. Depending on your use case, you can use specific submodules to detect:

    • Booru YOLO: Booru-style object detection.
    • Censor: Detection of censored areas.
    • Eye, Face, Head, Hand, Halfbody, Person: Human anatomical and body part detection.
    • Nudenet: Detection using the Nudenet model.
    • Similarity: Visual similarity detection.
    • Text: Text detection within images.
    • Visual: General visual feature detection.
  5. Generate lineart from anime images

    main

    You can convert anime images to line drawings using models from controlnet_aux.

    • canny: The fastest method, but provides average quality.
    • lineart: Higher quality but consumes more computational resources.
    • lineart_anime: Recommended as the most balanced choice for most use cases.
  6. Detect faces, heads, and persons in anime images

    main

    imgutils supports object detection specifically optimized for anime-style content:

    • Face Detection: Detects faces.
    • Head Detection: Detects heads. This is noted as being very stable and suitable for automation.
    • Person Detection: Detects full persons. This feature is currently being iterated to improve performance on artistic illustrations.
  7. Install imgutils via pip

    main

    You can install imgutils using pip from PyPI.

    For standard CPU-based processing, use the default installation. If your environment has an available GPU, install the [gpu] extra to enable higher performance models.

    # Standard installation
    pip install dghs-imgutils
    
    # GPU-accelerated installation
    pip install dghs-imgutils[gpu]