Views
No views yet
1from transformers import CLIPProcessor
2from aesthetic_scorer import AestheticScorer
3import torch
4from PIL import Image
5
6# Load the model
7processor = CLIPProcessor.from_pretrained("rsinema/aesthetic-scorer")
8model = torch.load("rsinema/aesthetic-scorer/model.pt")
9
10# Process an image
11image = Image.open("your_image.jpg")
12inputs = processor(images=image, return_tensors="pt")["pixel_values"]
13
14# Get scores
15with torch.no_grad():
16 scores = model(inputs)
17
18# Print results
19aesthetic_categories = ["Overall", "Quality", "Composition", "Lighting", "Color", "Depth of Field", "Content"]
20for category, score in zip(aesthetic_categories, scores):
21 print(f"{category}: {score.item():.2f}/5")