PhysAugNet 1.0.1
VQ-VQE powered augmentation for metal defect segmentation
Loading...
Searching...
No Matches
๐Ÿ”ง PhysAugNet

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)

pip install physaugnet

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:

python setup.py install

โš™๏ธ 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.