Skip to main content

Spatial image analysis with caffe and pytorch backends.

Project description

PySpacer

Build Status

This repository provide utilities to extract features from random point locations in images and then training classifiers over those features. It is used in the vision backend of https://github.com/beijbom/coralnet.

Spacer currently supports python >=3.5.

Overview

Spacer executes tasks as defined in messages. The messages types are defined in messages.py and the tasks in tasks.py. We also define several data-types in data_classes.py which define input and output types.

Refer to the unit-test in test_tasks.py for examples on how to create tasks. Currently the extract_features task only has a valid implementation through caffe, which requires the Docker build. We will add a PyTorch based feature extractor soon.

Tasks can be executed directly by calling the methods in tasks.py. However, spacer also supports an interface with SQS handled by sqs_mailman() in mailman.py.

Spacer supports four storage types: s3, filesystem, memory and url. Refer to storage.py for details. The Memory storage is mostly used for testing, and the url storage is read only.

Also take a look at config.py for settings and configuration.

Installation

The spacer repo can be installed in three ways.

  • Using Docker -- the only option that supports Caffe.
  • Local clone -- ideal for fast testing and development.
  • Using pip install -- for integration in other code-bases.

Config

Spacer needs three variables. They can either be set as environmental variables (recommended if you pip install the package), or in a secrets.json file in the same directory as this README (recommended for Docker builds and local clones). The secrets.json should look like this.

{
  "SPACER_AWS_ACCESS_KEY_ID": "YOUR_AWS_KEY_ID",
  "SPACER_AWS_SECRET_ACCESS_KEY": "YOUR_AWS_SECRET_KEY",
  "SPACER_LOCAL_MODEL_PATH": "/path/to/your/local/models"
}

Docker build

The docker build is the preferred build and the one used in deployment.

  • Install docker on your system
  • Create secrets.json as detailed above.
  • Create folder /path/to/your/local/models for caching model files.
  • Build image: docker build -t spacer:test .
  • Run: docker run -v /path/to/your/local/models:/workspace/models -it spacer:test

The -v /path/to/your/local/models:/workspace/models part will make sure the downloaded models are cached to your host storage. which makes rerunning stuff much faster.

The last step will run the default CMD command specified in the dockerfile (unit-test with coverage). If you want to enter the docker container run the same command but append bash in the end:

docker run -v /path/to/your/local/models:/workspace/models -it spacer:test bash

Pip install

  • pip install spacer
  • Set environmental variables.

Local clone

  • Clone this repo
  • pip install -r requirements.txt

Code coverage

If you are using the docker build or local install, you can check code coverage like so:

    coverage run --source=spacer --omit=spacer/tests/* -m unittest    
    coverage report -m
    coverage html

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

pyspacer-0.1.1.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyspacer-0.1.1-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file pyspacer-0.1.1.tar.gz.

File metadata

  • Download URL: pyspacer-0.1.1.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.2

File hashes

Hashes for pyspacer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d89a2bbd857aac9750931c8ab061295f0d7a6b730b6f6ee2d51d6346f164f4d6
MD5 118458b6c3bb25b81b3da7c12e545648
BLAKE2b-256 f8e2fc8d02973942d0c8667667fd81290bd2fa9210caa2e0d4ece7a21a9d6b4e

See more details on using hashes here.

File details

Details for the file pyspacer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyspacer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.2

File hashes

Hashes for pyspacer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1922bfd51b0520852b0cffe2db18474a8cb69e68d72d16eca817a2d0903c69b
MD5 7296b33e16b35d6d204b18effa767155
BLAKE2b-256 45412512c401c06a86d489ff9bf1b22b282ab62f84f08400106f186f85b7bd9c

See more details on using hashes here.

Supported by

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