Skip to content

deepghs/sdeval

Repository files navigation

sdeval

PyPI PyPI - Python Version Loc Comments

Code Test Package Release codecov

Discord GitHub Org's stars GitHub stars GitHub forks GitHub commit activity GitHub issues GitHub pulls Contributors GitHub license

Evaluation for stable diffusion model training

Installation

You can simply install it with pip command line from the official PyPI site.

pip install sdeval

If your operating environment includes a available GPU, you can use the following installation command to achieve higher performance:

pip install sdeval[gpu]

For more information about installation, you can refer to Installation.

Quick Start

CCIP Metrics

from sdeval.fidelity import CCIPMetrics

ccip = CCIPMetrics(images='/path/of/character/dataset')

# ccip score of one image
print(ccip.score('/path/of/one/image'))

# ccip score of a directory of images
print(ccip.score('/directory/of/images'))

Bikini Plus Metrics

from sdeval.controllability import BikiniPlusMetrics

# build bikini plus score metrics
bp = BikiniPlusMetrics(
    tag_blacklist=[
        'bangs', 'long_hair', 'blue_eyes', 'animal_ears', 'sleeveless',
        'breasts', 'grey_hair', 'medium_breasts'
    ]
)

# bp score of one image
# the image should contain a1111 webui's metadata of prompts
print(bp.score('/path/of/one/image'))

# bp score of a directory of images
# the images should contain a1111 webui's metadata of prompts
print(bp.score('/directory/of/images'))

AI Corrupt Metrics

from sdeval.corrupt import AICorruptMetrics

# build metrics
metrics = AICorruptMetrics()

# get ai corrupt score for one image file
print(metrics.score('/path/of/one/image'))

# get ai corrupt score of a directory of image files
print(metrics.score('/directory/of/images'))

# get ai corrupt score of list of images
print(metrics.score(['image1.png', 'image2.png']))