External server
Live Tracking > Save results > Measure > External server
TraCell can hand part of the work to another program: it sends the crops of the tracked cells in batches and takes back numbers, which become columns of the session's tables. The other program can run on the same computer or on another one, and can compute anything: a measurement, a classifier, a neural network.
The server is yours
TraCell only sends the crops and reads the answer. Writing the server, running it, keeping it reachable and what it computes are your responsibility. TraCell ships an example to start from.
How it works
- TraCell cuts a small picture (crop) of every tracked cell in every frame of a partition.
- It posts them to your address in batches (64 crops per request unless you change it), one request after the other.
- Your server answers each request with one or more values per crop.
- Each output becomes a column in
tables/partition_0001.csvof the session folder, beside the cell's position and size.
This runs behind the session: the camera never waits for the server. A request that fails or takes longer than the timeout is sent again, up to three times in all. If it still fails, that partition gets no measured columns, and the log says so; after two partitions in a row without an answer the server is left out for the rest of the session, so a server that is down does not hold everything up.
Settings
| Setting | Meaning |
|---|---|
| Address | Where the crops are posted, for example http://127.0.0.1:8000 or http://192.168.1.20:8000/cells |
| Crops per request | The batch size. Smaller batches answer sooner; larger ones mean fewer requests |
| Timeout | Seconds to wait for the answer to one batch |
The crop size is set beside Cell crops in the same group.
What is sent and what must come back
One request per batch:
POST <address>
{"inputs": [{"name": "crops", "shape": [64, 32, 32], "datatype": "UINT8", "data": [0, 12, 255, ...]}]}
shape is (crops, height, width); data holds the pixels of all crops, row after row, as gray values from 0
to 255. The answer:
{"outputs": [{"name": "brightness", "shape": [64], "data": [101.5, 98.2, ...]},
{"name": "class", "shape": [64, 2], "data": [0.9, 0.1, 0.2, 0.8, ...]}]}
One value per crop gives a column with the output's name (brightness). Several values per crop give
numbered columns (class_0, class_1). The order of the crops must be kept.
A server in 50 lines
Help > Example Scripts opens a folder with crop_server.py: a complete server that needs only Python and
NumPy. Copy it, put your processing into its process function and run it:
python crop_server.py
It then listens on http://127.0.0.1:8000, which is the address TraCell starts with.
If you already run an inference server
The request and the answer have the form of the Open Inference Protocol (KServe v2), which Triton, KServe,
TorchServe and MLServer speak. Give the model's full address, for example
http://server:8000/v2/models/cells/infer. This was not tested against such a server.
Limits
- Tested against a small test server and the shipped example only.
- The crops travel as text (JSON). That is simple and fine on one computer or a lab network; a very large crop size or batch makes large requests.
- The measured columns are in the saved tables. The Live Dashboard does not show them.