Skip to main content

Federated Drift-Aware Vision Reliability System SDK

Project description

FDAVRS Federated Drift-Aware Vision Reliability System

FDAVRS is a PyTorch-compatible SDK that acts as a self-healing wrapper for Computer Vision models.

When edge devices (such as drones or autonomous vehicles) encounter environmental drift (fog, snow, blur, lighting shifts), traditional models fail silently.

FDAVRS:

Detects drift in real time

Applies Unsupervised Test-Time Adaptation (TTA)

Heals the model mathematically

Securely packages adaptation weights for Federated Learning

Preserves the original model architecture

nstallation

Install the latest version from PyPI:

pip install fdavrs

Quick Start Guide:

Using FDAVRS is seamless. If you know how to use PyTorch, you already know how to use FDAVRS.

1️⃣ Import the SDK import torch import torchvision from fdavrs import FDAVRS 2️⃣ Wrap Your Model

Load your base vision model (e.g., ResNet or YOLO) and wrap it.

1. Load your standard pre-trained model

base_model = torchvision.models.resnet18(pretrained=True)

2. Wrap it with FDAVRS

robust_model = FDAVRS( client_model=base_model, feature_layer='avgpool', # Layer to monitor for drift threshold=0.3 # Drift score boundary ) 3️⃣ Calibrate the Baseline

Before deployment, the SDK analyzes clean images to establish a baseline embedding.

Pass a standard PyTorch DataLoader containing clean images

robust_model.fit(clean_data_loader) 4️⃣ Live Inference & Self-Healing

During live inference, FDAVRS operates automatically.

for images, labels in live_camera_feed:

# The SDK:
# - Calculates drift
# - Applies local adaptation if needed
# - Returns corrected predictions

predictions = robust_model.predict(images)

# Inspect SDK behavior
current_status = robust_model.status()
print(f"Action Taken: {current_status['action']}")

📖 API Reference Class: FDAVRS

The main wrapper class that orchestrates the Monitor, Brain, and Adapter layers.

🔧 Parameters client_model (torch.nn.Module)

The PyTorch vision model to make robust. The SDK freezes the feature extractor to prevent catastrophic forgetting.

feature_layer (str)

Name of the internal layer to attach a forward hook.

Examples:

'avgpool' → ResNet

'model.model.9' → YOLO

threshold (float, default = 0.3)

Drift score boundary:

Score < threshold → IDLE (Highly Reliable)

threshold < Score < 0.8 → LOCAL_ADAPTATION

Score > 0.8 → REQUEST_SERVER_CURE

core Methods fit(dataloader) Description

Calibrates the Monitor layer by computing a baseline reference embedding.

Parameters

dataloader (torch.utils.data.DataLoader) Clean, in-distribution images.

Returns

None

predict(images) / forward(images) Description

Main inference execution.

The SDK calculates a Composite Drift Score using:

Entropy

Cosine Shift

Confidence

If drift is detected:

BatchNorm layers switch to .train() mode

Running statistics (μ and σ²) are recalculated

5 adaptation iterations are performed

Corrected logits are returned

Parameters

images (torch.Tensor) Shape: (B, C, H, W)

Returns

logits (torch.Tensor)

status() Description

Returns the most recent decision taken by the Policy Engine.

Returns { "action": "IDLE | LOCAL_ADAPTATION | PASSIVE_DISCOVERY | REQUEST_SERVER_CURE", "metrics": { "score": float, "entropy": float, "shift": float, "confidence": float } } Architecture Overview

When predict() is called, FDAVRS executes a Teacher–Student Federated Learning protocol:

1️⃣ Monitor Layer

PyTorch forward hooks intercept internal activations

Calculates distribution shift

2️⃣ Decision Layer

Triage logic determines:

Whether the model is reliable enough to teach others

Or if it is blind and needs external correction

3️⃣ Local Adaptation Layer

If drift is recoverable:

Test-Time Adaptation (TTA) is triggered

BatchNorm statistics (μ, σ²) are recalculated

No permanent architecture changes occur

4️⃣ Knowledge Vault

Successful fixes are:

Stripped down to normalization weights (.pt)

Paired with a drift signature (.json)

Uploaded to Federated Server

Aggregated using FedAvg

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

fdavrs-0.1.2.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

fdavrs-0.1.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file fdavrs-0.1.2.tar.gz.

File metadata

  • Download URL: fdavrs-0.1.2.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for fdavrs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fd43be9fd5344ecf27350709224ac1308cade16085245fc15620aafd2a7bf5fb
MD5 ec99005f5569c23a83498389c61810e1
BLAKE2b-256 146185d6ba5b752fa3390e81fe9936862a423d8f64e511f3d1e37aed6c286ea5

See more details on using hashes here.

File details

Details for the file fdavrs-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fdavrs-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for fdavrs-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0cf13a8360e3194e307213d33cd3cc39cf82592cb75bbc46aa8c3a27a6aa5bfd
MD5 ad1cf725c2f90e1b49b21172439113db
BLAKE2b-256 614d27a9c84f285a63e322bfbe1cb2dc2f2581eef01a4d6d632f9ae70b131731

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