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

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: simple_aesthetics_predictor-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 0bf94fa2e097c608c028e743673e2deb9ff280bff17351f283e02b20e63ec764
MD5 f0e9a3e5af1b027ddb92d84ff0cf39be
BLAKE2b-256 63d6675270b046f97785ef3e5acfd36bd5ea435303283cf8362ca330bf7ee542

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_aesthetics_predictor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad5b6af625bb0cf55dd77fd3d82a2a767e36c81700e1f558263e599ffbedbf67
MD5 df425fd663df6580f0b5ae7dc5a9e6f5
BLAKE2b-256 6822110ce83e3f36f12a5ecebe65c18432f9a553e4a94516b61778edf72d7b6b

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