A self-healing SDK that detects and fixes data drift in deployed computer vision models using federated learning
Project description
FDAVRS — Federated Drift-Aware Vision Reliability System
FDAVRS is a PyTorch SDK that makes computer vision models self-healing. When deployed models encounter real-world distribution shift — fog, lighting changes, sensor noise, blur — they fail silently. FDAVRS detects this automatically and fixes the model at runtime, without labels and without retraining.
Install
pip install fdavrs
The Problem It Solves
A ResNet trained on clean images loses 30–40% accuracy when deployed in fog. No error is raised. The model just starts predicting wrong — silently. FDAVRS wraps the model and fixes this automatically.
Quick Start
import torch
import torchvision
from fdavrs import FDAVRS
# 1. Load your existing model — nothing changes here
base_model = torchvision.models.resnet18(pretrained=True)
# 2. Wrap it with FDAVRS — one line
model = FDAVRS(
client_model=base_model,
feature_layer='avgpool',
threshold=0.3
)
# 3. Calibrate once on clean data before deployment
model.fit(clean_data_loader)
# 4. Use exactly like a normal model during inference
for images in live_feed:
predictions = model.predict(images)
status = model.status()
print(status['action'])
# IDLE → model is healthy
# LOCAL_ADAPTATION → drift detected, fixing locally
# GLOBAL_CURE_APPLIED → fix retrieved from federated server
How It Works
When predict() is called, FDAVRS runs a 4-layer pipeline automatically:
1. Monitor Layer — A forward hook intercepts internal activations from the specified feature layer. It computes a Composite Drift Score: Score = (0.5 × Entropy) + (0.3 × Cosine Shift) + (0.2 × (1 - Confidence))
2. Decision Layer — Triage based on score:
- Score ≤ 0.3 →
IDLE(model is reliable) - 0.3 < Score ≤ 0.8 →
LOCAL_ADAPTATION(fix locally via TTA) - Score > 0.8 →
REQUEST_SERVER_CURE(ask federated server)
3. Adaptation Layer — BatchNorm running statistics (μ and σ²) are recalculated on the current batch using Test-Time Adaptation. No labels required. No architecture changes. No retraining.
4. Knowledge Vault — Successful fixes are packaged as weight deltas and drift signatures, then uploaded to a federated server so other devices with the same drift pattern benefit instantly.
API Reference
FDAVRS(client_model, feature_layer, threshold=0.3)
Wraps your model with drift monitoring and self-healing.
| Parameter | Type | Description |
|---|---|---|
client_model |
torch.nn.Module |
Your pretrained PyTorch model |
feature_layer |
str |
Layer name to monitor e.g. 'avgpool' for ResNet |
threshold |
float |
Drift sensitivity. Default 0.3 |
fit(dataloader) / fit_baseline(dataloader)
Calibrates the baseline using clean data. Call once before deployment.
predict(images) / forward(images)
Drop-in replacement for model(images). Drift detection and adaptation
happen automatically inside.
status()
Returns current SDK state:
{
"action": "IDLE | LOCAL_ADAPTATION | GLOBAL_CURE_APPLIED | ...",
"metrics": {
"score": 0.42,
"entropy": 0.81,
"shift": 0.23,
"confidence": 0.61
}
}
Compatible Models
Tested with ResNet-18, YOLOv11, DeepLabV3, and custom CNNs. Any PyTorch model with BatchNorm layers is supported.
Requirements
- Python ≥ 3.8
- PyTorch ≥ 1.9.0
- NumPy ≥ 1.19.0
- SciPy ≥ 1.7.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fdavrs-0.2.0.tar.gz.
File metadata
- Download URL: fdavrs-0.2.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0721701a9ac1fdb2a9c7e7ff5a838de386fe479a9f95930e1d993934908888b1
|
|
| MD5 |
df81f31c7d51f7b77c268c1254c9c649
|
|
| BLAKE2b-256 |
1b0e83686d1a975a77829d593f51ef8a9ea6c5938cb2798708c07ee864b27ca1
|
File details
Details for the file fdavrs-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fdavrs-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96c8832e1425a15d3c95ce6688ca5fc19c709abd85d93b83035a7f4cae507300
|
|
| MD5 |
7f83c4c46aeb525a7f86777d727f8bb7
|
|
| BLAKE2b-256 |
8f246fe250cb42e3da7b4e9c0511a413e580131cc9878eb0ac1d0814df8cf673
|