Deep learning loss functions and models for image similarity
Project description
Image Similarity Criteria
A Python package that provides various perceptual similarity metrics for comparing images using state-of-the-art models including Face Recognition Systems (FRS), CLIP, and LPIPS.
Features
- Face Recognition System (FRS) based identity loss with multiple model options:
- IR-152
- IR-SE-50
- MobileFaceNet
- FaceNet
- CurricularFace
- CLIP-based similarity metrics
- LPIPS (Learned Perceptual Image Patch Similarity)
- Ensemble ID loss for combining multiple FRS models
Installation
pip install criteria
Usage
Face Recognition System (FRS)
from criteria import id_loss
from PIL import Image
# Initialize ID loss with a specific model
id_loss_fn = id_loss.IDLoss(model_name='ir_se50')
# Load images
img1 = Image.open('image1.jpg')
img2 = Image.open('image2.jpg')
# Calculate identity loss
loss = id_loss_fn(img1, img2)
CLIP Similarity
from criteria import clip_loss
# Initialize CLIP loss
clip_loss_fn = clip_loss.CLIPLoss()
# Calculate CLIP similarity
similarity = clip_loss_fn(img1, img2)
LPIPS
from criteria import lpips_loss
# Initialize LPIPS
lpips_fn = lpips_loss.LPIPSLoss()
# Calculate perceptual similarity
distance = lpips_fn(img1, img2)
Model Weights
Pre-trained model weights will be automatically downloaded when initializing the respective loss functions.
License
MIT License
Citation
If you use this package in your research, please cite:
@misc{criteria2023,
author = {Le, Minh-Ha},
title = {Criteria: Image Similarity Metrics},
year = {2023},
publisher = {GitHub},
url = {https://github.com/minha12/criteria}
}
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file criteria-0.1.6.tar.gz.
File metadata
- Download URL: criteria-0.1.6.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37c0c9346899a71220b14bd0b4be42bcd24b8181e5a387d0068d43359478a994
|
|
| MD5 |
adf2bf9d2f7b63b75b9c30c1667e614f
|
|
| BLAKE2b-256 |
4a11bec66360cbdb5f19750d2a14c4b46c9657137120d675b5fe207685ab2f3f
|
File details
Details for the file criteria-0.1.6-py3-none-any.whl.
File metadata
- Download URL: criteria-0.1.6-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf7ac7899aa49d8340ca8daf823bb150f4044f482ccd86e9c85c676539e7c2dd
|
|
| MD5 |
2a00d45f02299f15b977788369735c04
|
|
| BLAKE2b-256 |
2b5b2ff4c8049bf64d4ac8f8b65a6743deacd200b58aad6f6257079b1eb9c2ec
|