Skip to main content

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

  1. Clone the repository:
git clone https://github.com/minha12/criteria.git
cd criteria
  1. Install the package:
pip install -e .

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/username/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

criteria-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

criteria-0.1.0-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: criteria-0.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.20

File hashes

Hashes for criteria-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f91ba63e4251f6761f414e218c7baf79ffce51210150cdcf3c4d8107492f9b01
MD5 6ec926cb557e8955fc59a85c165a1d62
BLAKE2b-256 ce2d34cce289797a8cb51a7523b5823a0ac1f6b2f775c783fb9a10ed7a9fc9dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: criteria-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.20

File hashes

Hashes for criteria-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6dd067f84d1305cfbc4513e6a4a69cf254e1cbeb21265409e4b376d5cce1c2b
MD5 b271262ebb357a5a8c7af4bc001d90d4
BLAKE2b-256 844ec6fca90be500cf1075e54673f390c4998fe63d4a2a36bba0b86d8767cb9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page