No project description provided
Project description
🤗 Simple Aesthetics Predictor
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 git+https://github.com/shunk031/simple-aesthetics-predictor.git
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
- LAION-AI/aesthetic-predictor: A linear estimator on top of clip to predict the aesthetic quality of pictures https://github.com/LAION-AI/aesthetic-predictor
- christophschuhmann/improved-aesthetic-predictor: CLIP+MLP Aesthetic Score Predictor https://github.com/christophschuhmann/improved-aesthetic-predictor
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
Built Distribution
Close
Hashes for simple_aesthetics_predictor-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 656d2b5f36b5105cde1c782e938258ded883e9061f28a890bd7550163b264f86 |
|
MD5 | b3968d8ed95562f65df7c183019346c0 |
|
BLAKE2b-256 | 6c316cfd063f7483315be89a3d98db4600b142a16199c578235d94312f4da5af |
Close
Hashes for simple_aesthetics_predictor-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7226efe5d0423b4ea04a0c932dba57b3da69dfb5ba98ad4dad6385b7c045ffe8 |
|
MD5 | 163938bc104e1b9a2e2a9345c0e13048 |
|
BLAKE2b-256 | 2ade5dcc5b49ed483a5245eeb8f935796045f8291c4c219815a30cc80e6cf884 |