Metadata-Version: 2.4
Name: landmarkerio-server
Version: 0.5.0
Summary: Menpo-based server for landmarker.io
Author-email: James Booth <james.booth08@imperial.ac.uk>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://menpo.github.io/landmarker.io/
Project-URL: Source, https://github.com/menpo/landmarkerio-server
Project-URL: Client, https://github.com/menpo/landmarker.io
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: menpo>=0.12
Requires-Dist: sanic>=23.12
Requires-Dist: sanic-cors
Requires-Dist: loguru
Requires-Dist: joblib
Requires-Dist: PyYAML
Provides-Extra: mesh
Requires-Dist: menpo3d>=0.10; extra == "mesh"
Dynamic: license-file

[![PyPI Release](http://img.shields.io/pypi/v/landmarkerio-server.svg?style=flat)](https://pypi.python.org/pypi/landmarkerio-server)

### The [Menpo](https://github.com/menpo/menpo)-powered [landmarker.io](https://github.com/menpo/landmarker.io) server

### About

**landmarkerio server** is an implementation of the landmarker.io server API
in Python. It uses Menpo to load images and meshes and serves them to
landmarker.io web clients for annotation. When the annotator is done, 
it is landmarkerio server that will actually persist the landmarks to disk.

The Python package for landmarkerio server is unambigously `landmarkerio`.

### Purpose

landmarker.io knowns how to talk to landmarkerio server instances over a RESTful API. The server
holds all assets and landmarks, and annotators can be constrained in what they can and can't
do. For instance - you can limit the choice of templates that users are able to use,
or the assets that they see. Upon saving, landmarks are saved back to the server instance,
so at all times you remain in control of the annotation experiement.

### Serving assets locally

For an annotation job on your own machine, run the server (`lmio`) from the command line and open the
hosted client with the address of your server:

```
>> lmio image ./path_to_images
```

then visit <https://menpo.github.io/landmarker.io/?server=http://localhost:5000>. A page served over
https may only talk to an https server, or to one on your own machine, which is what `localhost` is;
the server answers the "private network" preflight request that Chrome sends in that case.
To use another port, give `-p`.

For remote serving, SSH port tunnelling is an easy and secure solution.

### Installation

```
pip install landmarkerio-server            # serving images
pip install "landmarkerio-server[mesh]"    # also meshes (adds menpo3d)
```

It needs Python 3.10 or newer and [Menpo](https://github.com/menpo/menpo) 0.12 or newer, which is pure Python.
The hosted client is [landmarker.io](https://github.com/menpo/landmarker.io).

### Important concepts

landmarkerio server handles three different forms of data

- assets - *meshes, textures and images*
- landmarks - *annotations on assets*
- templates - *specifications of landmarks*


### Usage

The landmarker.io server can be started in one of two modes: 'image' and 'mesh'. To begin annotating a folder of meshes, just run
```
>> lmio mesh ./path_to_meshes
```

To begin annotating a folder of images, run
```
>> lmio image ./path_to_images
```

You get help on the tool just as you would expect

```
>> lmio --help
```

### Templates

#### Syntax

Templates restrict the set of allowed annotations and give the annotations
semantic meaning. The user of the server has full control over what
annotations the user of landmarker.io should complete by declaring *templates*.
A template file is simple a `.yml` file. The filename is the name of the template.

An example template is provided below, a [more detailed specification](https://github.com/menpo/landmarker.io/wiki/Templates-specification) is also available on the landmarker.io wiki.

**`face.yaml`**
```face.yaml
# groups key marks the template itself, anything else is metadata
groups:
  # The first landmark group is called 'mouth'
  # it is made up of six points
  - label: mouth
    points: 6
  - label: nose
    points: 3
    # Pairs of numbers immediately following a declaration
    # of a group specify connectivity information. Here,
    # The first entry of the nose group is joined to the second
    # (0-based indexing) and the second to the third. This will
    # be visualized in the landmarker.
    connectivity:
      - 0 1
      - 1 2
  - label: left_eye
    points: 8
    connectivity:
      # Slice notation is abused to construct straight chains
      # of connectivity. This is expanded out into
      # 0 1
      # 1 2
      # ...
      # 6 7
      - 0:7
      - 7 0
  - label: right_eye
    points: 8
    # The cycle shortcut
    connectivity: cycle
  - label: chin
    points: 1
```

#### Storing templates

A collection of template files can be placed in a templates folder.
A path to a folder can be provided as the `-t` argument to
`landmarkerio`. If no argument is provided, `lmio` looks for
the folder `~/.lmiotemplates`, and failing that uses the `ibug68` template that ships with the package. This provides a convenient place to
store frequently used templates.

