Skip to main content

Packages to provide training, inference and export templates for computer vision anomaly detection models.

Project description



Sinapsis Anomaly Detection

Monorepo with packages to provide anomaly detection training, inference and export for computer vision.

🐍 Installation📦 Packages 🌐 Webapp 📙 Documentation🔍 License

🐍 Installation

This monorepo currently consists of the following packages for anomaly detection:

  • sinapsis-anomalib

Install using your package manager of choice. We encourage the use of uv

Example with uv:

  uv pip install sinapsis-anomalib --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-anomalib --extra-index-url https://pypi.sinapsis.tech

[!IMPORTANT] Templates in each package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:

with uv:

  uv pip install sinapsis-anomalib[all] --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-anomalib[all] --extra-index-url https://pypi.sinapsis.tech

[!TIP] You can also install all the packages within this project:

  uv pip install sinapsis-anomaly-detection[all] --extra-index-url https://pypi.sinapsis.tech

📦 Packages

Packages summary
  • Sinapsis Anomalib
    • AnomalibTorchInference
      Run anomaly detection inference using PyTorch models.
    • AnomalibOpenVINOInference
      Perform optimized inference using OpenVINO-accelerated models.
    • AnomalibTrain
      Train custom anomaly detection models with Anomalib.
    • AnomalibExport
      Export trained models for deployment in different formats.

[!TIP] Use CLI command sinapsis info --all-template-names to show a list with all the available Template names installed with Sinapsis Anomaly Detection.

[!TIP] Use CLI command sinapsis info --example-template-config TEMPLATE_NAME to produce an example Agent config for the Template specified in TEMPLATE_NAME.

For example, for AnomalibTorchInference use sinapsis info --example-template-config AnomalibTorchInference to produce the following example config:

agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: AnomalibTorchInference
  class_name: AnomalibTorchInference
  template_input: InputTemplate
  attributes:
    model_path: '/path/to/model.pt'
    transforms: null
    device: cuda

🌐 Webapp

The webapp offers an interface for anomaly detection on images using pretrained models. Upload images and visualize results (labels, bboxes, or masks) based on the provided agent configuration.

[!IMPORTANT] To run the app you first need to clone this repository:

git clone git@github.com:Sinapsis-ai/sinapsis-anomaly-detection.git
cd sinapsis-anomaly-detection

[!NOTE] If you'd like to enable external app sharing in Gradio, export GRADIO_SHARE_APP=True

[!NOTE] Model training is performed when starting the webapp if an exported model does not exist in the MODEL_PATH location.

🐳 Docker

IMPORTANT This docker image depends on the sinapsis-nvidia:base image. Please refer to the official sinapsis instructions to Build with Docker.

  1. Build the sinapsis-anomalib image:
docker compose -f docker/compose.yaml build
  1. Start the app container:
docker compose -f docker/compose_apps.yaml up sinapsis-anomalib-gradio -d
  1. Check the status:
docker logs -f sinapsis-anomalib-gradio
  1. The logs will display the URL to access the webapp, e.g.:

NOTE: The url can be different, check the output of the logs

Running on local URL:  http://127.0.0.1:7860
  1. To stop the app:
docker compose -f docker/compose_apps.yaml down
Webapp Configuration

Customize the webapp behavior by updating the environment fields in docker/compose_apps.yaml:

For custom inference agent:

AGENT_CONFIG_PATH: "/app/configs/inference/custom_torch_demo_agent.yml"

For custom training agent:

TRAINING_CONFIG: "/app/configs/custom_train_export_agent.yaml"

For custom inference model path:

MODEL_PATH: "/app/artifacts/exported_models/weights/torch/custom_model.pt"

For custom test data:

TEST_DIR: "/app/artifacts/data/custom_test_data"
💻 UV

To run the webapp using the uv package manager, please:

  1. Create the virtual environment and sync the dependencies:
uv sync --frozen
  1. Install the wheel:
uv pip install sinapsis-anomaly-detection[all] --extra-index-url https://pypi.sinapsis.tech
  1. Run the webapp:
uv run webapps/anomalib_gradio_app.py
  1. The terminal will display the URL to access the webapp, e.g.:

NOTE: The url can be different, check the output of the terminal

Running on local URL:  http://127.0.0.1:7860
Webapp Configuration

Customize the webapp behavior by exporting the following variables with your custom values before running the app:

For custom inference agent:

export AGENT_CONFIG_PATH="packages/sinapsis_anomalib/src/sinapsis_anomalib/configs/inference/custom_torch_demo_agent.yml"

For custom training agent:

export TRAINING_CONFIG="packages/sinapsis_anomalib/src/sinapsis_anomalib/configs/custom_train_export_agent.yaml"

For custom inference model path:

export MODEL_PATH="artifacts/exported_models/weights/torch/custom_model.pt"

For custom test data:

export TEST_DIR="artifacts/data/custom_test_data"

📙 Documentation

Documentation for this and other sinapsis packages is available on the sinapsis website

Tutorials for different projects within sinapsis are available at sinapsis tutorials page

🔍 License

This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.

For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.

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

sinapsis_anomaly_detection-0.1.9.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinapsis_anomaly_detection-0.1.9-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_anomaly_detection-0.1.9.tar.gz.

File metadata

File hashes

Hashes for sinapsis_anomaly_detection-0.1.9.tar.gz
Algorithm Hash digest
SHA256 e397fff5502de89ad811484453d40ea5f3c9d3326e12ac2c6ac83a3d92a5cc99
MD5 c92365307b48c889a54eed7f1066ae78
BLAKE2b-256 61def921a2d4a95f0f61d62212ca3aa072eca69e0047d11a34f9b05e65ca0750

See more details on using hashes here.

File details

Details for the file sinapsis_anomaly_detection-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_anomaly_detection-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5d799d181d6ee4ec96aea439c32a00649b7181c06d1ba30bf1f2b9f0af47159f
MD5 95a6aaf70e5f7426b43b4e62d1ace224
BLAKE2b-256 6bf911eb27fecdfaf1e212240f45ca0a8118eb63f4d86028e4a65f374020bb85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page