Skip to main content

Video anomaly / suspicious-activity detection using ResNet50 + Temporal Attention.

Project description

SuspectIQ

Video anomaly / suspicious-activity detection in one line.

Installation

pip install .          # from the cloned repo
# or, once published:
pip install suspectiq

Requirements: Python ≥ 3.9, TensorFlow ≥ 2.12, OpenCV, NumPy.


Quick start

from suspectiq import SuspectIQ

# Load once – models are lazy-loaded on the first predict() call
detector = SuspectIQ("best_model_ucf.keras")

result = detector.predict("clip.mp4")

print(result.label)       # "NORMAL" or "SUSPICIOUS"
print(result.confidence)  # confidence for the predicted class
print(result.probability) # raw model probability (SUSPICIOUS)

API reference

SuspectIQ(model_path, threshold=0.325, num_frames=16, img_size=224)

Parameter Type Default Description
model_path str Path to the .keras temporal model file.
threshold float 0.325 Decision boundary for SUSPICIOUS classification.
num_frames int 16 Frames sampled per clip.
img_size int 224 Frame resize dimension (height = width).

detector.predict(video_path) → PredictionResult

Classify a single video file.

result = detector.predict("footage.mp4")

Returns a PredictionResult with:

  • result.label"NORMAL" or "SUSPICIOUS"
  • result.confidence – confidence for the winning class (0 – 1)
  • result.probability – raw SUSPICIOUS probability from the model

detector.predict_batch(video_paths) → list[PredictionResult | None]

Classify multiple videos. Failed videos return None.

results = detector.predict_batch(["a.mp4", "b.mp4", "c.mp4"])
for path, result in zip(paths, results):
    if result:
        print(f"{path}: {result.label} ({result.confidence:.2%})")

detector.set_threshold(threshold)

Adjust sensitivity at runtime without reloading models.

detector.set_threshold(0.5)   # stricter – fewer SUSPICIOUS flags
detector.set_threshold(0.2)   # more sensitive – more SUSPICIOUS flags

PredictionResult

@dataclass
class PredictionResult:
    label: str        # "NORMAL" | "SUSPICIOUS"
    confidence: float # confidence for the predicted class
    probability: float # raw model output (P(SUSPICIOUS))

Model architecture

Stage Component
Frame sampling OpenCV – first num_frames frames
Feature extractor ResNet50 (ImageNet, frozen)
Temporal model Custom model with TemporalAttention
Output Sigmoid → threshold → label

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

suspectiq-1.0.2.tar.gz (7.4 MB view details)

Uploaded Source

Built Distribution

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

suspectiq-1.0.2-py3-none-any.whl (7.4 MB view details)

Uploaded Python 3

File details

Details for the file suspectiq-1.0.2.tar.gz.

File metadata

  • Download URL: suspectiq-1.0.2.tar.gz
  • Upload date:
  • Size: 7.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for suspectiq-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ca81c50ce41265f8b508e7e04a238235df2f94bdb38bd1b0b616d19552146372
MD5 3b3b10133b1d72896fd599ed3c007139
BLAKE2b-256 04e669bd7e244fedd10030e5c37511e41d11e32e6dac5a3b0cc4bcf7f75762c9

See more details on using hashes here.

File details

Details for the file suspectiq-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: suspectiq-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for suspectiq-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2cfbcabf68f60c9e18615265c12521c815883cae9588b863edcfced780d278fc
MD5 4966bc3a698eed94a3704a996963cd72
BLAKE2b-256 5aae646a34c7d8770eef59fd5ba69dae88b847de232706ba2a0b36d029275e84

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