Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Remove setup.py's deps hack, add requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
elcorto committed Feb 8, 2019
1 parent ed9fc85 commit 6cc9378
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 36 deletions.
15 changes: 7 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ Install

.. code:: sh
$ git clone https://github.com/elcorto/imagecluster.git
$ cd imagecluster
$ pip3 install -e .
or
or if you have the ``requirements.txt`` already installed (e.g. by your system's
package manager)

.. code:: sh
$ python3 setup develop --prefix=...
$ pip3 install -e . --no-deps
Usage
=====
Expand All @@ -33,7 +32,7 @@ NN model and calculate fingerprints. Then it will cluster the images based on
the fingerprints and a similarity index ``sim=0...1`` (more details below).

Example session:

.. code:: python
>>> from imagecluster import main
Expand Down Expand Up @@ -125,7 +124,7 @@ like chair, boat, car .. and kitchen. Simple image hashing, which we used
previously, is rather limited in that respect. It only does a very pedestrian
smoothing / low-pass filtering to reduce the noise and extract the "important"
parts of the image. This helps to find duplicates and almost-duplicates in a
collection of photos.
collection of photos.

To this end, we use a pre-trained NN (VGG16_ as implemented by Keras_). The
network was trained on ImageNet_ and is able to categorize images into 1000
Expand All @@ -137,7 +136,7 @@ connected layer (4096 nodes) as image fingerprints (numpy 1d array of shape
The package can detect images which are rather similar, e.g. the same scene
photographed twice or more with some camera movement in between, or a scene
with the same background and e.g. one person exchanged. This was also possible
with image hashes.
with image hashes.

Now with NN-based fingerprints, we also cluster all sorts of images which have,
e.g. mountains, tents, or beaches, so this is far better. However, if you run
Expand All @@ -162,7 +161,7 @@ Tests
=====

Run ``nosetests3`` (nosetests for Python3, Linux).

.. _VGG16: https://arxiv.org/abs/1409.1556
.. _Keras: https://keras.io
.. _ImageNet: http://www.image-net.org/
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
numpy
tensorflow
keras
Pillow
30 changes: 2 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# publish on pypi
# ---------------
# $ python3 setup.py sdist
# $ twine upload dist/imagecluster-x.y.z.tar.gz
# $ twine upload dist/imagecluster-x.y.z.tar.gz

import os, importlib
from setuptools import setup
Expand All @@ -14,32 +14,6 @@
with open(os.path.join(here, 'README.rst')) as fd:
long_description = fd.read()

# Hack to make pip respect system packages.
install_requires = []

# (pip name, import name, operator, version)
# ('numpy', 'numpy', '>', '1.0')
reqs = [('numpy', 'numpy', None, None),
('tensorflow', 'tensorflow', None, None),
('keras', 'keras', None, None),
('Pillow', 'PIL', None, None),
]

for pip_name,import_name,op,ver in reqs:
print("checking dependency: {}".format(import_name))
req = pip_name + op + ver if op and ver else pip_name
try:
pkg = importlib.import_module(import_name)
if op and ver:
cmd = "Version(pkg.__version__) {op} Version('{ver}')".format(op=op,
ver=ver)
if not eval(cmd):
install_requires.append(req)
except ImportError:
install_requires.append(req)

print("install_requires: {}".format(install_requires))

setup(
name='imagecluster',
version='0.0.0',
Expand All @@ -52,6 +26,6 @@
license='BSD 3-Clause',
keywords='image cluster vgg16 deep-learning',
packages=['imagecluster'],
install_requires=install_requires,
install_requires=open('requirements.txt').read().splitlines(),
## scripts=['{}/{}'.format(bindir, script) for script in os.listdir(bindir)]
)

0 comments on commit 6cc9378

Please sign in to comment.