Skip to content

kanhaiya-gupta/AM-QADF

Repository files navigation

AM-QADF Framework

AM-QADF (Additive Manufacturing Quality Assessment and Data Fusion) is a comprehensive Python framework for processing, analyzing, and visualizing multi-source additive manufacturing data. It provides a unified interface for querying diverse data sources, mapping signals to voxel domains, performing quality assessment, conducting advanced analytics, and deploying production-ready monitoring and control systems.

Python 3.9+ GitHub

๐ŸŽฏ Framework Overview

flowchart TD
    Hatching["๐Ÿ›ค๏ธ Hatching Paths<br/>Path Coordinates"] --> Query["Unified Query<br/>๐Ÿ” Query Interface"]
    Laser["โšก Laser Parameters<br/>Power & Speed"] --> Query
    CT["๐Ÿ”ฌ CT Scans<br/>Defect Detection"] --> Query
    ISPM["๐ŸŒก๏ธ In-Situ Monitoring<br/>Sensor Data"] --> Query
    Thermal["๐Ÿ”ฅ Thermal Data<br/>Heat Distribution"] --> Query
    Metadata["๐Ÿ“‹ Build Metadata<br/>Process Parameters"] --> Query
    
    Query --> MetadataExtract["Metadata Extraction<br/>๐Ÿ“Š Min, Max, Union, Statistics"]
    
    MetadataExtract --> Sync1["Synchronization<br/>โฐ Temporal & Spatial<br/>Align Points (Point-First)"]
    MetadataExtract --> Sync2["Synchronization<br/>โฐ Temporal & Spatial<br/>Align Points (Point-First)"]
    MetadataExtract --> Sync3["Synchronization<br/>โฐ Temporal & Spatial<br/>Align Points (Point-First)"]
    
    Sync1 --> Correct1["Correction & Calibration<br/>๐Ÿ“ Source 1"]
    Sync2 --> Correct2["Correction & Calibration<br/>๐Ÿ“ Source 2"]
    Sync3 --> Correct3["Correction & Calibration<br/>๐Ÿ“ Source N"]
    
    Correct1 --> Process1["Signal Processing<br/>๐Ÿ”ง Source 1"]
    Correct2 --> Process2["Signal Processing<br/>๐Ÿ”ง Source 2"]
    Correct3 --> Process3["Signal Processing<br/>๐Ÿ”ง Source N"]
    
    Process1 --> Grid1["Grid Creation<br/>๐ŸงŠ Source 1<br/>Union Bounds"]
    Process2 --> Grid2["Grid Creation<br/>๐ŸงŠ Source 2<br/>Union Bounds"]
    Process3 --> Grid3["Grid Creation<br/>๐ŸงŠ Source N<br/>Union Bounds"]
    
    Grid1 --> Map1["Signal Mapping<br/>๐ŸŽฏ Map to Grid 1"]
    Grid2 --> Map2["Signal Mapping<br/>๐ŸŽฏ Map to Grid 2"]
    Grid3 --> Map3["Signal Mapping<br/>๐ŸŽฏ Map to Grid N"]
    
    Map1 --> GridT1["Grid Transformation<br/>๐Ÿ“ฆ OpenVDB"]
    Map2 --> GridT2["Grid Transformation<br/>๐Ÿ“ฆ OpenVDB"]
    Map3 --> GridT3["Grid Transformation<br/>๐Ÿ“ฆ OpenVDB"]
    
    GridT1 --> Fusion["Data Fusion<br/>๐Ÿ”€ Multi-Source Fusion"]
    GridT2 --> Fusion
    GridT3 --> Fusion
    
    Fusion --> Quality["Quality Assessment<br/>โœ… Quality Evaluation"]
    
    Quality --> Validate["Validation & Benchmarking<br/>๐Ÿ”ฌ Verify Results"]
    Quality --> Analyze{"What to Do?<br/>๐Ÿ“‹"}
    
    Validate --> Analyze
    
    Analyze -->|Understand Patterns| Stats["Statistical Analysis<br/>๐Ÿ“ˆ Find Trends"]
    Analyze -->|Find Important Factors| Sensitivity["Sensitivity Analysis<br/>๐Ÿ”ฌ Key Parameters"]
    Analyze -->|Detect Problems| Anomaly["Anomaly Detection<br/>๐Ÿšจ Find Defects"]
    Analyze -->|Control Process| SPC["Statistical Process Control<br/>๐Ÿ“Š Control Charts"]
    Analyze -->|Optimize & Predict| Process["Process Optimization<br/>โš™๏ธ Predict & Improve"]
    Analyze -->|Test Scenarios| Virtual["Virtual Experiments<br/>๐Ÿงช Simulate Changes"]
    
    Stats --> Visualize["Visualize Results<br/>๐Ÿ“Š 3D Views & Charts"]
    Sensitivity --> Visualize
    Anomaly --> Visualize
    SPC --> Visualize
    Process --> Visualize
    Virtual --> Visualize
    
    Visualize --> Report["Generate Reports<br/>๐Ÿ“„ Summary & Insights"]
    
    Report --> Decision([Make Decisions<br/>โœ… Improve Manufacturing])
    
    %% Styling
    classDef input fill:#f5f5f5,stroke:#424242,stroke-width:3px
    classDef process fill:#e3f2fd,stroke:#0277bd,stroke-width:2px
    classDef parallel fill:#fff9c4,stroke:#f57f17,stroke-width:2px
    classDef decision fill:#fff3e0,stroke:#e65100,stroke-width:3px
    classDef analysis fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef output fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px
    classDef action fill:#ffccbc,stroke:#d84315,stroke-width:3px
    
    class Hatching,Laser,CT,ISPM,Thermal,Metadata input
    class Query,MetadataExtract,Fusion,Quality,Validate process
    class Sync1,Sync2,Sync3,Correct1,Correct2,Correct3,Process1,Process2,Process3,Grid1,Grid2,Grid3,Map1,Map2,Map3,GridT1,GridT2,GridT3 parallel
    class Analyze decision
    class Stats,Sensitivity,Anomaly,SPC,Process,Virtual analysis
    class Visualize,Report output
    class Decision action
Loading

Workflow Overview

The AM-QADF framework follows a point-first pipeline: align and process points before voxelization, then map to grids. Each data source is processed in parallel through the same stages before fusion:

  1. Query & Metadata Extraction: Query data from multiple sources (hatching paths, laser parameters, CT scans, in-situ monitoring, thermal data) and extract metadata including min/max values, union bounds, and statistical summaries for each source.

  2. Synchronization (Point-First): Temporally and spatially align points (and signals) to a common coordinate system and time reference (e.g. bbox-corner transform, layer/time mapping). Alignment is done on points before voxelization.

  3. Correction & Calibration: Apply geometric distortion correction and calibration to aligned point/signal data (noise reduction, calibration, distortion models).

  4. Signal Processing: Process signals and reduce noise (smoothing, outlier detection, optional FFT filtering) on the corrected data.

  5. Per-Source Grid Creation: Create voxel grids using union bounds—the union of aligned data bounding boxes from synchronization. Grid bounds can also be derived from STL or source-specific bounds when provided.

  6. Per-Source Signal Mapping: Map processed signals to their respective grids using interpolation methods (Nearest Neighbor, Linear, IDW, KDE, RBF).

  7. Grid Transformation (if required): Optionally apply grid-level transformation (e.g. OpenVDB resampling to target transform/bbox) when grid alignment or resampling is needed after signal mapping.

  8. Data Fusion: Fuse all grids into a unified voxel domain.

  9. Quality Assessment & Analysis: Assess quality, perform analytics, detect anomalies, and visualize results.

โœจ Key Features

๐Ÿ” Multi-Source Data Integration

  • Unified Query Interface: Access multiple data sources (hatching paths, laser parameters, CT scans, in-situ monitoring, thermal data)
  • Metadata Extraction: Compute and store metadata (min, max, union bounds, statistical summaries) for each data source
  • Per-Source Processing: Process each data source independently through its own pipeline before fusion
  • Data Fusion: Combine processed data from disparate sources into a coherent voxel domain
  • Synchronization: Temporal and spatial alignment of each grid relative to Ground Truth (Build System)

๐ŸงŠ Voxel Domain Processing

  • Per-Source Voxelization: Create separate voxel grids for each data source with bounds from STL, union, or source-specific coordinates
  • Signal Mapping: Interpolate signals onto their respective grids using multiple methods (Nearest Neighbor, Linear, IDW, KDE, RBF)
  • Multi-Resolution: Support for adaptive and multi-resolution grids
  • Per-Source Correction: Apply geometric distortion correction and calibration to each grid independently
  • Per-Source Signal Processing: Process signals and reduce noise for each grid independently

โœ… Quality Assessment & Validation

  • Completeness: Assess data coverage and identify gaps
  • Signal Quality: Evaluate signal-to-noise ratios and data quality
  • Alignment Accuracy: Validate coordinate system alignments
  • Validation & Benchmarking: Compare framework results with MPM systems, validate against ground truth
  • Performance Benchmarking: Measure processing time, memory usage, and data volume reduction

๐Ÿ“Š Advanced Analytics

  • Statistical Analysis: Descriptive statistics, correlation, trends, patterns
  • Sensitivity Analysis: Sobol, Morris, and other sensitivity methods
  • Virtual Experiments: Parameter optimization and design of experiments
  • Process Analysis: Sensor analysis, parameter optimization
  • Process Optimization & Prediction: Early defect prediction, time-series forecasting, multi-objective optimization
  • Model Tracking: Model registry, performance tracking, drift detection

๐Ÿ“ˆ Statistical Process Control (SPC)

  • Control Charts: X-bar, R, S, Individual, Moving Range charts with adaptive limits
  • Process Capability: Cp, Cpk, Pp, Ppk indices and rating
  • Multivariate SPC: Hotelling T², PCA-based monitoring
  • Control Rules: Western Electric and Nelson rules for out-of-control detection
  • Baseline Management: Calculate and update control limits from historical data

๐Ÿšจ Anomaly Detection

  • Multiple Algorithms: Statistical, clustering, ML-based, rule-based detectors
  • Ensemble Methods: Combine multiple detectors for robust detection
  • Voxel-Level Analysis: Detect anomalies in spatial data

๐Ÿ“ก Real-Time Monitoring & Streaming

  • Data Streaming: Kafka integration for real-time data consumption
  • Incremental Processing: Process streaming data incrementally to update voxel grids
  • Buffer Management: Temporal windows and buffer management for streaming data
  • Live Dashboards: Real-time quality dashboards with WebSocket updates
  • Alert System: Multi-channel alert generation and management (Email, SMS, Dashboard)
  • Threshold Management: Dynamic threshold checking (absolute, relative, rate-of-change, SPC-based)
  • Health Monitoring: System and process health monitoring with health scores

๐Ÿญ Production Deployment & Industrial Integration

  • Production Configuration: Environment-based configuration management with secrets management
  • Scalability: Horizontal and vertical scaling with load balancing and auto-scaling
  • Fault Tolerance: Retry policies, circuit breakers, and graceful degradation
  • Resource Monitoring: System and process resource monitoring (CPU, memory, disk, network)
  • Performance Tuning: Profiling, optimization, and tuning recommendations
  • MPM Integration: Integration with Manufacturing Process Management systems
  • Equipment Integration: Connection to manufacturing equipment (3D printers, sensors, PLCs)
  • API Gateway: REST API for industrial access with versioning and middleware
  • Authentication & Authorization: JWT, OAuth2, API key authentication with RBAC

๐ŸŽจ Visualization

  • 3D Rendering: Interactive 3D visualization of voxel data using PyVista
  • Multi-Resolution Viewing: Navigate different levels of detail
  • Jupyter Widgets: Interactive widgets for notebooks

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/kanhaiya-gupta/AM-QADF.git
cd AM-QADF

# Install dependencies
pip install -r requirements.txt

# Install the package
pip install -e .

Basic Usage

The framework processes each data source independently through the complete pipeline:

from src.infrastructure.database import get_connection_manager
from am_qadf.query import UnifiedQueryClient
from am_qadf.voxel_domain import VoxelDomainClient

# Initialize connection manager
manager = get_connection_manager(env_name="development")
mongodb_client = manager.get_mongodb_client()

# Create query client
query_client = UnifiedQueryClient(mongo_client=mongodb_client)

# Create voxel domain client (orchestrates the workflow)
voxel_client = VoxelDomainClient(
    unified_query_client=query_client,
    base_resolution=1.0
)

# The framework automatically:
# 1. Queries data from multiple sources
# 2. Extracts metadata (min, max, union, statistics) for each source
# 3. Synchronizes points (temporal & spatial alignment, point-first)
# 4. Corrects and calibrates aligned data
# 5. Processes signals (noise reduction, smoothing)
# 6. Creates grids from aligned bounds
# 7. Maps signals to their respective grids
# 8. Optionally applies grid transformation (OpenVDB)
# 9. Fuses all grids into unified voxel domain

# Execute complete workflow
fused_grid = voxel_client.execute_complete_workflow(
    model_id="my_model",
    sources=['hatching', 'laser', 'ct'],
    interpolation_method='linear'
)

# Visualize
from am_qadf.visualization import VoxelRenderer
renderer = VoxelRenderer()
renderer.render(fused_grid, signal_name='power')

๐Ÿณ Docker Setup

AM-QADF includes Docker Compose configuration for easy development:

# Start MongoDB and Spark services
cd docker
docker-compose -f docker-compose.dev.yml up -d

# Check services
docker-compose -f docker-compose.dev.yml ps

See Infrastructure Documentation for details.

๐Ÿ“š Documentation

๐Ÿ—๏ธ Project Structure

AM-QADF/
├── src/
│   ├── am_qadf/              # Core framework (database-agnostic)
│   │   ├── core/              # Core domain entities
│   │   ├── query/             # Query clients
│   │   ├── voxelization/      # Voxel grid creation
│   │   ├── signal_mapping/    # Signal interpolation
│   │   ├── synchronization/   # Temporal/spatial alignment
│   │   ├── correction/        # Geometric distortion correction
│   │   ├── processing/        # Signal processing & noise reduction
│   │   ├── fusion/            # Multi-modal data fusion
│   │   ├── quality/           # Quality assessment
│   │   ├── analytics/         # Advanced analytics
│   │   │   ├── spc/           # Statistical Process Control
│   │   │   ├── process_analysis/  # Process analysis & optimization
│   │   │   │   ├── prediction/    # Early defect prediction, forecasting
│   │   │   │   └── model_tracking/ # Model registry & performance tracking
│   │   │   └── ...
│   │   ├── validation/        # Validation & benchmarking
│   │   ├── anomaly_detection/ # Anomaly detection
│   │   ├── streaming/         # Real-time data streaming
│   │   ├── monitoring/        # Real-time monitoring & alerts
│   │   ├── deployment/        # Production deployment utilities
│   │   ├── integration/       # Industrial system integration
│   │   ├── visualization/     # 3D visualization
│   │   └── voxel_domain/      # Voxel domain orchestrator
│   │
│   └── infrastructure/        # Infrastructure layer (database connections)
│       ├── config/            # Configuration management
│       └── database/         # Database connection management
│
├── docs/
│   ├── AM_QADF/              # Framework documentation
│   ├── Infrastructure/       # Infrastructure documentation
│   ├── Notebook/             # Interactive notebooks documentation
│   └── Tests/                # Testing documentation
│
├── notebooks/                # Interactive Jupyter notebooks (28 notebooks)
├── examples/                 # Example scripts
├── tests/                    # Test suite (unit, integration, performance, e2e)
├── docker/                   # Docker configuration
└── data_generation/          # Data generation utilities

๐Ÿ”ง Requirements

  • Python: 3.9 or higher
  • MongoDB: 7.0+ (for data storage)
  • Optional: Apache Spark (for distributed processing)
  • Optional: Kafka (for real-time streaming)
  • Optional: Redis (for caching and queue management)

Core Dependencies

  • numpy - Numerical computing
  • scipy - Scientific computing
  • pandas - Data manipulation
  • pymongo - MongoDB client

Optional Dependencies

  • pyspark - Apache Spark (distributed processing)
  • scikit-learn - Machine learning algorithms
  • pyvista - 3D visualization
  • matplotlib - Plotting
  • seaborn - Statistical visualization
  • kafka-python or confluent-kafka - Kafka integration (for streaming)
  • redis - Redis client (for caching)
  • websockets - WebSocket support (for live dashboards)
  • psutil - System resource monitoring
  • requests - HTTP client (for API integration)
  • PyJWT - JWT authentication support

๐Ÿงช Testing

# Run all tests
pytest

# Run specific test category
pytest tests/unit/
pytest tests/integration/
pytest tests/performance/

# Run with coverage
pytest --cov=src/am_qadf --cov-report=html

See Testing Documentation for detailed testing guides.

๐Ÿค Contributing

Contributions are welcome! We appreciate your interest in improving AM-QADF. Here's how you can contribute:

Getting Started

  1. Fork the Repository - Create your own fork of AM-QADF
  2. Create a Feature Branch - Create a branch for your feature or bug fix
  3. Make Your Changes - Follow our coding standards and guidelines
  4. Write Tests - Add tests for new features and ensure existing tests pass
  5. Submit a Pull Request - Open a PR with a clear description of your changes

Contribution Guidelines

  • Code Style: Follow PEP 8, use type hints, and write comprehensive docstrings
  • Testing: Write tests for new features and maintain test coverage
  • Documentation: Update relevant documentation and add examples for new features
  • Commit Messages: Use clear, descriptive commit messages

Areas for Contribution

  • ๐Ÿ› Bug fixes and improvements
  • โœจ New features and modules
  • ๐Ÿ“š Documentation improvements
  • ๐Ÿงช Test coverage enhancements
  • ๐ŸŽจ Code quality and refactoring
  • ๐Ÿš€ Performance optimizations

For detailed guidelines, please see the Contributing Guide.

๐Ÿ“„ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

This is a strong copyleft license that ensures:

  • โœ… Anyone can use, modify, and distribute the framework
  • โœ… All modifications and extensions must also be open source under AGPL-3.0
  • โœ… If used in a network/web service, the source code must be made available
  • โœ… The framework and all derivatives remain free and open

Why AGPL-3.0? This license ensures that improvements and extensions to the AM-QADF framework remain open and accessible to the research and manufacturing community, promoting collaborative development and preventing proprietary forks.

For the full license text, see LICENSE file.

๐Ÿ”— Related Resources

๐Ÿ“ง Contact

For questions, issues, or contributions, please open an issue on the GitHub repository.


AM-QADF - Empowering Additive Manufacturing through Quality Assessment and Data Fusion