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.1.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.1-py3-none-any.whl (7.4 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: suspectiq-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 60e21aa3fe0e08c8ff636383a28f90683e8de16549427136e67c90337a3ec94e
MD5 17c5572a34b525a97b994f57681afb1b
BLAKE2b-256 01c298bccf16cb963339275762a1fda7726a1785ab22f210b9691209692085bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: suspectiq-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16bb01baee694c562f274a196b50c838b19a96b7bea85b62d888becd614e405a
MD5 dce491cb8c93f85f1d1a3956c7433995
BLAKE2b-256 798636551695921fc21f0085cc82e0b3de792ace7ecdffe9a530726b69e425fd

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