imgutils Documentation
repository·main·Indexed 19 days ago
https://github.com/deepghs/imgutilsA 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.
What's inside imgutils
- 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.
Overview of imgutils
mainimgutilsis a module designed to parse and manage the structure and versions of configuration files.Use imgutils.metadata for image metadata extraction
mainThe
imgutils.metadatamodule 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.
Use imgutils.preprocess.torchvision for torchvision integration
mainTheimgutils.preprocess.torchvisionmodule provides utilities to integratetorchvisiontransforms and parsing logic into theimgutilspreprocessing pipeline. It allows for registering custom torchvision transforms and parsers, as well as creating and parsing transform configurations.Use imgutils.validate.safe for safety validation
mainTheimgutils.validate.safemodule provides tools to perform safety checks on images. It includes functions to calculate a safety score and perform a boolean safety check, typically used to identify potentially unsafe or inappropriate content in images.Explore imgutils.preprocess modules
mainThe
imgutils.preprocessmodule 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
torchvisionlibrary (typically for PyTorch-based workflows). - transformers: Preprocessing functions leveraging the Hugging Face
transformerslibrary.
Use these sub-modules to prepare images for various computer vision tasks, such as model inference or data augmentation.
Explore imgutils.detect detection modules
mainThe
imgutils.detectmodule 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.
Generate lineart from anime images
mainYou 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.
Detect faces, heads, and persons in anime images
mainimgutils 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.
Install imgutils via PyPI
mainInstall the stable version of
imgutilsfrom PyPI usingpip. This package requires Python version 3.8 or higher.pip install dghs-imgutilsInstall imgutils via pip
mainYou can install
imgutilsusingpipfrom 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]Install imgutils from GitHub
mainTo install the latest development version directly from the GitHub repository, use the following command:
pip install -U git+https://github.com/deepghs/imgutils@main