AutoTwin-AI

🏭 AutoTwin-AI: Industrial Digital Twin, Video Telemetry & Structural Inspection Platform

CI/CD Pipeline Release: v2.0 Release: v1.0 Python 3.10+ PyTorch 2.x FastAPI React Three Fiber Tailwind CSS License: MIT

An end-to-end Industrial Digital Twin, Video Telemetry & Structural Inspection Platform for vehicle ladder-frame chassis assemblies and heavy crane fabrication (Girder 516).


🎬 v2.0: Factory Video Telemetry & Inspection POC

AutoTwin-AI v2.0 integrates real-world factory video telemetry to benchmark robotic welding against internal controller logs, monitor human manual fabrication, and enforce takt compliance across the Crane Gallery Assembly.

1. Robotic Welding Benchmarks (Girder 516 Seams)

The robotic welding videos serve as a controlled benchmark. Vision-derived metrics are compared against the robot’s internal controller logs to validate measurement accuracy:

Metric Girder 516 // Inner Corner Seam (170143) Girder 516 // Lower Flange Seam (171604)
Video Duration 228.52s (3m 48s) 268.03s (4m 28s)
Total Frames 6,860 @ 30.02 FPS 8,046 @ 30.02 FPS
Arc-On Duration 228.46s (100.0% Duty Cycle) 267.97s (100.0% Duty Cycle)
Spatter Tracking 36.87 sparks/frame (~1,106.9 sparks/s) 86.95 sparks/frame (~2,610.2 sparks/s)
Peak Spatter Burst 93 sparks (@ $t = 29.91$s) 297 sparks (@ $t = 257.71$s)
Process Stability Index 95.04% (34 frames $> 3\sigma$) 93.29% (54 frames $> 3\sigma$)
Controller Log Audit READY FOR LOG VERIFICATION READY FOR LOG VERIFICATION

Girder 516 Inner Seam Telemetry


2. Manual Fabrication & Grinding Telemetry (IMG_3601.MOV)

The ultimate deployment target is human fabrication workstations. Telemetry tracks manual tool engagement and correlates against standard fabrication cycle times:

Manual Fabrication Telemetry


πŸ“Έ v1.0: 3D Chassis Digital Twin & Spatial Inspection

1. AI Structural Joint Anomaly Detection & Reconstruction Heatmap

The trained PyTorch Convolutional Autoencoder reconstructs baseline nominal joints and flags physical anomalies via high-intensity residual error heatmaps ($|I - \hat{I}|$):

Autoencoder Reconstruction & Anomaly Heatmap


2. True Structural CAD Joint Mapping

High-density 3D spatial voxel clustering isolates structural load-bearing junctions from 361,174 CAD vertices (28000.obj):

Top-Down Orthographic Chassis Overview 3D Isometric CAD Perspective
Chassis Top View Isometric Overview
Macro Top-Down Joint Crop (1:1 Sensor Framing) High-Resolution Macro Perspective Detail
Macro Top Crop Macro Perspective

3. Synthetic Defect Injection (Weld Slag & Spatter)

Mathematical defect generator spawning irregular, distorted oxidic slag geometry directly onto the suspension weld seam for out-of-distribution anomaly validation:

Injected Structural Defect - Weld Slag


πŸ“Œ System Architecture

flowchart TD
    subgraph CADLayer ["1. CAD Ingestion & Clustering"]
        CAD["Vehicle Chassis (28000.obj - 361k Vertices)"]
        CLUSTER["3D Spatial Voxel Clustering"]
        CAD --> CLUSTER
    end

    subgraph SyntheticGen ["2. Blender OptiX Synthetic Engine (GPU)"]
        PBR["PBR Steel Shaders (Met: 0.85, Rough: 0.28)"]
        RANDOM["Domain Randomization (Light Angle, Sun Energy, Jitter)"]
        ANOMALY["Mathematical Slag / Weld Spatter Injector"]
        CLUSTER --> RANDOM
        PBR --> RANDOM
        RANDOM --> |~0.60s / frame| BASELINE["4,850+ Normal Renders (weld_normal_*.png)"]
        ANOMALY --> DEFECT_IMG["Defect Validation Frame (defective_test.png)"]
    end

    subgraph NeuralAI ["3. PyTorch Deep Autoencoder"]
        ENC["Conv2d Encoder (256x256 -> 16x16)"]
        DEC["ConvTranspose2d Decoder (16x16 -> 256x256)"]
        LOSS["MSE Reconstruction Loss (|Input - Recon|)"]
        BASELINE --> ENC --> DEC --> LOSS
    end

    subgraph BackendAPI ["4. FastAPI Gateway Service (:8000)"]
        API_JOINTS["GET /api/joints (Hotspots Database)"]
        API_INSPECT["POST /api/inspect (Live PyTorch Inference)"]
        STATIC["Static Asset Server (/static/cad, /static/assets)"]
        LOSS --> API_INSPECT
    end

    subgraph WebDashboard ["5. React + Three.js 3D Digital Twin (:5173)"]
        CANVAS["Three.js 3D Viewport (OrbitControls + CAD Gizmo)"]
        HOTSPOTS["Interactive Glowing 3D Hotspot Pins"]
        SIDEBAR["Live Telemetry, Anomaly Gauges & Residual Heatmaps"]
        RAYCAST["Click-to-Find CAD Coordinate Raycaster"]
        STATIC --> CANVAS
        API_JOINTS --> HOTSPOTS
        API_INSPECT --> SIDEBAR
    end

⚑ Key Capabilities


πŸ“Š Structural Joint Mapping Table

Preset Key Structural Joint Name 3D CAD Coordinates $(X, Y, Z)$ Local Vertices Structural Details
rear_sus_bracket (Defect Target) Rear Suspension Spring Perch [1.358, 0.220, 0.500] 18,395 Rear spring perch tower and damper hardpoints (Slag defect test target).
front_sus_bracket_left Front-Left Suspension Joint [-1.227, 0.140, 0.398] 29,947 A-arm suspension mount, cross-tube weld interface, and frame rail flange.
front_sus_bracket_right Front-Right Suspension Joint [-1.185, 0.140, -0.416] 26,822 Symmetrical right A-arm bracket and gusset stiffener.
engine_mount_crossmember Engine Mount Crossmember [-0.644, 0.100, -0.452] 21,557 Heavy-duty chassis mounting bracket with reinforcement gussets.

πŸ“‚ Project Directory Structure

AutoTwin-AI/
β”œβ”€β”€ .gitignore                                # Ignores large raw renders & CAD binaries
β”œβ”€β”€ README.md                                 # Complete project documentation & visual gallery
β”œβ”€β”€ requirements.txt                          # Python dependencies (PyTorch, FastAPI, Uvicorn, Trimesh)
β”‚
β”œβ”€β”€ backend/                                  # FastAPI Backend Service
β”‚   └── main.py                               # API Gateway, CAD asset server & live PyTorch inference
β”‚
β”œβ”€β”€ frontend/                                 # React + Three.js 3D Web Application
β”‚   β”œβ”€β”€ package.json                          # Node dependencies (@react-three/fiber, three, tailwindcss)
β”‚   β”œβ”€β”€ vite.config.js                        # Vite dev server configuration
β”‚   β”œβ”€β”€ tailwind.config.js                    # Cyber-industrial theme & palette
β”‚   β”œβ”€β”€ postcss.config.js
β”‚   β”œβ”€β”€ index.html                            # HTML entrypoint
β”‚   └── src/
β”‚       β”œβ”€β”€ App.jsx                           # Main dashboard, telemetry sidebar & heatmap modal
β”‚       β”œβ”€β”€ DigitalTwinViewer.jsx             # Three.js 3D Canvas, CAD Gizmo & Hotspot Raycaster
β”‚       β”œβ”€β”€ index.css                         # Custom cyberpunk glow styles & scanline animations
β”‚       └── main.jsx                          # React DOM entrypoint
β”‚
β”œβ”€β”€ src/                                      # Core pipeline modules & algorithms
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ data_gen.py                           # Multi-joint synthetic dataset generator
β”‚   β”œβ”€β”€ generate_autoencoder_dataset.py       # 5,000-sample domain-randomized baseline generator
β”‚   β”œβ”€β”€ data_gen_anomalous.py                 # Synthetic structural defect & weld slag injector
β”‚   β”œβ”€β”€ train_autoencoder_pytorch.py          # PyTorch Autoencoder training & heatmap visualizer
β”‚   β”œβ”€β”€ data.py                               # Dataset verification & corrupted file cleaner
β”‚   β”œβ”€β”€ generate_synthetic_data.py            # Multi-view reference renderer
β”‚   └── debug_blender.py                      # Blender environment diagnostics
β”‚
β”œβ”€β”€ docs/                                     # Documentation assets & showcase images
β”‚   └── assets/
β”‚       β”œβ”€β”€ 01_full_top_view_true_joint.png
β”‚       β”œβ”€β”€ 02_full_isometric_true_joint.png
β”‚       β”œβ”€β”€ 03_zoomed_true_joint_top_crop.png
β”‚       β”œβ”€β”€ 04_zoomed_true_joint_isometric_detail.png
β”‚       β”œβ”€β”€ defective_test.png
β”‚       └── reconstruction_analysis.png
β”‚
β”œβ”€β”€ cad_model/                                # Raw CAD assets (361k vertex chassis)
β”‚   └── 28000.obj
β”‚
β”œβ”€β”€ joint_inspection/                         # Structural joint inspection metadata
β”‚   └── joint_info.json                       # 3D spatial coordinates & cluster properties
β”‚
β”œβ”€β”€ models/                                   # Trained neural network artifacts
β”‚   β”œβ”€β”€ autoencoder_best.pth                  # Best model checkpoint (PyTorch weights - 9.38 MB)
β”‚   └── reconstruction_analysis.png
β”‚
└── synthetic_dataset/
    β”œβ”€β”€ autoencoder_baseline/                 # 4,855 domain-randomized normal baseline frames
    β”‚   └── manifest.json                     # Ground-truth camera/lighting metadata
    └── defective_test.png                    # Injected anomaly validation frame

πŸš€ Quickstart Guide

1. Environment Setup

# Clone the repository
git clone https://github.com/Arkz-Deepak/AutoTwin-AI.git
cd AutoTwin-AI

# Install Python dependencies (PyTorch with CUDA support)
pip install -r requirements.txt

# Install Frontend dependencies
cd frontend
npm install
cd ..

2. Run the Full-Stack Digital Twin Web Application

Start the FastAPI Backend (Port 8000):

cd backend
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload

(Interactive Swagger API docs available at http://localhost:8000/docs)

Start the React + Three.js Frontend (Port 5173):

cd frontend
npm run dev

(Open http://localhost:5173 in your browser)


3. Generate Synthetic Datasets (Blender OptiX Engine)

Generate 5,000 Baseline Images:

# Windows
$env:NUM_IMAGES="5000"
& "C:\Program Files\Blender Foundation\Blender 5.1\blender.exe" -b --python src/generate_autoencoder_dataset.py
# Ubuntu Linux
NUM_IMAGES=5000 blender -b --python src/generate_autoencoder_dataset.py

Inject a Physical Structural Defect (Weld Slag):

& "C:\Program Files\Blender Foundation\Blender 5.1\blender.exe" -b --python src/data_gen_anomalous.py

4. Train the Autoencoder & Generate Inspection Heatmaps

# Trains on GPU, evaluates reconstruction, and outputs 3-panel error heatmap
python src/train_autoencoder_pytorch.py

The script automatically generates models/reconstruction_analysis.png plotting:

  1. Original Frame: Input PBR industrial joint.
  2. Autoencoder Reconstruction: Learned clean topology.
  3. Anomaly Heatmap: Absolute pixel reconstruction residual ($ I - \hat{I} $).

πŸ›‘οΈ License

This project is licensed under the MIT License.