Metadata-Version: 2.4
Name: ai-center
Version: 2026.8.2
Summary: Automated Sample Alignment for MX using a YOLO Model
License-Expression: MIT
License-File: LICENSE
Author: Michel Fodje
Author-email: michel.fodje@lightsource.ca
Requires-Python: >=3.11, !=3.14.1, <3.15
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Provides-Extra: model
Provides-Extra: view
Requires-Dist: devioc (>=2025.6.2,<2026.0.0)
Requires-Dist: huggingface-hub (==1.28.0) ; extra == "model"
Requires-Dist: numpy (>=2.4.6,<3.0.0)
Requires-Dist: onnxruntime-gpu (>=1.26.0,<2.0.0)
Requires-Dist: opencv-contrib-python (>=4.13.0.92,<5.0.0.0) ; extra == "view"
Requires-Dist: opencv-python (>=4.13.0.92,<5.0.0.0)
Requires-Dist: redis (>=8.0.0,<9.0.0)
Requires-Dist: ultralytics (==8.4.62)
Project-URL: Homepage, https://github.com/michel4j/ai-center
Project-URL: Issues, https://github.com/michel4j/ai-center/issues
Project-URL: Models, https://huggingface.co/michel4j/mxsamples
Description-Content-Type: text/markdown

aicenter
========

A python based Soft IOC Server for Sample Alignment using a YOLO model.

Installation
============

```
python -m venv my-venv
source my-venv/bin/activate
pip install ai-center
```

To enabled downloading of the latest model file from HuggingFace, install with the `[model]` extra as follows:

```
pip install ai-center[model]
```

Running
=======

To run the EPICS IOC directly, use the following command:

```
app.epics --device "AIC001" --model "/path/to/model.pt" --video "video_uri"
```

### Command-line Arguments

*   `--device`: The EPICS root name of the device (e.g., `AIC001` or `AIC002`). **(Required)**
*   `--model`: Path to the YOLO model file. If omitted, the latest model will be downloaded from HuggingFace. The model is about 50 MB in size.
*   `--video`: The URI for the video stream. (e.g., `redis://hostname/0030180F06E5:JPG`) **(Required)**
*   `--confidence`: Object detection confidence threshold. (Optional, default: 0.1)
*   `-v`: Enable verbose logging. (Optional)

Currently, only `file://`, `redis://` and `http[s]://` video schemes are supported

### EPICS Process Variables

*   `AIC001:enable`: Set to 1/0 to Enable/Disable Inference
*   `AIC001:loop:score`: Score of best loop
*   `AIC001:loop:box`: Bounding Box of best loop
*   `AIC001:loop:valid`: 1 if best loop is still valid
*   `AIC001:loop:id`: id of best loop, not used at the moment
*   `AIC001:crystal:score`: Score of best crystal
*   `AIC001:crystal:box`: Bounding Box of best crystal
*   `AIC001:crystal:valid`: 1 if best crystal is still valid
*   `AIC001:crystal:id`: id of best crystal, not used at the moment
*   `AIC001:pin:score `: Score of best pin
*   `AIC001:pin:box`: Bounding Box of best pin
*   `AIC001:pin:valid`: 1 if best pin is still valid
*   `AIC001:pin:id `: ID of best pin, not used at the moment
*   `AIC001:extra:box`: Bounding Box array of extra Crystals (x1, y1, x2, y2) in sequence, length is 4 x number of extra crystals
*   `AIC001:extra:score`: Array of scores of extra crystals
*   `AIC001:extra:valid`: Array of validity of extra crystals, 1 if valid 0 if invalid
*   `AIC001:extra:id`: Corresponding IDs, of extra crystals (not used at the moment)

If you installed the `[view]` extra, you can also run the stand-alone inference viewer which displays the inference in a
window as follows:

```
app.view --model "/path/to/model.pt" --video "video_uri"
```

### Command-line Arguments

*   `--model`: Path to the YOLO model file. If omitted, the latest model will be downloaded from HuggingFace. The model is about 50 MB in size.
*   `--video`: The URI for the video stream. (e.g., `redis://hostname/0030180F06E5:JPG`) **(Required)**
*   `--confidence`: Object detection confidence threshold. (Optional, default: 0.1)
*   `-v`: Enable verbose logging. (Optional)
