Skip to main content

Single Scene Video Anomaly Detection Metrics

Project description

Single-Scene Video Anomaly Detection (SSVAD) Metrics

This project contains evaluation protocol (metrics) for benchmarking single-scene video anomaly detection (SSVAD).

Evaluation Protocol

This is an unofficial implementation of Sec. 2.2 of A Survey of Single-Scene Video Anomaly Detection. This metric is intended only for single-scene video anomaly detection methods and is untested for other purposes.

There are 3 kind of supported outputs from SSVAD methods/ground-truths:

  • Pixel-level anomaly scores maps.
  • Bounding-boxes based outputs, it will be implicitly converted into pixel-level anomaly scores maps. Overlapping bounding-boxes will be averaged by its scores.
  • Frame-level anomaly scores.

The metrics can be categorized into 4:

  1. Track-based metric: requires pixel-level anomaly scores maps predictions and ground-truths, plus anomaly track ID for each frame in the ground-truths that contains anomalous regions (predictions does not require anomaly track ID and is ignored in the process).
  2. Region-based metric: requires pixel-level anomaly scores maps predictions and ground-truths.
  3. Pixel-level traditional metric: requires pixel-level anomaly scores maps predictions and ground-truths.
  4. Frame-level traditional metric: only require frame-level anomaly scores; does not require pixel-level anomaly scores maps predictions and ground-truths.

Each prediction output and ground-truth annotation must be a JSON file that follows data structure defined in ssvad_metrics.data_schema.VADAnnotation. Pixel-level anomaly scores maps arrays must be provided using .tiff or .npy format, containing single-precision (32-bit) floating point values ranging from 0.0 to 1.0. For ground-truths, it can be same as pixel-level predictions, or using boolean values instead. But only .npy files supported if using boolean values (as .tiff requires 32-bit floating point values).

Installation

This metrics is available via PyPI.

pip install py-ssvad-metrics

Usage

  1. Prepare ground-truth JSON files and prediction JSON files (also the pixel anomaly score map linked files for pixel-level predictions and groundtruths).

    • ssvad_metrics.data_schema.VADAnnotation can be used for the data structure reference and validator of the JSON file.
    • JSON file examples are in the samples folder.
    • For UCSD Pedestrian 1 and 2 datasets, CUHK Avenue dataset, and Street Scene dataset, we provided scripts for converting ground-truth annotation files from Street Scene dataset provided by the paper (txt files, each row contains: <filename> <track_id> <x_center> <y_center> <width> <height>). Download link is provided in the paper http://www.merl.com/demos/video-anomaly-detection.
  2. Example usage for single groundtruth and prediction file pair:

    import ssvad_metrics
    result = ssvad_metrics.evaluate(
        "tests/gt_examples/Test001_gt.json",
        "tests/pred_examples/Test001_pred.json")
    
  3. Example usage for multiple groundtruth and prediction file pairs:

    import ssvad_metrics
    result = ssvad_metrics.accumulated_evaluate(
        "tests/gt_examples",
        "tests/pred_examples",
        gt_name_suffix="_gt",
        pred_name_suffix="_pred")
    
  4. For more examplles, see samples folder.

References

  1. B. Ramachandra, M. Jones and R. R. Vatsavai, "A Survey of Single-Scene Video Anomaly Detection," in IEEE Transactions on Pattern Analysis and Machine Intelligence, doi: 10.1109/TPAMI.2020.3040591.

License

GPL-3.0 License. Brought to open-source by PT Qlue Performa Indonesia.

Contributing

Feel free to contribute for improvements.

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

py-ssvad_metrics-0.3.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

py_ssvad_metrics-0.3.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file py-ssvad_metrics-0.3.0.tar.gz.

File metadata

  • Download URL: py-ssvad_metrics-0.3.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.9

File hashes

Hashes for py-ssvad_metrics-0.3.0.tar.gz
Algorithm Hash digest
SHA256 2616219a0f59dc07d2de129f7521228240aaaf6c8d98e75a9bc009151fdcf047
MD5 e3614a2cae1a5fcfc3c12e2a516f5539
BLAKE2b-256 c6a7ec3490b3b845782e83663d7030a5b530afd2c88b85f0a97924151317bcd2

See more details on using hashes here.

File details

Details for the file py_ssvad_metrics-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: py_ssvad_metrics-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.9

File hashes

Hashes for py_ssvad_metrics-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0e2022cfb99c9d273c63414fe7ea236d61c65562fbec4fc4acdd5c6876ac4d2
MD5 810107780de519797d65a87aeb7ab148
BLAKE2b-256 84a098eebacea0f6cf453f6eea6ecb62ca2b1f64032271d8ef303ea37012c099

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