Skip to content

A loss function (Weighted Hausdorff Distance) for object localization in PyTorch

Notifications You must be signed in to change notification settings

designer00/weighted-hausdorff-loss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object locator

Table of Contents

  1. Using Conda (recommended)
    1. Installation
    2. Usage
      1. Test/evaluate
      2. Train
    3. Uninstall
  2. Using Docker

Using Conda (recommended)

Installation

  1. Download and install Anaconda as described in https://docs.anaconda.com/anaconda/install
  2. Download the tool from this link, and decompress the zip.
  3. Open the terminal in Linux/MacOS. In Windows, open the Anaconda Prompt.
  4. "cd" into the decompressed directory
  5. Download the trained models from here and put them in
    object-locator-1.3.0/object-locator/checkpoints
  6. Install the dependencies:
  7. conda env create
    
  8. Activate the environment:
    • In Linux/MacOS:
    • source activate object-locator
      
    • In Windows:
    • activate object-locator
      
  9. Install the tool:
  10. pip install .
    
  11. Download some example data from here and decompress it wherever you want.
  12. Usage

    Activate the environment:

    • In Linux/MacOS:
    • source activate object-locator
      
    • In Windows:
    • activate object-locator
      

    Test/evaluate

    To use a pre-trained model/checkpoint.

    Run this to get help (usage instructions):

    python -m object-locator.locate -h
    

    Example:

    python -m object-locator.locate \
           --dataset DIRECTORY \
           --out DIRECTORY \
           --model CHECKPOINTS \
           --evaluate \
           --no-gpu \
           --radius 5
    

    Train (optional)

    If you do not want to use one of the provided pretrained models, you can train your own model. Run the following command to get the full help message on how to train, with an explanation of all available training parameters. You need to have a NVIDIA card and CUDA 8 installed to train your own model. This depends greatly on the specific model of your NVIDIA card and operating system.

    Run this to get help (usage instructions):

    python -m object-locator.train -h
    

    Example:

    python -m object-locator.train \
           --train-dir ~/data/20160613_F54_training_256x256 \
           --batch-size 32 \
           --env-name sorghum \
           --lr 1e-3 \
           --val-dir ~/data/plant_counts_random_patches/20160613_F54_validation_256x256 \
           --optim Adam \
           --save unet_model.ckpt
    

    Uninstall

    • In Linux/MacOS:
    • source deactivate object-locator
      
    • In Windows:
    • deactivate object-locator
      
    conda env remove --name object-locator
    

    Using Docker

    (only for expert users)

    1. Install docker-ce as described in https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository
    2. Install NVIDIA drivers
    3. Run the following commands
    
    docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
    sudo apt-get purge -y nvidia-docker
    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
      sudo apt-key add -
    curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \
      sudo tee /etc/apt/sources.list.d/nvidia-docker.list
    sudo apt-get update
    sudo apt-get install -y nvidia-docker2
    sudo pkill -SIGHUP dockerd
    docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
    

    You can get more details at https://github.com/NVIDIA/nvidia-docker

About

A loss function (Weighted Hausdorff Distance) for object localization in PyTorch

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%