Skip to main content

Aesthetic predictor v2.5

Project description

Aesthetic Predictor V2.5

Aesthetic Predictor V2.5 is a SigLIP-based predictor that evaluates the aesthetics of an image on a scale from 1 to 10. Compared to Aesthetic Predictor V2, it has been improved to evaluate a wider range of image domains.

This repository features an interface similar to Hugging Face Transformers, inspired by Simple Aesthetics Predictor, making it easy to use.

Installation

pip install aesthetic-predictor-v2-5

Usage

from pathlib import Path
import torch

from aesthetic_predictor_v2_5 import convert_v2_5_from_siglip

SAMPLE_IMAGE_PATH = (
    Path(__file__).resolve().parent
    / "assets"
    / "samples"
    / "sample1.jpg"
)

# load model and preprocessor
model, preprocessor = convert_v2_5_from_siglip(
    low_cpu_mem_usage=True,
    trust_remote_code=True,
)
model = model.to(torch.bfloat16).cuda()

# load image to evaluate
image = Image.open(SAMPLE_IMAGE_PATH).convert("RGB")

# preprocess image
pixel_values = (
    preprocessor(images=image, return_tensors="pt")
    .pixel_values.to(torch.bfloat16)
    .cuda()
)

# predict aesthetic score
with torch.inference_mode():
    score = model(pixel_values).logits.squeeze().float().cpu().numpy()

# print result
print(f"Aesthetics score: {score:.2f}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

aesthetic_predictor_v2_5-2024.5.28-py2.py3-none-any.whl (27.9 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page