Model Ready
API Docs
Convolutional Neural Network Design

Model Architecture & Engineering

An in-depth breakdown of layer dimensions, parameter counts, optimization strategies, and the parameter-efficient GlobalAveragePooling2D classifier design.

Trainable Parameters
421,441
1.61 MB active weights
Total Model Footprint
4.82 MB
1,264,325 total parameters
Input Resolution
224 ร— 224
3 RGB Color Channels
Feature Depth
256 Filters
4 Conv-Pool Stages
Key Optimization

GlobalAveragePooling2D vs. Traditional Flattening

Overfitting Prevention
โŒ Traditional Flatten Approach

Flatten Layer (36,864 Features)

Flattening the final 12 ร— 12 ร— 256 feature map produces 36,864 linear inputs, requiring 4.72 Million parameters for the dense layer alone (over 5.1M total parameters).

Dense Layer Params: 4,718,720
  • High risk of severe overfitting on training textures
  • Massive memory and disk storage requirements
  • Sluggish inference times on edge/CPU environments
โœ… GreenSort GlobalAveragePooling2D

Spatial Average Pooling (256 Features)

Computes the average activation across each feature map, directly condensing spatial dimensions to 256 values. The Dense layer requires only 32,896 parameters (~99.3% parameter reduction).

Dense Layer Params: 32,896 (99.3% reduction)
  • Significantly improved unseen generalization (92.04% Test Acc)
  • Eliminates spatial location bias in waste photos
  • Compact 4.82 MB file size enables rapid startup (<50ms)
Layer Specifications

Layer-by-Layer Network Topology

Keras Sequential Model
# Layer Name Layer Type Output Shape Kernel / Details Param #
0 input_layer Input / RGB (None, 224, 224, 3) Standard RGB Image 0
1 rescaling_5 Rescaling (None, 224, 224, 3) Scale pixels to [0, 1] 0
2 conv2d_37 Conv2D (None, 222, 222, 32) 32 filters, 3ร—3, ReLU 896
3 max_pooling2d_37 MaxPooling2D (None, 111, 111, 32) Pool size 2ร—2, Stride 2 0
4 conv2d_38 Conv2D (None, 109, 109, 64) 64 filters, 3ร—3, ReLU 18,496
5 max_pooling2d_38 MaxPooling2D (None, 54, 54, 64) Pool size 2ร—2, Stride 2 0
6 conv2d_39 Conv2D (None, 52, 52, 128) 128 filters, 3ร—3, ReLU 73,856
7 max_pooling2d_39 MaxPooling2D (None, 26, 26, 128) Pool size 2ร—2, Stride 2 0
8 conv2d_40 Conv2D (None, 24, 24, 256) 256 filters, 3ร—3, ReLU 295,168
9 max_pooling2d_40 MaxPooling2D (None, 12, 12, 256) Pool size 2ร—2, Stride 2 0
10 global_avg_pool GlobalAveragePooling2D (None, 256) Spatial Average Pooling 0
11 dense_22 Dense (None, 128) 128 Units, ReLU 32,896
12 dropout_11 Dropout (None, 128) Drop probability = 0.5 0
13 dense_23 Dense (Output) (None, 1) Sigmoid Binary Activation 129
Total Trainable Parameters 421,441 (1.61 MB)
Optimizer State (Adam Moments) 842,884 (3.22 MB)
Grand Total Parameters 1,264,325 (4.82 MB)
Hyperparameters

Training Configuration

Optimizer Adam (Adaptive Moment Estimation)
Learning Rate ($\alpha$) 0.001
Loss Function Binary Crossentropy
Batch Size 32 Images per Step
Training Epochs 15 Total Epochs
Steps per Epoch 565 Batches
Total Training Time ~101 minutes (~6.7 min / epoch)
Evaluation Latency 79 Test Steps in ~23 seconds
Production Pipeline

Inference Preprocessing & Decision Logic

1
Image Decoding & RGB Conversion:
Accepts JPEG, PNG, WEBP, BMP up to 15 MB and converts to 3-channel RGB.
2
High-Quality Resizing:
Resized to (224, 224) using Lanczos interpolation preserving edges and textures.
3
Batch Vectorization & Scaling:
Expanded to (1, 224, 224, 3). The in-graph Rescaling(1/255) normalizes pixel values without external scaling dependencies.
4
Sigmoid Decision Boundary:
Output $\sigma(z) \in [0, 1]$ represents recyclable probability:
โ€ข If $\sigma(z) \ge 0.5 \implies$ Class R (Recyclable), Confidence $= \sigma(z)$
โ€ข If $\sigma(z) < 0.5 \implies$ Class O (Organic), Confidence $= 1.0 - \sigma(z)$