PhysAugNet is a research-grade Python toolkit designed to enhance few-shot or low-data industrial defect segmentation tasks by integrating:
- ๐ Vector-Quantized Variational Autoencoding (VQ-VAE) for generative reconstructions
- ๐ฅ Physically-inspired augmentations including thermal distortion and sensor grain noise
This augmentation pipeline improves generalization and robustness of deep segmentation models in industrial inspection workflows.
๐ Key Features
- โ
Compact and efficient VQ-VAE architecture with fast convergence
- โ
Dual-mode augmentation: thermal distortion + sensor grain noise
- โ
PhysAugNet Fusion: Combines VQ-VAE reconstructions with physics-inspired augmentations
- โ
CLI-based experiment control via YAML configuration
- โ
Fully modular and easy to plug into PyTorch pipelines
- โ
Lightweight design tailored for few-shot learning and resource-constrained environments
๐งฉ Computational Pipeline
| Module | Operation | Description |
| physaug/vqvae/train.py | Training | Trains VQ-VAE to learn latent quantized space |
| physaug/vqvae/infer.py | Inference | Reconstructs defect images for augmentation |
| physaug/augment/thermal.py | Augmentation | Applies thermal distortion to images |
| physaug/augment/grain.py | Augmentation | Applies synthetic sensor grain noise |
| physaug/augment/combined.py | Augmentation | Fuses VQ-VAE reconstructions with thermal + grain noise |
| infer_video.py | Video Inference | Performs VQ-VAE reconstructions on video frames |
| main.py | CLI Launcher | Unified command-line interface with argparse routing |
| configs/default.yaml | Config | Centralized configuration for all training and inference tasks |
๐ Project Structure
PhysAugNet/
โโโ physaug/
โ โโโ __init__.py
โ โโโ vqvae/
โ โ โโโ __init__.py
โ โ โโโ vqvae.py
โ โ โโโ train.py
โ โ โโโ infer.py
โ โโโ augment/
โ โ โโโ __init__.py
โ โ โโโ thermal.py
โ โ โโโ grain.py
โ โ โโโ combined.py
โ โโโ utils/
โ โโโ __init__.py
โ โโโ config.py
โ โโโ io.py
โ โโโ logger.py
โโโ configs/
โ โโโ default.yaml
โโโ examples/
โ โโโ notebook_demo.ipynb
โโโ physaugnet.egg-info/
โโโ main.py
โโโ train_vqvae.py
โโโ gen_vqvae.py
โโโ augment_thermal.py
โโโ augment_combined.py
โโโ infer_video.py
โโโ setup.py
โโโ requirements.txt
โโโ README.md
๐ฆ Installation
Option 1: Install from PyPI (Recommended)
Option 2: Clone the Repository
git clone https://github.com/Shantanu-Parmar/PhysAugNet
cd PhysAugNet
Create a virtual environment:
# Linux/Mac
python -m venv Physaug
source Physaug/bin/activate
# Windows
python -m venv Physaug
Physaug\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Or install the package:
โ๏ธ Setup
๐ Dataset Preparation
- Place training images under:
images/train/<class_name>/
- Place test images under:
images/test/
๐ Directory Creation
mkdir -p checkpoints/vqvae outputs/reconstructed outputs/augmented outputs/combined logs
๐ Config File
Edit configs/default.yaml to ensure all paths and parameters are correctly set for your environment.
๐ฅ Usage
Run from the root PhysAugNet/ directory using CLI:
๐ง VQ-VAE Training
python -m physaug.main train_vqvae --config configs/default.yaml
๐ง Image Reconstruction (VQ-VAE)
python -m physaug.main reconstruct --config configs/default.yaml
๐ก Thermal + Grain Augmentation
python -m physaug.main augment_tg --config configs/default.yaml
๐ Combined VQ-VAE + Physical Augmentations
python -m physaug.main augment_combined --config configs/default.yaml
๐ Video Frame Reconstruction (VQ-VAE)
python infer_video.py --video_path images/DEMO_INFERENCE.mp4 --output_path outputs/reconstructed_video.mp4 --checkpoint checkpoints/vqvae.pth --config configs/default.yaml
๐ Notebook Demonstration
Open the demo notebook to:
- Train the VQ-VAE
- Reconstruct images
- Apply augmentations
- Combine and visualize outputs
jupyter notebook examples/notebook_demo.ipynb
๐ค Output Structure
| Type | Path |
| Logs | logs/ (e.g., vqvae_trainer.log) |
| Checkpoints | checkpoints/vqvae/ |
| Reconstructed Images | outputs/reconstructed/ |
| Augmented Images | outputs/augmented/ |
| Combined Outputs | outputs/combined/ |
| Video Outputs | outputs/reconstructed_video.mp4 |
๐งช Applications
- Few-shot segmentation in manufacturing
- Synthetic data generation for metal defect detection
- Robustness to physical variations in sensor input
- Domain adaptation for industrial computer vision
๐ Citation
If you use PhysAugNet in your research, please cite:
@misc{parmar2025physaugnet,
author = {Shantanu Parmar},
title = {PhysAugNet: VQ-VAE and Physically-Inspired Augmentations for Metal Defect Segmentation},
year = {2025},
howpublished = {\url{https://github.com/Shantanu-Parmar/PhysAugNet}},
note = {GitHub repository}
}
๐ License
MIT License โ You are free to use, modify, and distribute this software with proper attribution.
ยฉ 2025 Shantanu Parmar. All rights reserved.