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.0.tar.gz (6.6 kB 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.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for suspectiq-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a8ee217e0855ed3d50bbc08c96de7c0db087b4a758ea31be6b19c87d14888916
MD5 734a444dac1a5639aef3bf81ebcecab4
BLAKE2b-256 6f98dc5df655adbd73cd4fc5cef951fa62320adebaee9539c88e2394bc9ac414

See more details on using hashes here.

File details

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

File metadata

  • Download URL: suspectiq-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f0b561697b99067d7765b0fb925edac134f0ca6881783bff8fa167e5bd810f3
MD5 330808d4cbce2605fdd4399637f53e4a
BLAKE2b-256 9620d8dd198dc953cfd05e6d07c3fd75f31d9c4b29493569f0177eab8db35e90

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