Skip to main content

No project description provided

Project description

🤗 Simple Aesthetics Predictor

CI Release Python PyPI

CLIP-based aesthetics predictor inspired by the interface of 🤗 huggingface transformers. This library provides a simple wrapper that can load the predictor using the from_pretrained method.

Install

pip install simple-aesthetics-predictor

How to Use

import requests
import torch
from PIL import Image
from transformers import CLIPProcessor

from aesthetics_predictor import AestheticsPredictorV1

#
# Load the aesthetics predictor
#
model_id = "shunk031/aesthetics-predictor-v1-vit-large-patch14"

model = AestheticsPredictorV1.from_pretrained(model_id)
processor = CLIPProcessor.from_pretrained(model_id)

#
# Download sample image
#
url = "https://github.com/shunk031/simple-aesthetics-predictor/blob/master/assets/a-photo-of-an-astronaut-riding-a-horse.png?raw=true"
image = Image.open(requests.get(url, stream=True).raw)

#
# Preprocess the image
#
inputs = processor(images=image, return_tensor="pt")

#
# Inference for the image
#
with torch.no_grad():
    outputs = model(**inputs)
prediction = outputs.logits

print(f"Aesthetics score: {prediction}")

The Predictors found in 🤗 Huggingface Hub

Acknowledgements

Project details


Download files

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

Source Distribution

simple_aesthetics_predictor-0.1.2.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

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