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 details)

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: simple_aesthetics_predictor-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7d992ffd643be35ee56d540f9bc4d6e54f3734d995fc145a17996d018b18cec3
MD5 a2b2949e5a9b143bfafa72a7cf8eecf1
BLAKE2b-256 3abbceb460fadfbe100909bbfa81f30893fe684202db07fe95e7b163241cf408

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_aesthetics_predictor-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d624abbea19118ab51b613f14bb608b0b811d42fb1240ae2a9224a676c1bf262
MD5 fa9d26d4d67d1d12415804b119799eb6
BLAKE2b-256 8892c4805e510862a5ddb7d34370ccd818e09a950c23500294a2d3a7b33efecb

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