Skip to main content

Compares two images using siamese networks

Project description

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

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

image-comparer-1.1.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

image_comparer-1.1.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file image-comparer-1.1.3.tar.gz.

File metadata

  • Download URL: image-comparer-1.1.3.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for image-comparer-1.1.3.tar.gz
Algorithm Hash digest
SHA256 f61fbf650a8bf4d214468c40c8a4517aa830a280f1af467a24dd44c2d430ba5a
MD5 ba341925d9dddfb16e710c0b3b737ecc
BLAKE2b-256 5fcb8fb7aadfdb02338fec1062e07719542db4f1d92fcf2cf8f11996acedbeab

See more details on using hashes here.

File details

Details for the file image_comparer-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: image_comparer-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for image_comparer-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 672a08ce21ded7d3bfa78b64f7a1c1fce7cdbb7a1c5f99f81113ed2ff3648f5c
MD5 5fd9a6808301de9e6c2670ccc6450b1c
BLAKE2b-256 113426eb73c319e6eed07b293e4e82d2316c21f576bd0c79b1e02b7845807c74

See more details on using hashes here.

Supported by

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