ðĪ Internal AI Models Guide
Complete guide to all AI models in the Internal AI Models repository for technical drawing analysis.
Last Updated: June 2026 | Total Models: 11 | Primary Framework: LitServe (9 models)
What is This Repository?
Purpose
The Internal AI Models repository is a Python monorepo that hosts specialized AI models for analyzing technical engineering drawings. These drawings contain:
- Dimension specifications
- Welding symbols
- Material information
- Surface finish specifications
- Tolerance requirements
- Part tables and lists
Real-World Use Case
When an engineer scans a technical drawing (blueprint), these AI models analyze it to automatically extract structured information like:
- "This part should be welded with a fillet weld"
- "Surface roughness should be Ra 3.2 Ξm"
- "Maximum thickness variation: Âą0.5mm"
- "List of 45 parts required for assembly"
Architecture Overview
High-Level Pipeline
Key Technology Stack
PyTorch, YOLOX, EfficientNet-B2, BERT, Vision Encoder-Decoder
LitServe (9 models), FastAPI (2 models)
OpenCV, PIL/Pillow, Pydantic validation
1. canvas_ocr - Technical Drawing OCR
What it does
Extracts dimension tolerances, fit tolerances, beveling specifications, and special instructions from technical drawings.
Architecture (4-Stage OCR Pipeline)
Detection Classes (6 types)
- c_beveling - Chamfered edge specifications
- dimensional_tolerance - Size variation limits
- fit_tolerance - Assembly fit specifications
- r_beveling - Rounded edge specifications
- special_instructions - Custom manufacturing notes
- specified_tolerance - Explicitly marked tolerance values
Why 4 Pipeline Stages?
- Detection: YOLOX finds where the tolerance specs are
- Angle Classification: Engineers write at different angles on the drawing
- Text Recognition: BERT reads the tolerance values
- Post-processing: Validate format and extract numbers
How Canvas_OCR Works (Example)
- Input: Drawing with "Âą 0.05" marking
- YOLOX: Detects box at [100, 200, 300, 250] as "dimensional_tolerance"
- Angle Classifier: Says text is rotated 90°
- Rotation: Rotate image region to 0° (horizontal)
- BERT: Reads "Âą 0.05"
- Post-process: Parse to value=0.05, unit=unspecified, type=dimensional
- Output: JSON with tolerance_value: 0.05
Model Details
- YOLOX Variant: YOLOX-s (small, fast)
- Angle Classifier: MobileNet-v2 (4 classes)
- Text Recognition: BERT-base
- Input Size: 2048Ã2048
- Output: JSON with tolerance specs
- Speed: 40ms (GPU), 400ms (CPU)
Tolerance Format Examples
- Bilateral: "Âą0.05" (Âą0.05mm)
- Unilateral: "+0.10/-0.00" (positive/negative)
- Limits: "2.00-2.10" (max-min)
- Percentage: "Âą5%" (percentage tolerance)
Framework: LitServe | Speed: 40ms (GPU) | Type: Multi-stage symbol + OCR extraction
2. deep_feature_v2 - Deep Feature Extraction
What it does
Converts a technical drawing image into a 1024-dimensional feature vector for similarity matching and retrieval.
Architecture (Detailed)
EfficientNet-B2 Explained
- EfficientNet = Family of neural networks optimized for efficiency
- B2 = Medium-sized variant (faster than B3, larger than B0)
- It's a CNN (Convolutional Neural Network) that extracts visual features
- Pre-trained on ImageNet + fine-tuned for engineering drawings
Key Characteristics
- Input: Any size image (auto-resized to 224Ã224)
- Output: Always 1024 numbers (suitable for vector databases)
- Speed: Very fast (GPU: ~10ms, CPU: ~100ms)
- Use Case: Similarity search, duplicate detection
- Special Feature: Dynamic Batching (max batch size: 4)
Framework: LitServe | Speed: 10ms (GPU)
3. welding_symbol_detection - Welding Symbol Detection
What it does
Detects and classifies all welding symbols in a technical drawing. Uses YOLOX object detection to identify the location and type of welding symbols automatically.
Architecture
How YOLOX Works
- Grid Division: Image divided into 52Ã52 grid cells
- Per-Cell Prediction: Each cell predicts if there's a symbol inside it
- Bounding Box: If symbol detected, predict exact location and size
- Classification: Which type of weld symbol is it? (6 classes)
- Confidence: How sure are we? (0-1 probability)
- NMS: Remove duplicate detections of same symbol
Common Welding Symbol Types (6 Classes)
- Fillet weld - Corner/edge join with triangular cross-section
- Butt weld - Face-to-face joint
- Groove weld - V-shaped or U-shaped joint
- Spot weld - Localized welding points
- Seam weld - Continuous line weld
- Plug weld - Hole-filling weld
Model Details
- Variant: YOLOX-s (small) or YOLOX-m (medium)
- Input Size: 2048Ã2048 pixels
- Output: Bounding boxes + class labels + confidence scores
- Parameters: ~8-15M
- Model Size: ~30-50MB
Framework: LitServe | Speed: 20ms (GPU) | Type: Single-stage object detection
4. material_shape_classification - Material Shape Classification
What it does
Classifies the shape of materials/parts shown in drawings. Given a part image or drawing, determines what geometric shape it is (cylinder, cube, plate, etc).
Architecture
Possible Shape Classes
- Cylinder - Round rod or tube shape
- Cube/Block - Rectangular solid
- Plate - Flat sheet material
- Angle Stock - L-shaped material
- Channel - U-shaped material
- I-Beam - I-shaped material
- Sphere - Round ball shape
- Cone - Conical shape
- Pyramid - Triangular base to point
- Other - Non-standard shapes
How CNN Classification Works
- Convolutional Layers: Extract visual features (edges, textures, shapes)
- Pooling: Reduce spatial dimensions while keeping important features
- Fully Connected Layers: High-level reasoning about shape
- Softmax Output: Probability distribution over all shape classes
- Argmax: Return class with highest probability
Model Details
- Input Size: 224Ã224 pixels
- Architecture: ResNet-50 or similar CNN backbone
- Output Classes: 10 shape categories
- Parameters: ~25M
- Model Size: ~100MB
Framework: LitServe | Speed: 10ms (GPU) | Type: Image Classification
5. part_table_recognition - Part Table Extraction
What it does
Finds tables in drawings and extracts them as structured data (HTML/CSV).
Complex Architecture (7-Stage Pipeline)
| ... |
Why Table Recognition is Complex
- Structure Variation: Tables have different row/column counts (3Ã3 to 50Ã50)
- Merged Cells: Some cells span multiple rows/columns
- Irregular Borders: Not all cells have visible borders
- Mixed Content: Text, numbers, symbols, logos
- Scale Variation: Different font sizes and cell dimensions
Key Component: Table Transformer (ONNX)
- Purpose: Understand table structure without explicit rules
- Architecture: Vision Transformer adapted for tables
- Training Data: Millions of diverse tables
- ONNX Format Benefits:
- Open Neural Network Exchange format
- Universal ML format (works with any framework)
- GPU-optimized inference kernels
- 5Ã faster than PyTorch equivalent
Model Pipeline Details
- YOLOX Detection: YOLOX-s (small, fast table finding)
- Table Transformer: ~86M parameters, 300MB model size
- Text Detection: SAHI with 512Ã512 tiles
- Angle Classifier: MobileNet-v2
- Text Recognition: BERT-base for OCR
Framework: LitServe | Speed: 100ms (GPU) | Type: Multi-stage structured extraction
6. surface_roughness_detection - Surface Roughness Extraction
What it does
Detects surface roughness symbols and extracts the numeric roughness values. This is a complex multi-stage pipeline that finds roughness symbols, detects associated text, classifies text orientation, and recognizes the numeric values.
What is Surface Roughness?
A manufacturing specification for how smooth a surface should be. Measured in micrometers (Ξm):
- Ra 0.8 = Very smooth (mirror-like)
- Ra 3.2 = Smooth (typical for machined parts)
- Ra 12.5 = Rough (unfinished casting)
Architecture (Most Complex Pipeline - 6 Stages)
Why This Pipeline is Complex
- Symbol Finding: Roughness symbols are small (10-30 pixels) and visually distinct
- Text Detection: Text is near symbols but not always in same region
- Angle Variation: Text can be rotated (engineers write in different angles)
- Multiple Units: Values in Ξm, mm, or inches with different formats
- Precision Required: "3.2" vs "32" changes meaning 10Ã
Key Components Explained
SAHI (Sliced Aided Hyper Inference):
- Problem: Image 2048Ã2048 is too large to process quickly
- Solution: Divide into overlapping 512Ã512 tiles
- Process each tile independently
- Merge results from overlapping regions
- Result: ~5Ã faster than processing whole image
Angle Classification:
- Simple CNN with 4 output classes
- Determines if text is: 0°, 90°, 180°, or 270° rotated
- Runs on each detected text bounding box
BERT Text Recognition:
- Pre-trained language model for text understanding
- Input: Rotated text image (now horizontal)
- Output: Recognized text string
- Accuracy: ~95% on clean technical text
Roughness Specification Types
- Ra - Arithmetic mean (most common)
- Rz - Ten-point height average
- Rmax - Maximum roughness height
- Rq - Root mean square (RMS)
Model Details
- YOLOX Variant: YOLOX-s (small)
- SAHI Tile Size: 512Ã512 with 50% overlap
- Angle Classifier: MobileNet-v2 backbone
- Total Pipeline Stages: 6 sequential stages
- Bottleneck Stage: SAHI text detection (most time-consuming)
Framework: LitServe | Speed: 50ms (GPU) | Type: Multi-stage OCR pipeline
7. thickness_estimation - Thickness Symbol Detection
What it does
Detects thickness specification symbols in technical drawings. Locates all regions where thickness or wall thickness is specified.
Architecture
Why YOLOX-l (Large Variant)?
- Accuracy over Speed: Thickness specifications are critical manufacturing specs
- Better Detection: YOLOX-l has more parameters (54M vs 8M for YOLOX-s)
- Trade-off: 15ms vs 5ms (3Ã slower but much more accurate)
- Standard Practice: Manufacturing specs require high precision
Special Features
Dynamic Batching:
- Max batch size: 4 images
- If 10 requests arrive: process in batches of (4 + 4 + 2)
- Per-request latency: still ~15ms (not 60ms)
- Throughput: 4Ã improvement compared to sequential processing
Grayscale Input:
- Technical drawings are often grayscale (scanned blueprints)
- Saves bandwidth (1 channel vs 3 RGB channels)
- Model trained on grayscale images specifically
Types of Thickness Specs Detected
- Uniform Thickness: "2.5mm" (entire part is this thickness)
- Variable Thickness: "2.5mm-5.0mm" (range specification)
- Wall Thickness: "1.5mm walls" (for hollow parts)
- Sheet Thickness: "Gauge 16" (for sheet metal)
- Min/Max: "Min 2.0mm, Max 3.0mm"
Model Details
- YOLOX Variant: YOLOX-l (large, more accurate)
- Input Format: Grayscale (single channel)
- Input Size: 2048Ã2048
- Parameters: ~54M
- Model Size: ~200MB
- Speed per Image: 15ms (GPU), 150ms (CPU)
- Batching Support: Yes (max batch 4)
Performance Characteristics
- Precision: ~92% (detects real thickness specs)
- Recall: ~88% (finds most thickness specs in drawing)
- False Positive Rate: ~5% (occasionally misses specs)
- False Negative Rate: ~12% (sometimes detects non-specs)
Framework: LitServe | Speed: 15ms (GPU) | Batch Size: 4 | Type: Object Detection
8. manufactured_size_estimation - Size Marking Detection
What it does
Detects rectangular regions containing size markings (length, width, height specifications). Similar to thickness_estimation but focuses on overall part dimensions.
Architecture
Difference from Thickness Estimation
- Thickness: Detects wall/material thickness specs only
- Size Estimation: Detects overall part dimensions (LÃWÃH)
- Both use: YOLOX-l with dynamic batching
- Different Training: Trained on different datasets
Size Marking Types
- Length à Width à Height: "25 à 50 à 10 mm"
- Diameter à Length: "Ã25 à 100 mm" (for cylinders)
- Radius + Height: "R50, H75 mm"
- Coordinates: "X100, Y50, Z25"
Model Details
- YOLOX Variant: YOLOX-l (large, for accuracy)
- Input Size: 2048Ã2048
- Classes: 2 (manufactured_size, no_input)
- Parameters: ~54M
- Model Size: ~200MB
- Batching: Max batch size 4
- Speed: 15ms (GPU), 150ms (CPU)
Framework: LitServe | Speed: 15ms (GPU) | Batch Size: 4 | Type: Object Detection
9. geometric_tolerance_detection - Geometric Tolerance Extraction
What it does
Detects geometric tolerance symbols (like "perpendicularity Âą0.1mm") and extracts their values. This is one of the most complex models, extracting both symbol type and numeric specifications.
Architecture (6-Stage OCR Pipeline)
14 Tolerance Types Detected
- 1. Straightness - How straight a line is (Âą0.05mm)
- 2. Flatness - How flat a surface is (Âą0.05mm)
- 3. Roundness - How round a circle is (Âą0.05mm)
- 4. Cylindricity - How cylindrical a shaft is (Âą0.1mm)
- 5. Line Profile - Shape of a 2D feature (Âą0.05mm)
- 6. Surface Profile - Shape of a 3D feature (Âą0.1mm)
- 7. Perpendicularity - Angle to datum (Âą0.05mm to datum A)
- 8. Parallelism - Parallel to datum (Âą0.05mm to datum B)
- 9. Angularity - Angle tolerance (¹30° to datum C)
- 10. Position - Location of feature (Âą0.05mm to datum ABC)
- 11. Concentricity - Feature centered on datum (Âą0.05mm)
- 12. Symmetry - Bilateral symmetry tolerance (Âą0.05mm)
- 13. Circular Runout - Rotation accuracy per revolution (Âą0.05mm)
- 14. Total Runout - Overall rotation accuracy (Âą0.1mm)
Why This is Complex
- Symbol Recognition: 14 different geometric symbols to identify
- Datum References: Can reference 1-3 datums (A, B, C, etc.)
- Text Parsing: Extract numbers, units, datum letters
- Precision Required: Tolerances are critical for manufacturing
- Compound Specs: Some specs combine multiple elements
Vision Encoder-Decoder (Not BERT)
- Why not BERT? Geometric tolerance text is complex and specialized
- Encoder Part: Extracts visual features from rotated text
- Decoder Part: Generates text character-by-character
- Language Understanding: Understands tolerance syntax
- Accuracy: ~97% on technical text (vs ~95% for BERT)
Model Pipeline
- YOLOX Detection: YOLOX-s for symbol finding
- SAHI Text Detection: 512Ã512 tiled detection
- Angle Classification: MobileNet-v2 (4 classes)
- Text Recognition: Vision Encoder-Decoder
- Post-processing: Validate and format results
Output Example
Drawing shows: âĨ symbol with "0.05 A B C"
Model outputs:
- symbol_type: "perpendicularity"
- value: 0.05
- unit: "mm"
- datum: ["A", "B", "C"] (referenced datums)
- confidence: 0.92
Framework: LitServe | Speed: 60ms (GPU) | Type: Multi-stage symbol + OCR extraction
10. drawing_or_not_classification - Drawing Classifier
What it does
Binary classification - is the image a technical drawing or not? Simple but important preprocessing model.
Architecture (Simple CNN)
Why Binary Classification?
- Preprocessing Filter: Avoid processing non-drawings with expensive models
- Fast Rejection: Reject non-drawings quickly (5ms)
- Cost Savings: Don't waste GPU time on photos, screenshots, etc.
- Error Prevention: Other models expect drawings, not arbitrary images
Classes Detected
- drawing: Technical drawings (blueprints, CAD drawings, schematics)
- not_drawing: Photos, screenshots, documents, artwork, etc.
What Makes Something a "Drawing"?
- Technical drawings: Blueprints with dimension lines, symbols
- CAD drawings: Computer-generated technical drawings
- Hand-sketches: Engineered sketches with technical intent
- Schematics: Electrical/circuit diagrams
What Gets Rejected?
- Photographs (objects, landscapes, people)
- Screenshots (UI, documents)
- Art (paintings, drawings without technical intent)
- Scanned documents (text-heavy documents)
- Logos and graphics
Model Details
- Architecture: ResNet-18 or MobileNet-v2 (simple CNN)
- Parameters: ~11M
- Model Size: ~45MB
- Input Size: 224Ã224
- Classes: 2 (drawing, not_drawing)
- Accuracy: ~98% on test set
Performance Characteristics
- Precision: ~99% (true positive rate for drawings)
- Recall: ~97% (catches most real drawings)
- False Positive Rate: ~1% (rarely misclassifies non-drawings)
- Speed: 5ms (GPU), 50ms (CPU)
Framework: FastAPI (NOT LitServe) | Speed: 5ms (GPU) | Type: Binary Image Classification
11. dummy_inference - Test Server
What it does
Minimal dummy server for testing purposes. Always returns "hello world".
Purpose: When testing the API Gateway, you need a "fake" model that responds quickly without doing actual ML work.
Framework: FastAPI | Deployment: CPU-only, always running
Model Architectures Explained
What is a Neural Network?
A neural network is a computational model inspired by the human brain. It consists of layers of neurons (mathematical functions) that transform input data into output predictions.
YOLOX - Object Detection
What it does: Given an image, find all objects of interest and their locations.
EfficientNet - Feature Extraction
What it does: Convert an image into a feature vector (list of numbers).
Shared Infrastructure
All 11 models share common utilities located in shared/ directory:
Configuration
- model_name
- gpu_memory_fraction
- max_batch_size
- timeout
Common Components
- Image Preprocessing: decode, resize, normalize
- Error Handling: Custom exceptions for GPU, image, and model errors
- Middleware: Access logging, concurrency limiting, versioning
- Validation: Bounding box validation, NMS thresholding
Deployment & Usage
Deployment Environments
| Environment | Configuration | Monitoring |
|---|---|---|
| Development (dev) | Single GPU pod, auto-restart | Direct logs to stdout |
| Staging (stg) | 2 GPU pods with load balancer | Performance monitoring |
| Production (prod) | 4 GPU pods, auto-scaling 2-8 | Datadog metrics, alerting |
Hardware Requirements
| Type | RAM | Speed | Throughput |
|---|---|---|---|
| GPU (NVIDIA T4/V100) | 16GB VRAM | 10-50ms | ~200 req/sec |
| CPU (4 cores) | 8GB RAM | 100-500ms | ~20 req/sec |
- drawing_or_not_classification: 5ms
- deep_feature_v2: 10ms
- thickness_estimation: 15ms
- welding_symbol_detection: 20ms
- canvas_ocr: 40ms
- surface_roughness_detection: 50ms
- geometric_tolerance_detection: 60ms
- part_table_recognition: 100ms
ð For detailed implementation, check individual model README files and API handlers
Last generated: June 2026