Inspiration

As a commissioning engineer, I managed construction and commissioned offshore platforms which included welding inspection of which Radiography was a critical component.

In traditional Non-Destructive Testing (NDT), operators manually interpret radiographic (X-ray) films of weld joints to locate defects like porosities, inclusions, and cracks. A missed defect can cause catastrophic failure, while a false reject delays construction by weeks. We wanted to build an autonomous agentic system that acts as an objective, standards-compliant co-pilot for NDT technicians and supervisors, streamlining the entire "Review-to-Repair" quality assurance lifecycle.

What it does

WeldInspector AI is an enterprise-grade NDT Quality Inspector powered by an autonomous reasoning agent. It automates radiographic film interpretation and compliance verification:

Scans Enhancement: Automatically applies Contrast Limited Adaptive Histogram Equalization (CLAHE) to low-contrast radiographs to make micro-discontinuities visible. Defect Detection: Deploys fine-tuned computer vision models (YOLO and RT-DETR) to pinpoint, classify, and size weld defects. Engineering Standard Enforcement: Passes defect dimensions through a dynamic rules engine that cross-references measurements against international standards (ASME B31.3, ASME VIII, AWS, API 1104) and custom client overrides.

Agentic Reasoning Loop: Powered by the Google Antigravity SDK, the agent orchestrates tools (running vision checks, querying compliance rules, logging reports) and generates a human-readable reasoning log explaining the pass/fail verdict.

Human-in-the-Loop (HITL) Workflow: Guides the inspection through a gated review lifecycle (Stage 0: AI Analysis -> Stage 1: Performer remarks & digital signature -> Stage 2: Supervisor approval & dual digital stamps). Dynamic PDF Generation: Generates stage-gated inspection reports on-the-fly, embedding visual bounding box mapping, abbreviations legend, and green digital signature stamps. Tamper-Evident Auditing: Logs all operations (user requests, cache hits, database clearing attempts) to an immutable ledger for audit compliance.

How we built it

We engineered WeldInspector AI from the ground up using a decoupled, production-ready stack:

Clean Architecture: Adheres strictly to Hexagonal Architecture (Ports & Adapters), separating the core business domain from network gateways and databases. Frontend Client: Built a premium dark-theme UI with Streamlit (featuring backdrop filters and custom HSL styling). It is a pure client with zero backend logic imports, communicating via REST API payloads. Backend Gateway: Powered by a high-performance FastAPI web server. Agent Orchestration: Built using the Google Antigravity SDK powered by the Gemini model. Vision Pipeline: Integrates YOLO and Hugging Face RT-DETR models for discontinuity detection. Resilient Dual Storage: Implemented a database adapter that writes to MongoDB Atlas (primary) and seamlessly fails over to local SQLite (data/local_ndt.db) when offline. PDF Construction: Uses the FPDF2 library on the server for stage-aware PDF compilation. Containerization: Packaged the entire stack into a multi-stage Dockerfile orchestrated via Docker Compose.

Challenges we ran into

Probabilistic AI vs. Deterministic Rules: Large Language Models (LLMs) are probabilistic and cannot reliably calculate mathematical compliance inequalities (such as checking if a defect exceeds thickness * 0.33). We resolved this by isolating the LLM's role to explanation and synthesis (Agent Reasoning Log) while leaving the binary pass/fail decision to a deterministic programmatic rule engine.

Offline Resiliency: Monolithic prototypes often crash when cloud database connections drop. We designed a dual database adapter that transparently switches database reads/writes to SQLite fallback on connection timeouts, implementing automatic schema migrations.

Stateless/Decoupled Image Sharing: Separating the frontend from the backend meant we couldn't share files via local paths. We solved this by passing base64-encoded annotated visuals in JSON payloads, allowing the backend to run in docker while the client remains completely lightweight.

Accomplishments that we're proud of

Training the generic RT-DETR model on 25000 weld radiographs over 25000 iterations. Production-Grade Architecture: Transitioning a basic, monolithic hackathon script into a decoupled, containerized Hexagonal design with 100% test coverage (all 28 unit/integration tests pass). Cryptographic Caching: Built a SHA-256 vision inference caching system (vision_cache) that bypasses GPU execution on duplicate radiographic scans, reducing API latencies to milliseconds. Stage-Gated Report Release: Implemented a realistic HITL approval workflow where the generated PDF document is updated and signed digitally at each stage on-the-fly.

What we learned

Agent Tool Isolation: agentic architectures are only as good as the tools provided. Separating tasks (defect detection vs. standard lookup) into distinct abstract ports makes the agentic logic clean, stable, and easily swappable. Vertex AI ADC Integration: Integrated keyless authentication using local Google Cloud Application Default Credentials (ADC) for Vertex AI access, avoiding exposed API keys in environment files.

What's next for WeldInspector AI

RAG-Powered Standards Directory: Implement Retrieval-Augmented Generation (RAG) to dynamically index entire PDF booklets of ASME B31.3 and API 1104, allowing the agent to query standard paragraphs directly instead of using pre-parsed rule files. Cloud-Native Deployment: Deploy the Docker container stack to Google Cloud Run, integrating Google Cloud VPN for secure network boundaries, and migrating the primary database to Google Cloud Firestore/AlloyDB. DVC Model Pipelines: Automate nightly DVC (Data Version Control) snapshotting of rejected radiographs to auto-trigger vision model retraining on human-corrected annotations. Analytics and scope for improvement : Analyse the parameters ipacting the quality of the weld type such as welding, technology, machines or humans involved, flux, electrodes used, ambient temperature, material grade and origin etc. This can help pipeline manufacturers performing continuous welds (LSAW, HSAW, etc) to look at the batches where the defects are understand the causes and rectify them.

Market size: As of 2026, the global Non-Destructive Testing (NDT) market sits between ~$36 Billion, scaling rapidly toward the $50B+ mark over the next decade growing at a rate of 10% YOY.

Built With

  • docker-&-docker-compose
  • fastapi
  • fpdf2
  • gcp-services-(aws-parity-layer)
  • gemini
  • google-antigravity-sdk
  • google-cloud-vertex-ai
  • graphviz
  • hugging-face-transformers
  • mongodb-atlas-(primary)
  • opencv-(cv2):
  • pydantic
  • python-(3.10+)
  • pytorch
  • sqlite-(fallback)
  • streamlit
  • ultralytics-yolo
  • uvicorn
Share this project:

Updates