diff options
| -rw-r--r-- | CLAUDE.md | 2 | ||||
| -rw-r--r-- | PROJECT_CONTEXT.md | 4 | ||||
| -rw-r--r-- | cmake/DemoSourceLists.cmake | 2 | ||||
| -rw-r--r-- | cnn_v1/README.md | 2 | ||||
| -rw-r--r-- | cnn_v1/docs/CNN.md | 2 | ||||
| -rw-r--r-- | cnn_v1/docs/CNN_FLATTEN_ANALYSIS.md | 6 | ||||
| -rw-r--r-- | cnn_v1/docs/CNN_V1_EFFECT.md (renamed from cnn_v1/docs/CNN_EFFECT.md) | 0 | ||||
| -rw-r--r-- | cnn_v1/src/cnn_v1_effect.cc (renamed from cnn_v1/src/cnn_effect.cc) | 18 | ||||
| -rw-r--r-- | cnn_v1/src/cnn_v1_effect.h (renamed from cnn_v1/src/cnn_effect.h) | 14 | ||||
| -rw-r--r-- | doc/COMPLETED.md | 2 | ||||
| -rw-r--r-- | doc/HOWTO.md | 10 | ||||
| -rw-r--r-- | src/app/test_demo.cc | 2 | ||||
| -rw-r--r-- | src/gpu/demo_effects.h | 2 | ||||
| -rw-r--r-- | src/tests/gpu/test_demo_effects.cc | 4 | ||||
| -rw-r--r-- | tools/cnn_test.cc | 2 | ||||
| -rw-r--r-- | training/README.md | 2 | ||||
| -rw-r--r-- | workspaces/main/assets.txt | 14 | ||||
| -rw-r--r-- | workspaces/main/timeline.seq | 4 |
18 files changed, 46 insertions, 46 deletions
@@ -12,7 +12,7 @@ # TIER 3: DESIGN DOCS (Load On-Demand by Subsystem) # # Audio: SPECTRAL_BRUSH_EDITOR.md, TRACKER.md, BEAT_TIMING.md -# CNN: CNN.md, CNN_EFFECT.md, CNN_V2*.md, CNN_TEST_TOOL.md, CNN_*ANALYSIS.md, CNN_BIAS_FIX*.md +# CNN: cnn_v1/docs/CNN_V1_EFFECT.md, cnn_v2/docs/CNN_V2*.md # 3D/Graphics: 3D.md, GPU_PROCEDURAL_PHASE4.md, MASKING_SYSTEM.md, SDF_EFFECT_GUIDE.md # Scene: SCENE_FORMAT.md, SEQUENCE.md, WORKSPACE_SYSTEM.md # Build: ASSET_SYSTEM.md, BUILD.md, CMAKE_MODULES.md, SIZE_MEASUREMENT.md diff --git a/PROJECT_CONTEXT.md b/PROJECT_CONTEXT.md index 63e6f8a..f59eb8b 100644 --- a/PROJECT_CONTEXT.md +++ b/PROJECT_CONTEXT.md @@ -57,9 +57,9 @@ See `TODO.md` for current priorities and active tasks. - `doc/CONTRIBUTING.md` - Development protocols **Technical Reference:** -- Core: `ASSET_SYSTEM.md`, `SEQUENCE.md`, `TRACKER.md`, `3D.md`, `CNN_EFFECT.md`, `CNN_V2.md` +- Core: `ASSET_SYSTEM.md`, `SEQUENCE.md`, `TRACKER.md`, `3D.md`, `cnn_v1/docs/CNN_V1_EFFECT.md`, `cnn_v2/docs/CNN_V2.md` - Formats: `SCENE_FORMAT.md`, `MASKING_SYSTEM.md` -- Tools: `BUILD.md`, `WORKSPACE_SYSTEM.md`, `SIZE_MEASUREMENT.md`, `CNN_TEST_TOOL.md`, `tools/timeline_editor/README.md` +- Tools: `BUILD.md`, `WORKSPACE_SYSTEM.md`, `SIZE_MEASUREMENT.md`, `cnn_v1/docs/CNN_TEST_TOOL.md`, `tools/timeline_editor/README.md` **History:** - `doc/COMPLETED.md` - Completed tasks archive diff --git a/cmake/DemoSourceLists.cmake b/cmake/DemoSourceLists.cmake index 1345ed4..2d6cf42 100644 --- a/cmake/DemoSourceLists.cmake +++ b/cmake/DemoSourceLists.cmake @@ -39,7 +39,7 @@ set(COMMON_GPU_EFFECTS src/effects/scene1_effect.cc src/effects/chroma_aberration_effect.cc src/effects/vignette_effect.cc - src/effects/cnn_effect.cc + cnn_v1/src/cnn_v1_effect.cc cnn_v2/src/cnn_v2_effect.cc src/gpu/post_process_helper.cc src/gpu/shaders.cc diff --git a/cnn_v1/README.md b/cnn_v1/README.md index ad9b8f3..052f22a 100644 --- a/cnn_v1/README.md +++ b/cnn_v1/README.md @@ -29,7 +29,7 @@ Original CNN implementation with per-layer WGSL shaders. Supports multiple kerne ## Documentation - [CNN.md](docs/CNN.md) - Architecture overview -- [CNN_EFFECT.md](docs/CNN_EFFECT.md) - Implementation details +- [CNN_V1_EFFECT.md](docs/CNN_V1_EFFECT.md) - Implementation details - [CNN_TEST_TOOL.md](docs/CNN_TEST_TOOL.md) - Testing guide - [CNN_DEBUG.md](docs/CNN_DEBUG.md) - Debugging notes diff --git a/cnn_v1/docs/CNN.md b/cnn_v1/docs/CNN.md index 2dc3362..5d9a667 100644 --- a/cnn_v1/docs/CNN.md +++ b/cnn_v1/docs/CNN.md @@ -8,7 +8,7 @@ Have the input 3d scene be processed by a multi-layer CNN trained on the side. Input: some rendered scene. Output: 'stylized' scene with CNN post-processing. -**See `doc/CNN_EFFECT.md` for implementation details, usage, and API reference.** +**See `CNN_V1_EFFECT.md` for implementation details, usage, and API reference.** ## Shader implementation diff --git a/cnn_v1/docs/CNN_FLATTEN_ANALYSIS.md b/cnn_v1/docs/CNN_FLATTEN_ANALYSIS.md index bf63c5d..8664157 100644 --- a/cnn_v1/docs/CNN_FLATTEN_ANALYSIS.md +++ b/cnn_v1/docs/CNN_FLATTEN_ANALYSIS.md @@ -183,7 +183,7 @@ These yield better size/performance than shader architecture changes. ## References -- `doc/CNN_EFFECT.md` - CNN implementation details -- `doc/CNN.md` - High-level CNN design -- `src/effects/cnn_effect.cc` - Current implementation +- `CNN_V1_EFFECT.md` - CNN implementation details +- `CNN.md` - High-level CNN design +- `../src/cnn_effect.cc` - Current implementation - `workspaces/main/shaders/cnn_*.wgsl` - Shader snippets diff --git a/cnn_v1/docs/CNN_EFFECT.md b/cnn_v1/docs/CNN_V1_EFFECT.md index 40f095e..40f095e 100644 --- a/cnn_v1/docs/CNN_EFFECT.md +++ b/cnn_v1/docs/CNN_V1_EFFECT.md diff --git a/cnn_v1/src/cnn_effect.cc b/cnn_v1/src/cnn_v1_effect.cc index 49c5239..1f44619 100644 --- a/cnn_v1/src/cnn_effect.cc +++ b/cnn_v1/src/cnn_v1_effect.cc @@ -1,7 +1,7 @@ // CNN post-processing effect implementation // Neural network-based stylization with modular WGSL -#include "effects/cnn_effect.h" +#include "cnn_v1_effect.h" #include "gpu/bind_group_builder.h" #include "gpu/effect.h" #include "gpu/pipeline_builder.h" @@ -33,7 +33,7 @@ static WGPURenderPipeline create_cnn_pipeline(WGPUDevice device, return pipeline; } -CNNEffect::CNNEffect(const GpuContext& ctx) +CNNv1Effect::CNNv1Effect(const GpuContext& ctx) : PostProcessEffect(ctx), layer_index_(0), total_layers_(1), blend_amount_(1.0f), input_view_(nullptr), original_view_(nullptr), bind_group_(nullptr) { @@ -41,7 +41,7 @@ CNNEffect::CNNEffect(const GpuContext& ctx) create_cnn_pipeline(ctx_.device, ctx_.format, cnn_layer_shader_wgsl); } -CNNEffect::CNNEffect(const GpuContext& ctx, const CNNEffectParams& params) +CNNv1Effect::CNNv1Effect(const GpuContext& ctx, const CNNv1EffectParams& params) : PostProcessEffect(ctx), layer_index_(params.layer_index), total_layers_(params.total_layers), blend_amount_(params.blend_amount), input_view_(nullptr), original_view_(nullptr), bind_group_(nullptr) { @@ -49,7 +49,7 @@ CNNEffect::CNNEffect(const GpuContext& ctx, const CNNEffectParams& params) create_cnn_pipeline(ctx_.device, ctx_.format, cnn_layer_shader_wgsl); } -void CNNEffect::init(MainSequence* demo) { +void CNNv1Effect::init(MainSequence* demo) { PostProcessEffect::init(demo); demo_ = demo; params_buffer_.init(ctx_.device); @@ -62,11 +62,11 @@ void CNNEffect::init(MainSequence* demo) { // Initialize uniforms BEFORE any bind group creation uniforms_.update(ctx_.queue, get_common_uniforms()); - CNNLayerParams params = {layer_index_, blend_amount_, {0.0f, 0.0f}}; + CNNv1LayerParams params = {layer_index_, blend_amount_, {0.0f, 0.0f}}; params_buffer_.update(ctx_.queue, params); } -void CNNEffect::resize(int width, int height) { +void CNNv1Effect::resize(int width, int height) { if (width == width_ && height == height_) return; @@ -78,7 +78,7 @@ void CNNEffect::resize(int width, int height) { } } -void CNNEffect::render(WGPURenderPassEncoder pass, +void CNNv1Effect::render(WGPURenderPassEncoder pass, const CommonPostProcessUniforms& uniforms) { if (!bind_group_) { fprintf(stderr, "CNN render: no bind_group\n"); @@ -90,7 +90,7 @@ void CNNEffect::render(WGPURenderPassEncoder pass, effective_blend = blend_amount_ * uniforms.beat_phase * beat_scale_; } - CNNLayerParams params = {layer_index_, effective_blend, {0.0f, 0.0f}}; + CNNv1LayerParams params = {layer_index_, effective_blend, {0.0f, 0.0f}}; params_buffer_.update(ctx_.queue, params); wgpuRenderPassEncoderSetPipeline(pass, pipeline_); @@ -98,7 +98,7 @@ void CNNEffect::render(WGPURenderPassEncoder pass, wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); } -void CNNEffect::update_bind_group(WGPUTextureView input_view) { +void CNNv1Effect::update_bind_group(WGPUTextureView input_view) { input_view_ = input_view; // Update common uniforms (CRITICAL for UV calculation!) diff --git a/cnn_v1/src/cnn_effect.h b/cnn_v1/src/cnn_v1_effect.h index cdcd656..e820275 100644 --- a/cnn_v1/src/cnn_effect.h +++ b/cnn_v1/src/cnn_v1_effect.h @@ -5,23 +5,23 @@ #include "gpu/effect.h" #include "gpu/uniform_helper.h" -struct CNNLayerParams { +struct CNNv1LayerParams { int layer_index; float blend_amount; // Blend: mix(input, output, blend_amount) float _pad[2]; }; -static_assert(sizeof(CNNLayerParams) == 16); +static_assert(sizeof(CNNv1LayerParams) == 16); -struct CNNEffectParams { +struct CNNv1EffectParams { int layer_index = 0; // Which layer to render (0-based) int total_layers = 1; // Total number of layers in the CNN float blend_amount = 1.0f; // Final blend with original input }; -class CNNEffect : public PostProcessEffect { +class CNNv1Effect : public PostProcessEffect { public: - explicit CNNEffect(const GpuContext& ctx); - explicit CNNEffect(const GpuContext& ctx, const CNNEffectParams& params); + explicit CNNv1Effect(const GpuContext& ctx); + explicit CNNv1Effect(const GpuContext& ctx, const CNNv1EffectParams& params); void init(MainSequence* demo) override; void resize(int width, int height) override; @@ -47,7 +47,7 @@ class CNNEffect : public PostProcessEffect { float beat_scale_ = 1.0f; WGPUTextureView input_view_; WGPUTextureView original_view_; - UniformBuffer<CNNLayerParams> params_buffer_; + UniformBuffer<CNNv1LayerParams> params_buffer_; WGPUBindGroup bind_group_; MainSequence* demo_ = nullptr; }; diff --git a/doc/COMPLETED.md b/doc/COMPLETED.md index 55fac50..08767ea 100644 --- a/doc/COMPLETED.md +++ b/doc/COMPLETED.md @@ -93,7 +93,7 @@ Use `read @doc/archive/FILENAME.md` to access archived documents. - All 36 tests pass (100%) - Processes 64×64 test image successfully - Ready for ground-truth validation vs Python training script - - Documented in `doc/CNN_TEST_TOOL.md` + - Documented in `cnn_v1/docs/CNN_TEST_TOOL.md` ## Recently Completed (February 10, 2026) diff --git a/doc/HOWTO.md b/doc/HOWTO.md index a309b27..59ab6fd 100644 --- a/doc/HOWTO.md +++ b/doc/HOWTO.md @@ -100,7 +100,7 @@ make run_util_tests # Utility tests Extracts patches at salient points, trains on center pixels only (matches WGSL sliding window): ```bash # Train with 32×32 patches at detected corners/edges -./training/train_cnn.py \ +./cnn_v1/training/train_cnn.py \ --input training/input/ --target training/output/ \ --patch-size 32 --patches-per-image 64 --detector harris \ --layers 3 --kernel_sizes 3,5,3 --epochs 5000 --batch_size 16 \ @@ -117,7 +117,7 @@ Extracts patches at salient points, trains on center pixels only (matches WGSL s ### Full-Image Processes entire image with sliding window (matches WGSL): ```bash -./training/train_cnn.py \ +./cnn_v1/training/train_cnn.py \ --input training/input/ --target training/output/ \ --layers 3 --kernel_sizes 3,5,3 --epochs 10000 --batch_size 8 \ --checkpoint-every 1000 @@ -126,10 +126,10 @@ Processes entire image with sliding window (matches WGSL): ### Export & Validation ```bash # Generate shaders from checkpoint -./training/train_cnn.py --export-only checkpoints/checkpoint_epoch_5000.pth +./cnn_v1/training/train_cnn.py --export-only checkpoints/checkpoint_epoch_5000.pth # Generate ground truth (sliding window, no tiling) -./training/train_cnn.py --infer input.png \ +./cnn_v1/training/train_cnn.py --infer input.png \ --export-only checkpoints/checkpoint_epoch_5000.pth \ --output ground_truth.png ``` @@ -327,7 +327,7 @@ See `doc/ASSET_SYSTEM.md` and `doc/WORKSPACE_SYSTEM.md`. **Note:** `--weights` loads layer count and kernel sizes from the binary file, overriding `--layers` and forcing CNN v2. -See `doc/CNN_TEST_TOOL.md` for full documentation. +See `cnn_v1/docs/CNN_TEST_TOOL.md` for full documentation. --- diff --git a/src/app/test_demo.cc b/src/app/test_demo.cc index f512a5f..ff2c105 100644 --- a/src/app/test_demo.cc +++ b/src/app/test_demo.cc @@ -20,7 +20,7 @@ extern float GetDemoDuration(); extern void LoadTimeline(MainSequence& main_seq, const GpuContext& ctx); // Inline peak meter effect for debugging audio-visual sync -#include "effects/cnn_effect.h" +#include "../../cnn_v1/src/cnn_v1_effect.h" #include "../../cnn_v2/src/cnn_v2_effect.h" #include "gpu/post_process_helper.h" #include "gpu/shader_composer.h" diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h index 60ca581..6b22f3f 100644 --- a/src/gpu/demo_effects.h +++ b/src/gpu/demo_effects.h @@ -18,7 +18,7 @@ // Individual Effect Headers #include "effects/chroma_aberration_effect.h" #include "effects/circle_mask_effect.h" -#include "effects/cnn_effect.h" +#include "../../cnn_v1/src/cnn_v1_effect.h" #include "../../cnn_v2/src/cnn_v2_effect.h" #include "effects/distort_effect.h" #include "effects/fade_effect.h" diff --git a/src/tests/gpu/test_demo_effects.cc b/src/tests/gpu/test_demo_effects.cc index ec78c10..8726e55 100644 --- a/src/tests/gpu/test_demo_effects.cc +++ b/src/tests/gpu/test_demo_effects.cc @@ -12,7 +12,7 @@ #include "../common/effect_test_helpers.h" #include "../common/webgpu_test_fixture.h" -#include "effects/cnn_effect.h" +#include "../../../cnn_v1/src/cnn_v1_effect.h" #include "gpu/demo_effects.h" #include "gpu/effect.h" #include <cassert> @@ -89,7 +89,7 @@ static void test_post_process_effects() { {"ThemeModulationEffect", std::make_shared<ThemeModulationEffect>(fixture.ctx())}, {"VignetteEffect", std::make_shared<VignetteEffect>(fixture.ctx())}, - {"CNNEffect", std::make_shared<CNNEffect>(fixture.ctx())}, + {"CNNv1Effect", std::make_shared<CNNv1Effect>(fixture.ctx())}, {"CNNv2Effect", std::make_shared<CNNv2Effect>(fixture.ctx())}, }; diff --git a/tools/cnn_test.cc b/tools/cnn_test.cc index 7d060ae..137d235 100644 --- a/tools/cnn_test.cc +++ b/tools/cnn_test.cc @@ -5,7 +5,7 @@ #error "cnn_test requires STRIP_ALL=OFF (tool builds only)" #endif -#include "effects/cnn_effect.h" +#include "../cnn_v1/src/cnn_v1_effect.h" #include "generated/assets.h" #include "gpu/bind_group_builder.h" #include "gpu/gpu.h" diff --git a/training/README.md b/training/README.md index e78b471..bddf4d5 100644 --- a/training/README.md +++ b/training/README.md @@ -174,6 +174,6 @@ pip install torch torchvision pillow opencv-python numpy ## References -- **CNN Effect:** `doc/CNN_EFFECT.md` +- **CNN Effect:** `cnn_v1/docs/CNN_V1_EFFECT.md` - **Timeline:** `doc/SEQUENCE.md` - **HOWTO:** `doc/HOWTO.md` diff --git a/workspaces/main/assets.txt b/workspaces/main/assets.txt index e1cf2bc..189e965 100644 --- a/workspaces/main/assets.txt +++ b/workspaces/main/assets.txt @@ -37,13 +37,13 @@ SHADER_PASSTHROUGH, NONE, ../../common/shaders/passthrough.wgsl, "Passthrough Sh SHADER_ELLIPSE, NONE, shaders/ellipse.wgsl, "Ellipse Shader" SHADER_PARTICLE_SPRAY_COMPUTE, NONE, shaders/particle_spray_compute.wgsl, "Particle Spray Compute" SHADER_GAUSSIAN_BLUR, NONE, shaders/gaussian_blur.wgsl, "Gaussian Blur Shader" -SHADER_CNN_ACTIVATION, NONE, shaders/cnn/cnn_activation.wgsl, "CNN Activation Functions" -SHADER_CNN_CONV1X1, NONE, shaders/cnn/cnn_conv1x1.wgsl, "CNN 1x1 Convolution" -SHADER_CNN_CONV3X3, NONE, shaders/cnn/cnn_conv3x3.wgsl, "CNN 3x3 Convolution" -SHADER_CNN_CONV5X5, NONE, shaders/cnn/cnn_conv5x5.wgsl, "CNN 5x5 Convolution" -SHADER_CNN_CONV7X7, NONE, shaders/cnn/cnn_conv7x7.wgsl, "CNN 7x7 Convolution" -SHADER_CNN_WEIGHTS, NONE, shaders/cnn/cnn_weights_generated.wgsl, "CNN Weights (Generated)" -SHADER_CNN_LAYER, NONE, shaders/cnn/cnn_layer.wgsl, "CNN Layer Shader" +SHADER_CNN_ACTIVATION, NONE, ../../cnn_v1/shaders/cnn_activation.wgsl, "CNN Activation Functions" +SHADER_CNN_CONV1X1, NONE, ../../cnn_v1/shaders/cnn_conv1x1.wgsl, "CNN 1x1 Convolution" +SHADER_CNN_CONV3X3, NONE, ../../cnn_v1/shaders/cnn_conv3x3.wgsl, "CNN 3x3 Convolution" +SHADER_CNN_CONV5X5, NONE, ../../cnn_v1/shaders/cnn_conv5x5.wgsl, "CNN 5x5 Convolution" +SHADER_CNN_CONV7X7, NONE, ../../cnn_v1/shaders/cnn_conv7x7.wgsl, "CNN 7x7 Convolution" +SHADER_CNN_WEIGHTS, NONE, ../../cnn_v1/shaders/cnn_weights_generated.wgsl, "CNN Weights (Generated)" +SHADER_CNN_LAYER, NONE, ../../cnn_v1/shaders/cnn_layer.wgsl, "CNN Layer Shader" SHADER_CNN_V2_STATIC, NONE, ../../cnn_v2/shaders/cnn_v2_static.wgsl, "CNN v2 Static Features" SHADER_CNN_V2_COMPUTE, NONE, ../../cnn_v2/shaders/cnn_v2_compute.wgsl, "CNN v2 Compute (Storage Buffer)" WEIGHTS_CNN_V2, NONE, ../../cnn_v2/weights/cnn_v2_weights.bin, "CNN v2 Binary Weights" diff --git a/workspaces/main/timeline.seq b/workspaces/main/timeline.seq index 05d9026..b4663bb 100644 --- a/workspaces/main/timeline.seq +++ b/workspaces/main/timeline.seq @@ -29,12 +29,12 @@ SEQUENCE 16.00 2 "Hybrid3D + CNN" EFFECT + ParticleSprayEffect 0.00 2.00 EFFECT = ParticlesEffect 2.00 4.00 EFFECT + Hybrid3DEffect 0.00 4.00 - EFFECT + CNNEffect 0.00 4.00 layers=3 blend=.9 + EFFECT + CNNv1Effect 0.00 4.00 layers=3 blend=.9 SEQUENCE 20.00 0 "CNN effect" EFFECT + HeptagonEffect 0.00 8.00 EFFECT + Scene1Effect 0.00 8.00 - EFFECT + CNNEffect 6.00 8.00 layers=3 blend=.5 + EFFECT + CNNv1Effect 6.00 8.00 layers=3 blend=.5 SEQUENCE 28.00 0 "buggy" EFFECT + HeptagonEffect 0.00 2.00 |
