Initial commit: Synthetic Defect Factory digital twin & automated AOI pipeline
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
# Base USDA Scene Specification: `usd/base/station.usda`
|
||||
|
||||
**Generated By:** `src/make_base_usd.py`
|
||||
**Rendered Via:** Blender 5.2.2 LTS (Cycles GPU / OptiX)
|
||||
**Preview Artifacts:**
|
||||
- Top-Down Inspection: `renders/samples/base_preview.png`
|
||||
- 3D Workstation Overview: `renders/samples/station_overview.png`
|
||||
**Interactive 3D File:** `station.blend`
|
||||
**Stage Metadata:**
|
||||
- `upAxis`: `"Z"`
|
||||
- `metersPerUnit`: `1.0`
|
||||
- `defaultPrim`: `"World"`
|
||||
|
||||
---
|
||||
|
||||
## 1. Scene Architecture & Hierarchy
|
||||
|
||||
The scene contains 118 prims organized cleanly under standard USD schemas:
|
||||
|
||||
| Subsystem Path | Type | Applied Schemas | Description / Realism Features |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `/World` | `Xform` | — | World root coordinates. |
|
||||
| `/World/Materials` | `Scope` | — | 15 PBR materials (`UsdPreviewSurface`): Brushed steel, anodized aluminum, rubber, camera paint, safety yellow, cast iron, 3-tier andon indicators, black polymer conduit, chrome piston rod, RAL 7035 enclosure paint, stainless reject chute, etc. |
|
||||
| `/World/FactoryFloor` | `Mesh` | `MaterialBindingAPI` | Factory floor plane (1.8m x 1.8m) at $z = -0.30\text{ m}$. |
|
||||
| `/World/Conveyor` | `Xform` | — | 800mm conveyor assembly: continuous vulcanized rubber belt, fine splice seam line, extruded aluminum side channels, safety yellow guide rails, end pulley rollers, pillow-block bearing blocks, electric drive motor/gearbox, 4 support legs with rubber foot pads, photoelectric part detector, and emergency stop station with red mushroom button. |
|
||||
| `/World/InspectionRig` | `Xform` | — | Corner mounting mast ($x = -0.12, y = 0.20$), floor mounting flange, 3-tier Andon signal tower (Red/Amber/Green), articulated boom arm, swivel knuckle, industrial camera casing with heat-sink fins, C-mount lens barrel, ring illuminator housing, status green LED, cable connector, corrugated cable conduits, and electrical enclosure cabinet. |
|
||||
| `/World/RejectStation` | `Xform` | — | Automated downstream defect sorting station: side rail clamp, pneumatic air cylinder, chrome piston rod, black polymer pusher paddle, and slanted stainless steel reject slide chute. |
|
||||
| `/World/StreamBrackets` | `Xform` | — | Upstream ($x = -0.24\text{ m}$) and downstream ($x = +0.24\text{ m}$) brackets on the conveyor belt with natural physical pose variation ($\pm 2.8^\circ$ yaw angle and lateral offsets). |
|
||||
| `/World/Product` | `Xform` | — | Primary inspection assembly centered at origin $(0, 0, 0)$. |
|
||||
| `/World/Product/Body` | `Mesh` | `MaterialBindingAPI` | Bracket body ($80 \times 40 \times 6\text{ mm}$), 4 holes, $64 \times 32$ subdivided top face quad grid, linear UVs. |
|
||||
| `/World/Product/Screw_1` | `Mesh` | `MaterialBindingAPI` | Pan-head fastener seated in Hole 1 at local $(-0.025, -0.010, 0.006)$. |
|
||||
| `/World/Product/Screw_2` | `Mesh` | `MaterialBindingAPI` | Pan-head fastener seated in Hole 4 at local $(0.025, 0.010, 0.006)$. |
|
||||
| `/World/Camera` | `Camera` | — | Machine vision top-down perspective camera at $(0.0, 0.0, 0.22)$, 50mm focal length, 1:1 sensor (640x640). |
|
||||
| `/World/Lights/*` | `Scope` | — | Calibrated lighting suite: soft diffused KeyLight, two balanced SideLights, and RingLight around the lens barrel. |
|
||||
|
||||
---
|
||||
|
||||
## 2. USD Compliance Validation Results
|
||||
|
||||
Validated via `pxr.UsdValidation` across all 30 standard validator suites:
|
||||
- **Total Errors:** `0`
|
||||
- **Total Warnings:** `0`
|
||||
- **Result:** **100% COMPLIANT** (Complies strictly with `PROJECT_BRIEF.md`: pure ASCII USDA, meter units, Z up-axis, standard `UsdPreviewSurface` materials, standard named prims).
|
||||
|
||||
---
|
||||
|
||||
## 3. Headless Render Verification
|
||||
|
||||
- **Render Engine:** Blender 5.2.2 LTS Cycles with OptiX GPU acceleration on NVIDIA GeForce RTX 3050 Laptop GPU.
|
||||
- **Outputs Produced:**
|
||||
- `renders/samples/base_preview.png`: 640 × 640 inspection camera view.
|
||||
- `renders/samples/station_overview.png`: 1024 × 640 3D overview with depth-of-field, factory ceiling illumination, full machine vision stanchion, Andon tower, and reject station.
|
||||
- `station.blend`: Saved and configured in Material Preview mode for interactive inspection.
|
||||
@@ -0,0 +1,161 @@
|
||||
# Blender 5.2 API Discovery & System Compatibility Notes
|
||||
|
||||
**Generated At:** 2026-10-22
|
||||
**Blender Binary:** `C:\Program Files\Blender Foundation\Blender 5.2\blender.exe`
|
||||
**Host System:** Windows (AMD64), Intel Core i5-13420H, NVIDIA GeForce RTX 3050 6GB Laptop GPU
|
||||
|
||||
---
|
||||
|
||||
## 1. Blender Version & Build Metadata
|
||||
|
||||
Discovered via headless command `blender --background --version` and `bpy.app`:
|
||||
|
||||
| Property | Value |
|
||||
| :--- | :--- |
|
||||
| **Version** | `5.2.2 LTS` |
|
||||
| **Version Tuple** | `(5, 2, 2)` |
|
||||
| **Build Date** | `2026-09-15` |
|
||||
| **Build Time** | `01:37:04` |
|
||||
| **Build Hash** | `d13f752e3b9c` |
|
||||
| **Build Branch** | `blender-v5.2-release` |
|
||||
| **Platform** | Windows (MSVC 1938 64-bit) |
|
||||
| **Embedded Python** | `Python 3.11` |
|
||||
|
||||
---
|
||||
|
||||
## 2. Valid Render Engine Identifiers
|
||||
|
||||
Discovered via querying `bpy.context.scene.render.engine` and testing engine assignments:
|
||||
|
||||
| Engine Identifier | Engine Name | Status in Blender 5.2 | Notes |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `CYCLES` | Cycles | **VALID** | Full raytracing engine, supports CPU, CUDA, and OptiX GPU acceleration. |
|
||||
| `BLENDER_EEVEE` | EEVEE | **VALID** | Real-time viewport and rasterized render engine. In Blender 4.2+ and 5.2, the redesigned next-generation EEVEE architecture uses the identifier `BLENDER_EEVEE`. |
|
||||
| `BLENDER_WORKBENCH` | Workbench | **VALID** | Real-time preview/wireframe/technical renderer. |
|
||||
| `BLENDER_EEVEE_NEXT` | EEVEE Next (Legacy Name) | **INVALID** | Explicitly raises `TypeError: enum "BLENDER_EEVEE_NEXT" not found in ('BLENDER_EEVEE', 'BLENDER_WORKBENCH', 'CYCLES')`. **Do not use** `BLENDER_EEVEE_NEXT`. |
|
||||
|
||||
---
|
||||
|
||||
## 3. Cycles GPU Acceleration & Device Assessment
|
||||
|
||||
Discovered by inspecting `bpy.context.preferences.addons['cycles'].preferences` and executing headless 1-sample verification renders:
|
||||
|
||||
### Supported Compute Device Types
|
||||
Blender 5.2 Cycles reports the following device types:
|
||||
- `NONE` (CPU only)
|
||||
- `CUDA` (NVIDIA CUDA)
|
||||
- `OPTIX` (NVIDIA OptiX hardware raytracing)
|
||||
- `HIP` (AMD HIP)
|
||||
- `ONEAPI` (Intel oneAPI)
|
||||
|
||||
### Hardware Detection on this Machine
|
||||
- **GPU Device:** `NVIDIA GeForce RTX 3050 6GB Laptop GPU` (`0000:01:00`)
|
||||
- **CPU Device:** `13th Gen Intel Core i5-13420H` (`CPU`)
|
||||
|
||||
### GPU Capability & Headless Render Tests
|
||||
| Backend | Device Identified | Headless Render Test (1 Sample) | Recommendation |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **OptiX** (`OPTIX`) | `NVIDIA GeForce RTX 3050 6GB Laptop GPU` | **PASS (SUCCESS)** | **Recommended primary backend**. Hardware raytracing via RT Cores delivers optimal rendering throughput. |
|
||||
| **CUDA** (`CUDA`) | `NVIDIA GeForce RTX 3050 6GB Laptop GPU` | **PASS (SUCCESS)** | **PASS**. Fully operational fallback backend. |
|
||||
| **HIP** (`HIP`) | No AMD GPU detected | N/A (Library initialization skipped) | Not applicable for this NVIDIA GPU. |
|
||||
| **oneAPI** (`ONEAPI`) | CPU fallback | N/A | Not recommended over OptiX/CUDA. |
|
||||
|
||||
### Cycles GPU Headless Setup Pattern
|
||||
To configure Cycles for GPU rendering in Python scripts:
|
||||
```python
|
||||
import bpy
|
||||
|
||||
# Set render engine
|
||||
scene = bpy.context.scene
|
||||
scene.render.engine = 'CYCLES'
|
||||
|
||||
# Configure GPU preferences
|
||||
cpref = bpy.context.preferences.addons['cycles'].preferences
|
||||
cpref.compute_device_type = 'OPTIX' # or 'CUDA'
|
||||
cpref.get_devices()
|
||||
|
||||
for device in cpref.devices:
|
||||
if device.type == 'OPTIX':
|
||||
device.use = True
|
||||
else:
|
||||
device.use = False
|
||||
|
||||
scene.cycles.device = 'GPU'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. USD Import Operator (`bpy.ops.wm.usd_import`) Parameter Reference
|
||||
|
||||
Discovered via RNA property introspection (`bpy.ops.wm.usd_import.get_rna_type().properties`). Total parameters: 61 (including file dialog filters).
|
||||
|
||||
### 4.1 Key Scene, Scaling & Units Parameters
|
||||
| Parameter | Type | Default | Description & Project Relevance |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `filepath` | `STRING` | `""` | Absolute or relative path to the USD/USDA file. |
|
||||
| `scale` | `FLOAT` | `1.0` | Global scaling factor applied relative to the world origin. |
|
||||
| `apply_unit_conversion_scale` | `BOOLEAN` | `True` | Scales objects by the USD stage's `metersPerUnit` value. Since USDA scenes are authored with `metersPerUnit = 1.0`, keeping this `True` preserves 1:1 scale in Blender (1 unit = 1 meter). |
|
||||
| `set_frame_range` | `BOOLEAN` | `True` | Updates scene frame start/end to match the USD archive. |
|
||||
| `support_scene_instancing` | `BOOLEAN` | `True` | Imports USD scene graph instances as collection instances. |
|
||||
| `merge_parent_xform` | `BOOLEAN` | `True` | Merges USD primitives with their Xform parent if they are the only child in the hierarchy. |
|
||||
|
||||
### 4.2 Materials, Textures & Shading Parameters
|
||||
| Parameter | Type | Default | Options / Description |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `import_materials` | `BOOLEAN` | `True` | Imports materials defined in the USD file. |
|
||||
| `import_usd_preview` | `BOOLEAN` | `True` | **Crucial:** Converts `UsdPreviewSurface` shader networks directly to Blender `Principled BSDF` node networks. |
|
||||
| `set_material_blend` | `BOOLEAN` | `True` | Automatically sets material blend method based on opacity and opacityThreshold. |
|
||||
| `mtl_purpose` | `ENUM` | `'MTL_FULL'` | `['MTL_ALL_PURPOSE', 'MTL_PREVIEW', 'MTL_FULL']`. Preferred material purpose binding. |
|
||||
| `mtl_name_collision_mode` | `ENUM` | `'MAKE_UNIQUE'` | `['MAKE_UNIQUE', 'REFERENCE_EXISTING']`. Handles duplicate material naming. |
|
||||
| `import_textures_mode` | `ENUM` | `'IMPORT_PACK'` | `['IMPORT_NONE', 'IMPORT_PACK', 'IMPORT_COPY']`. Handling of embedded textures. |
|
||||
| `import_textures_dir` | `STRING` | `"//textures/"` | Directory where imported textures will be copied. |
|
||||
| `tex_name_collision_mode` | `ENUM` | `'USE_EXISTING'` | `['USE_EXISTING', 'OVERWRITE']`. Handling of texture filename collisions. |
|
||||
| `import_all_materials` | `BOOLEAN` | `False` | When False, only imports materials referenced by geometry. |
|
||||
|
||||
### 4.3 Primitives, Geometry & Hierarchy Parameters
|
||||
| Parameter | Type | Default | Options / Description |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `import_defined_only` | `BOOLEAN` | `True` | Import only defined USD primitives (ignores override specifiers if False). |
|
||||
| `import_visible_only` | `BOOLEAN` | `True` | Skips primitives flagged as invisible in USD. |
|
||||
| `create_collection` | `BOOLEAN` | `False` | Adds imported objects into a new collection. |
|
||||
| `validate_meshes` | `BOOLEAN` | `False` | Validates mesh geometry data integrity. |
|
||||
| `property_import_mode` | `ENUM` | `'ALL'` | `['NONE', 'USER', 'ALL']`. Imports USD attributes as Blender custom properties. |
|
||||
| `prim_path_mask` | `STRING` | `""` | Imports only primitives at the given path and descendants (comma/semicolon delimited). |
|
||||
| `import_meshes` | `BOOLEAN` | `True` | Imports polygonal mesh geometry. |
|
||||
| `import_curves` | `BOOLEAN` | `True` | Imports curve geometry. |
|
||||
| `import_points` | `BOOLEAN` | `True` | Imports point cloud primitives. |
|
||||
| `read_mesh_uvs` | `BOOLEAN` | `True` | Imports UV coordinates. |
|
||||
| `read_mesh_colors` | `BOOLEAN` | `True` | Imports color attributes. |
|
||||
| `read_mesh_attributes` | `BOOLEAN` | `True` | Reads USD Primvars as mesh attributes. |
|
||||
| `import_subdivision` | `BOOLEAN` | `False` | Creates subdivision surface modifiers based on `SubdivisionScheme`. |
|
||||
| `import_guide` | `BOOLEAN` | `False` | Import guide geometry. |
|
||||
| `import_proxy` | `BOOLEAN` | `False` | Import proxy geometry. |
|
||||
| `import_render` | `BOOLEAN` | `True` | Import final render geometry. |
|
||||
|
||||
### 4.4 Lights, Cameras & Dome Lighting Parameters
|
||||
| Parameter | Type | Default | Description |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `import_lights` | `BOOLEAN` | `True` | Imports USD lights (`DiskLight`, `SphereLight`, `RectLight`, etc.). |
|
||||
| `light_intensity_scale` | `FLOAT` | `1.0` | Multiplier for the intensity of imported lights. |
|
||||
| `create_world_material` | `BOOLEAN` | `True` | Converts the first discovered USD `DomeLight` to a world background environment shader. |
|
||||
| `import_cameras` | `BOOLEAN` | `True` | Imports USD camera primitives (`/World/Camera`). |
|
||||
| `import_volumes` | `BOOLEAN` | `True` | Imports OpenVDB / USD volume grids. |
|
||||
| `import_shapes` | `BOOLEAN` | `True` | Imports USD shape primitives (Cylinder, Cube, Sphere). |
|
||||
|
||||
---
|
||||
|
||||
## 5. Recommended Headless Import & Render Invocation
|
||||
|
||||
Based on the discovered parameters, the standard operator invocation for headless USDA import in Blender 5.2 is:
|
||||
```python
|
||||
bpy.ops.wm.usd_import(
|
||||
filepath="usd/scenes/scene_0001.usda",
|
||||
import_usd_preview=True,
|
||||
import_materials=True,
|
||||
import_lights=True,
|
||||
import_cameras=True,
|
||||
apply_unit_conversion_scale=True,
|
||||
create_world_material=True,
|
||||
scale=1.0
|
||||
)
|
||||
```
|
||||
@@ -0,0 +1,46 @@
|
||||
# Procedural Defect Engine Specification: `src/defects.py`
|
||||
|
||||
**Implementation Script:** `src/defects.py`
|
||||
**Render Verification Script:** `blender/render_sample.py`
|
||||
**Validation Suite:** `pxr.UsdValidation` (30 validator suites)
|
||||
**Render Backend:** Blender 5.2.2 LTS (Cycles GPU / OptiX)
|
||||
|
||||
---
|
||||
|
||||
## 1. Defect Class Definitions & Geometric Implementations
|
||||
|
||||
The defect generator models all 4 industrial defect classes procedurally on the USDA stage, plus good (pristine) parts:
|
||||
|
||||
| Class ID | Class Name | Target Prim | 3D Physical & Geometric Implementation | Manifest Coordinates |
|
||||
| :---: | :---: | :---: | :--- | :--- |
|
||||
| **0** | `scratch` | `/World/Product/Body` | Hairline directional groove with perturbed vertex normals on the bracket top quad grid ($z \in [0.0055, 0.006]$) combined with a high-contrast abrasive ribbon mesh (`/World/Product/Scratch_Ribbon`) bound to `/World/Materials/ScratchAbrasion`. | Center $[x_c, y_c, 0.006]$ (m), radius $L/2$ (m) |
|
||||
| **1** | `dent` | `/World/Product/Body` | Smooth $C^1$ radial indentation on the top face grid with depth $D \in [0.8\text{ mm}, 1.6\text{ mm}]$ and radius $R \in [4.5\text{ mm}, 7.5\text{ mm}]$ using $\Delta z = -D(1 - r^2/R^2)^2$. Vertices deformed and vertex normals recomputed for raytraced concave shadows and rim highlights. | Center $[x_c, y_c, 0.006]$ (m), radius $R$ (m) |
|
||||
| **2** | `missing_part` | `/World/Product/Screw_1` or `Screw_2` | Complete omission / deactivation of either `Screw_1` (Hole 1) or `Screw_2` (Hole 4), leaving the dark cylindrical through-hole clearance bore exposed down to the black conveyor rubber. | Hole center $[-0.025, -0.010, 0.006]$ or $[0.025, 0.010, 0.006]$, radius $0.004$ (m) |
|
||||
| **3** | `misplaced_part` | `/World/Product/Screw_*` | **Variation A:** Fastener inserted into the wrong hole (Hole 2 or 3).<br>**Variation B:** Fastener cross-threaded / high (backed out by 2.2–3.2 mm and tilted by $14^\circ$–$20^\circ$).<br>**Variation C:** Stray loose fastener dropped horizontally on the bracket top surface. | Position $[x, y, z]$ (m), radius $0.0045$–$0.006$ (m) |
|
||||
| **None** | `good` | — | Pristine bracket with Hole 1 having `Screw_1` seated flush, Hole 4 having `Screw_2` seated flush, 0 dents, 0 scratches. | `defects: []` |
|
||||
|
||||
---
|
||||
|
||||
## 2. USD Compliance Validation Results
|
||||
|
||||
All 5 representative sample USDA scenes were validated against all 30 standard validator suites in `pxr.UsdValidation`:
|
||||
|
||||
| Scene Name | USDA Path | JSON Manifest Path | USD Errors | USD Warnings | Compliance Status |
|
||||
| :--- | :--- | :--- | :---: | :---: | :---: |
|
||||
| `sample_good` | `usd/scenes/sample_good.usda` | `usd/manifests/sample_good.json` | **0** | **0** | **100% COMPLIANT** |
|
||||
| `sample_scratch` | `usd/scenes/sample_scratch.usda` | `usd/manifests/sample_scratch.json` | **0** | **0** | **100% COMPLIANT** |
|
||||
| `sample_dent` | `usd/scenes/sample_dent.usda` | `usd/manifests/sample_dent.json` | **0** | **0** | **100% COMPLIANT** |
|
||||
| `sample_missing_part` | `usd/scenes/sample_missing_part.usda` | `usd/manifests/sample_missing_part.json` | **0** | **0** | **100% COMPLIANT** |
|
||||
| `sample_misplaced_part` | `usd/scenes/sample_misplaced_part.usda` | `usd/manifests/sample_misplaced_part.json` | **0** | **0** | **100% COMPLIANT** |
|
||||
|
||||
---
|
||||
|
||||
## 3. Render Verification Outputs
|
||||
|
||||
Rendered at $640 \times 640$ in headless Blender 5.2.2 LTS (Cycles OptiX GPU on NVIDIA RTX 3050):
|
||||
|
||||
- `renders/samples/preview_good.png`: Pristine bracket with two seated screws and two empty holes.
|
||||
- `renders/samples/preview_scratch.png`: Clear directional abrasive scratch streak with recomputed normals.
|
||||
- `renders/samples/preview_dent.png`: Physically raytraced concave dent with smooth shadow and crescent rim reflection.
|
||||
- `renders/samples/preview_missing_part.png`: Screw 1 absent, exposing the dark through-bore hole.
|
||||
- `renders/samples/preview_misplaced_part.png`: Stray loose fastener lying horizontally on the bracket top face.
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"timestamp": "2026-10-26 10:23:47",
|
||||
"epochs": 30,
|
||||
"batch_size": 8,
|
||||
"training_time_minutes": 22.66,
|
||||
"best_weights_path": "C:\\Ai India Innovations\\synthetic-defect-factory\\runs\\detect\\train\\weights\\best.pt",
|
||||
"overall": {
|
||||
"mAP50": 0.8543,
|
||||
"mAP50_95": 0.84,
|
||||
"precision": 0.8388,
|
||||
"recall": 0.9375
|
||||
},
|
||||
"per_class": {
|
||||
"scratch": {
|
||||
"mAP50": 0.9614
|
||||
},
|
||||
"dent": {
|
||||
"mAP50": 0.995
|
||||
},
|
||||
"missing_part": {
|
||||
"mAP50": 0.995
|
||||
},
|
||||
"misplaced_part": {
|
||||
"mAP50": 0.4087
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user