Skip to main content

py-image-comparer

Compares two images using Siamese Network (Machine Learning) trained from a Pytorch Implementation

Installation

To install, run

pip install image-comparer

Usage

CLI

image-compare

which wil show the follow help screen

usage: image-compare [-h] [--threshold THRESHOLD] Image1-Path Image2-Path

For example, you can compare two images with

image-compare tests/images/kobe.jpg tests/images/kobe2.jpg

which gives the result

kobe.jpg and kobe2.jpg are not similar

Programmatically

With PIL

import image_comparer
from PIL import Image

image = Image.open("test/kobe.jpg")
image2 = Image.open("test/kobe2.jpg")
image_comparer.is_similar(image, image2, threshold=0.5)

or with OpenCV

import image_comparer
import cv2

image = cv2.imread("test/kobe.jpg")
image2 = cv2.imread("test/kobe2.jpg")
image_comparer.is_similar(image, image2, threshold=0.5)

API

Methods

is_similar(image1: Union[Image.Image, np.ndarray], image2: Union[Image.Image, np.ndarray], threshold=0.5): Checks if the two images are similar based on the reshold passed

calculate_score(image1: Union[Image.Image, np.ndarray], image2: Union[Image.Image, np.ndarray]): Calculates the score between the two images. The higher the score, the more closely the two images are related.

Development

Installation

pip install -r requirements-test.txt

Tests

To run tests, run

pytest

Metadata

Release files for image-comparer 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for image-comparer 1.1.3
File Size Uploaded
image-comparer-1.1.3.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for image-comparer 1.1.3
File Interpreter ABI Platform
image_comparer-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / image-comparer-1.1.3.tar.gz

Download URL image-comparer-1.1.3.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f61fbf650a8bf4d214468c40c8a4517aa830a280f1af467a24dd44c2d430ba5a
BLAKE2b-256 checksum
How to use checksums
5fcb8fb7aadfdb02338fec1062e07719542db4f1d92fcf2cf8f11996acedbeab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.9

Release files / image_comparer-1.1.3-py3-none-any.whl

Download URL image_comparer-1.1.3-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
672a08ce21ded7d3bfa78b64f7a1c1fce7cdbb7a1c5f99f81113ed2ff3648f5c
BLAKE2b-256 checksum
How to use checksums
113426eb73c319e6eed07b293e4e82d2316c21f576bd0c79b1e02b7845807c74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 release files

1.1.2

1 release file

1.1.1

1 release file

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page