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.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file simple_aesthetics_predictor-0.1.1.tar.gz.

File metadata

  • Download URL: simple_aesthetics_predictor-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure

File hashes

Hashes for simple_aesthetics_predictor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8a89430c0f70c4e3d38f6ea4b1a56a6c8b1a49a000692d1881eea9d46e6993b3
MD5 78672dc4bdd3b00ecd6ce506dd181d9c
BLAKE2b-256 2746f5af884c66915332a3a3ac38b4e331324132e029f6f1d0474913bca21166

See more details on using hashes here.

File details

Details for the file simple_aesthetics_predictor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_aesthetics_predictor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6de7d2a30523befc6d1bc0bf08980ba864fa193e0668f13068e750861e9e2471
MD5 1ba83f77ed42d45b93a882d584a42ce3
BLAKE2b-256 035fba129a29afb6c70b0b7c0d928d14f7ff81e637ac77b3f4b436b19711719c

See more details on using hashes here.

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