Skip to content

jnosal/domino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Manual

Useful settings (location domino/settings/base.py)

  1. IMAGE_CONTENT_TYPES - acceptable image content types
  2. IMAGE_COLOR_PERSIST_MODE - whether hex or color name should be taken into consideration when constructing color set
  3. IMAGE_EXTRACTION_MODE - whether color extraction should run in 'sync' or 'async' mode
  1. Useful linux packages
$ sudo apt-get install build-essential python-dev python-virtualenv python-dev g++ python-software-properties curl libjpeg62 libjpeg62-dev
  1. Clone project
$ git clone git@github.com:jnosal/domino.git .
  1. Install virtualenv
$ virtualenv venv/ && source venv/bin/activate
  1. Install requirements
$ pip install -r requirements.txt
  1. If You'll be using async mode install rabbitmq
$ sudo apt-get install rabbitmq-server
$ sudo service rabbitmq-server start
  1. Create database (it creates sqlite3 database && applies migrations)
$ python manage.py recreate_db
  1. Run tests
$ ./scripts/runtests.sh
  1. Run project (by default sync extraction mode and name persist mode)
$ python manage.py runserver
  1. Post couple of files
$ curl -X POST -F "image1=@data/cobra.jpg" -F "image2=@data/onlywhite.jpg" http://localhost:8000/api/v1/imagefile
  1. Explore
$ curl -X GET http://localhost:8000/api/v1/imagefile/search\?format\=json
  1. Search for color
$ curl -X GET http://localhost:8000/api/v1/imagefile/search\?format\=json\&color\=crimson
  1. Search for hex
$ curl -X GET http://localhost:8000/api/v1/imagefile/search\?format\=json\&hex\=fcfcfc
  1. Run in assync mode
    1. edit domino/settings/base.py and replace IMAGE_EXTRACTION_MODE = 'sync' with IMAGE_EXTRACTION_MODE = 'async'
    2. this assumes that rabbitmq is installed & running

Stop & start application again (after editing settings)

$ python manage.py runserver

In other terminbal start Celery worker

$ venv/bin/celery -A domino worker --loglevel=INFO

Image handling should be significantly faster:

$ curl -X POST -F "image1=@data/cobra.jpg" -F "image2=@data/onlywhite.jpg" http://localhost:8000/api/v1/imagefile

What can be than to improve overall project:

  1. adding authentication / authorization policies
  2. serving application via uwsgi / gunicorn and static files using nginx
  3. running in async mode with multiple celery workers
  4. replacing sqlite with postgresql or mysql
  5. considering storing image files on S3

About

Detect color in your images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published