Git Product home page Git Product logo

pycompare's Introduction

PyCompare

Python-based image similarity calculator

Code in this repo helps calculate a similarity score of two images.

The algorithm is based on MSE (Mean Squared Error) and a part of the Python code was obtained from this post.

TravisCI builds the python code into two executables; one for MacOS and another one for Windows; and uploads it to this Github repo under 'Releases' here.

Considerations

How do you know if your code works?
  • pytest unit tests are written in comparator_test.py. Running pytest from the command line will test basic functionality. It wasn't possible to integrate this into TravisCI because of an issue with opencv-python on Windows.
  • You may also run python comparator.py to test functionality before committing changes. A sample images.csv and test images are provided images folder.
How are you going to teach Bjorn how to use the program?
  • A help dialog pops up every time the program is run. help-dialog
  • When the program finishes successfully, another dialog pops up letting the user know so. finished-dialog
How are you ensuring Bjorn gets the latest version of your application?
  • A new version is created everytime the build succeeds. A version info dialog pops up if a newer version of the program is available on Github. version-dialog. Version info is bundled into the executable at build time by 'pyinstaller' and is checked on program startup.
Your manager Jeanie is assigning you to a different task and is making Ferris the maintainer of your application. How do you make sure he succeeds?
  • The #Maintainer section of this README contains setup and dev instructions for a future maintainer.

Running this program

Download an executable for your operating system (MacOS or Windows) from the releases page.

Requirements

In the same folder populate a CSV file with two columns:

  • Column#1 must contain an absolute path to a source image.
  • Column#2 must contain the absolute path to a second image to compare the first against.

Path must be compatible with the OS. Windows paths are of style: C:/Users/<-username->/Documents/pycompare/image1.png. MacOS paths are your typical Unix-style paths: /Users/<-username->Library/Documents/pycompare/image1.png

Limitations and future improvements

  • The program doesn't yet accept files of GIF and TIFF formats due to opencv-python's limitations with licensing. This will be addressed in a future version.
  • We're unable to run pytests because of a Windows-TravisCI bug. Hopefully, a fix is available in the future.
  • A new version of the program is created on every successful TravisCI build, regardless of whether there's a change in the Python code. This must be fixed to only run on code changes.

Execute

Execute the program by double-clicking on the executable file. You will first be presented with a help dialog box. See: https://github.com/vsanjay85/pycompare#how-are-you-going-to-teach-bjorn-how-to-use-the-program

If the program runs successfully, you will be presented with a window citing so, and a file named processed_images.csv will be placed in the same folder where the executable was placed.

This file will contain four columns:

  • Column1 and Column2 will be the same as the source CSV.
  • Column3 holds the similarity score of the two source and target images. A score of '0' indicates 100% similar images.
  • Column4 holds the time the program took to calculate the score, in seconds.

Maintainer

How to use this repo

  • Install Python 3.7 or up
  • Open a terminal (Unix) or powershell (Windows) window
  • Create a virtualenv, ensuring the venv is based on python 3.7
  • Activate the virtualenv
  • Clone this repo
  • Install the required pip packages by running: pip3 install -r requirements.txt
  • Create a new branch git checkout -b <branch-name>
  • Make your modifications to the code
  • Test the functioning of the code by running: python comparator.py. Code will use the sample images.csv and images from the images folder. Python works with both / and \ path separators without issues.
  • If you'd prefer creating an executable to test, run the appropriate pyinstaller command from file .travis.yml. This creates an executable in the dist folder.
  • Once tested and satisfied, push your changes to your branch git push.

Github-Releases token creation

A token is used to push the build artifacts into Github/Releases. This token is generated by using the travis CLI which is installed by running gem install travis Then you run: travis login --pro travis setup releases --com which automatically creates, encrypts, and adds the token to .travis.yml.

pycompare's People

Contributors

vsanjay85 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.