Metadata-Version: 2.4
Name: wifi-activity-recognition
Version: 0.1.0
Summary: A comprehensive Python package for human activity recognition using WiFi CSI and computer vision
Author-email: Diogo Ribeiro <dfr@esmad.ipp.pt>
Maintainer-email: Diogo Ribeiro <dfr@esmad.ipp.pt>
License: MIT
Project-URL: Homepage, https://github.com/diogoribeiro7/wifi-csi-activity-recognition
Project-URL: Documentation, https://wifi-activity-recognition.readthedocs.io/
Project-URL: Repository, https://github.com/diogoribeiro7/wifi-csi-activity-recognition.git
Project-URL: Bug Tracker, https://github.com/diogoribeiro7/wifi-csi-activity-recognition/issues
Project-URL: Changelog, https://github.com/diogoribeiro7/wifi-csi-activity-recognition/blob/main/CHANGELOG.md
Keywords: wifi,csi,activity-recognition,computer-vision,machine-learning,iot,sensing,human-activity
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Classifier: Topic :: System :: Hardware :: Hardware Drivers
Classifier: Topic :: Communications
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS.md
Requires-Dist: numpy>=1.19.0
Requires-Dist: scipy>=1.5.0
Requires-Dist: pandas>=1.1.0
Requires-Dist: scikit-learn>=0.24.0
Requires-Dist: opencv-python>=4.0.0
Requires-Dist: matplotlib>=3.3.0
Requires-Dist: seaborn>=0.11.0
Requires-Dist: tqdm>=4.50.0
Requires-Dist: pyyaml>=5.4.0
Requires-Dist: h5py>=3.0.0
Requires-Dist: requests>=2.25.0
Requires-Dist: click>=8.0.0
Requires-Dist: networkx>=2.5
Requires-Dist: PyWavelets>=1.1.1
Provides-Extra: torch
Requires-Dist: torch>=1.8.0; extra == "torch"
Requires-Dist: torchvision>=0.9.0; extra == "torch"
Requires-Dist: torchaudio>=0.8.0; extra == "torch"
Provides-Extra: tensorflow
Requires-Dist: tensorflow>=2.4.0; extra == "tensorflow"
Provides-Extra: dev
Requires-Dist: pytest>=6.0.0; extra == "dev"
Requires-Dist: pytest-cov>=2.10.0; extra == "dev"
Requires-Dist: pytest-mock>=3.3.0; extra == "dev"
Requires-Dist: black>=21.0.0; extra == "dev"
Requires-Dist: flake8>=3.8.0; extra == "dev"
Requires-Dist: isort>=5.0.0; extra == "dev"
Requires-Dist: mypy>=0.812; extra == "dev"
Requires-Dist: pre-commit>=2.10.0; extra == "dev"
Requires-Dist: sphinx>=4.0.0; extra == "dev"
Requires-Dist: sphinx-rtd-theme>=0.5.0; extra == "dev"
Requires-Dist: nbsphinx>=0.8.0; extra == "dev"
Requires-Dist: jupyter>=1.0.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=4.0.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=0.5.0; extra == "docs"
Requires-Dist: nbsphinx>=0.8.0; extra == "docs"
Requires-Dist: myst-parser>=0.15.0; extra == "docs"
Provides-Extra: all
Requires-Dist: wifi-activity-recognition[dev,docs,torch]; extra == "all"
Dynamic: license-file

# WiFi Activity Recognition

[![PyPI version](https://img.shields.io/pypi/v/wifi-activity-recognition.svg)](https://pypi.org/project/wifi-activity-recognition/)
[![CI](https://github.com/diogoribeiro7/wifi-csi-activity-recognition/actions/workflows/ci.yml/badge.svg)](https://github.com/diogoribeiro7/wifi-csi-activity-recognition/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

WiFi Activity Recognition is a Python package for CSI-based human activity recognition. It provides a hardware abstraction layer, preprocessing and feature utilities, train/evaluate/predict workflows, and research modules for adaptation and federated learning.

## Features

- Hardware abstraction for currently registered readers: Intel 5300, ESP32, Atheros AR9300, and Qualcomm.
- Model implementations including CNN2D, CNN3D, ResNet, Transformer, and Vision Transformer variants.
- CLI workflows for collection, training, prediction, evaluation, streaming, benchmarking, export, and visualization.
- Research utilities for domain adaptation, few-shot learning, and federated training.
- Dataset helpers and a PyTorch-based training loop for reproducible experiments.

## Installation

The package supports Python 3.10 through 3.12.

```bash
pip install wifi-activity-recognition
```

For local development:

```bash
git clone https://github.com/diogoribeiro7/wifi-csi-activity-recognition.git
cd wifi-csi-activity-recognition
pip install -e .[dev,docs]
```

If you plan to train or run inference, install a compatible PyTorch build for your platform as well.

See [docs/installation.md](docs/installation.md) for environment and hardware notes.

## Quickstart

Create a small synthetic dataset:

```bash
python - <<'PY'
import numpy as np

rng = np.random.default_rng(42)
data = rng.random((24, 1, 8, 8), dtype=np.float32)
labels = rng.integers(0, 2, size=24, dtype=np.int64)

np.save("demo_data.npy", data)
np.save("demo_labels.npy", labels)
PY
```

Train a model:

```bash
python -m wifi_activity_recognition.cli train \
  --data demo_data.npy \
  --labels demo_labels.npy \
  --model cnn2d \
  --hardware esp32 \
  --epochs 1 \
  --batch-size 4 \
  --output demo_model.pt
```

Evaluate it:

```bash
python -m wifi_activity_recognition.cli evaluate \
  --model demo_model.pt \
  --data demo_data.npy \
  --labels demo_labels.npy \
  --hardware esp32
```

See [docs/quickstart.md](docs/quickstart.md) for a slightly fuller walkthrough.

## Python API

### Train a model

```python
import numpy as np

from wifi_activity_recognition.datasets import Dataset, split_dataset
from wifi_activity_recognition.models import create_model
from wifi_activity_recognition.training import Trainer

data = np.load("demo_data.npy")
labels = np.load("demo_labels.npy")
train, val, test = split_dataset(data, labels, val_ratio=0.2, test_ratio=0.2)
dataset = Dataset(train=train, val=val, test=test)

model = create_model("cnn2d", num_classes=len(dataset.classes), in_channels=1)
trainer = Trainer(model=model, dataset=dataset, batch_size=4)
trainer.train(epochs=1)
trainer.save_model("demo_model.pt")
```

### Run packet-level inference

```python
from wifi_activity_recognition.inference import ActivityRecognizer
from wifi_activity_recognition.models import load_model
from wifi_activity_recognition.utils.io import load_csi_data

model = load_model("demo_model.pt")
recognizer = ActivityRecognizer(model)
packets = load_csi_data("captured_packets.json")

label, confidence = recognizer.predict(packets[0])
print(label, confidence)
```

### Stream from hardware

```python
from wifi_activity_recognition.hardware import CSIReader

reader = CSIReader("esp32", {"sampling_rate": 100, "channel": 6})

with reader:
    for packet in reader.stream():
        print(packet.shape)
        break
```

## Hardware Status

The current registry-backed CLI and factory surface expose the hardware drivers that are actually registered at import time. At the moment that means Intel 5300, ESP32, Atheros AR9300, and Qualcomm. Broadcom and MediaTek are not enabled in the active registry yet.

Use the CLI to inspect the current environment:

```bash
python -m wifi_activity_recognition.cli info --hardware all
```

## Documentation

- [Installation Guide](docs/installation.md)
- [Quickstart](docs/quickstart.md)
- [Hardware Setup](docs/hardware_setup.md)
- [Training Guide](docs/training_guide.md)
- [Deployment Guide](docs/deployment.md)
- [API Reference](docs/api_reference.md)

## License

Distributed under the [MIT License](LICENSE).
