Skip to main content

scikit-surgerytf is a Python package for Tensor Flow examples and utilities

Project description

Logo GitHub Actions CI status Test coverage Documentation Status

Author: Matt Clarkson

scikit-surgerytf is part of the SNAPPY software project, developed at the Wellcome EPSRC Centre for Interventional and Surgical Sciences, part of University College London (UCL).

scikit-surgerytf supports Python 3.6+, and tensorflow >= 2.0.0.

The aim of scikit-surgerytf is to provide a home for various Tensor Flow examples and utilities and to show best practice. It’s NOT meant to be a layer on-top of Tensor Flow or provide a new kind-of platform. The aim is that researchers can learn from examples, and importantly, learn how to deliver an algorithm that can be used by other people out of the box, with just a `pip install`, rather than a new user having to re-implement stuff, or struggle to get someone else’s code running. Researchers can commit their research to this repository, or use the PythonTemplate to generate their own project as a home for their new world-beating algorithm!

Design Principles

Each project herein should provide the following:

  • Code that passes pylint.
  • Unit testing, as appropriate. In all likelihood, testing will cover individual functions, not large training cycles.
  • Sufficient logging, including date, time, software (git) version, runtime folder, machine name.
  • A main class containing a network that can be run separately in train/test mode.
  • Visualisation with TensorBoard.
  • Saving of learned network weights at the end of training.
  • Loading of pre-train weights, initialising the network ready for inference.
  • The ability to be run repeatedly for hyper-parameter tuning via python scripting, not bash.
  • The ability to be callable from within a Jupyter Notebook, and thereby amenable to weekly writup’s for supervisions.
  • One or more command line programs that are pip-installable, enabling a subsequent user to train and test your algorithm with almost-zero faff.
  • Visualisation for debugging purposes, such as printing example image thumbnails etc. should be done in Jupyter notebooks, or in tensorboard, not in the same class as your algorithm.

Optional features could include:

  • Small test projects that train quickly to completion won’t need checkpointing, but large ones will.


Typical instructions for use:

First create a clean python environment, just installing tox:

# Create a clean conda environment
conda create -n myenv python=3.6
conda activate myenv
pip install tox

Then you get the code, and use tox to install all other dependencies:

git clone
cd scikit-surgerytf
# edit requirements.txt, changing tensorflow to tensorflow-gpu.
# The default is the CPU version just for cross platform testing,
# but for real use, you should swap it to GPU.
# Then run tox to install all dependencies.

Then you can activate the tox created virtualenv and run top-level entry points directly from the root folder:

source .tox/py36/bin/activate
python --help

Windows users would run:

python --help

So, for example, to run the program and train on some data, you would do:

python -d DATA -w working_dir -s output.hdf5

where DATA is a directory like:


and P1,P2..PN just represents some patient identifier. Images and masks, though in different folders, must have the same name.



You can clone the repository using the following command:

git clone

Running tests

Pytest is used for running unit tests, but you should run using tox, as per the PythonTemplate instructions.


This code conforms to the PEP8 standard. Pylint is used to analyse the code. Again, follow the PythonTemplate instructions and run via tox.


You can pip install directly from the repository as follows:

pip install git+


Please see the contributing guidelines.


Supported by Wellcome and EPSRC.

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

scikit-surgerytf-0.2.1.tar.gz (34.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page