# Image Classifier Node Configurations

These configuration files are automatically copied to user projects during `mecha10 init` or when adding the image-classifier node via `mecha10 add image-classifier`.

## Directory Structure

```
configs/
├── dev/
│   └── config.json         # Development settings (lower rate, lower threshold)
├── production/
│   └── config.json         # Production settings (higher rate, higher threshold)
└── common/
    └── config.json         # Shared settings (balanced defaults)
```

## Config Hierarchy

When running the image-classifier node, configs are merged in this order:
1. **common/config.json** - Base settings
2. **{environment}/config.json** - Environment-specific overrides (dev/production)
3. **Environment variables** - Runtime overrides

## Configuration Schema

```json
{
  "input_topic": "/camera/rgb",
  "output_topic": "/vision/classification",
  "processing_rate_hz": 10,
  "top_k": 5,
  "model": {
    "name": "mobilenet-v2"
  }
}
```

### Fields

| Field | Type | Description |
|-------|------|-------------|
| `input_topic` | string | Camera topic to subscribe to |
| `output_topic` | string | Topic to publish classification results |
| `processing_rate_hz` | number | How many frames per second to process (1-30) |
| `top_k` | number | Number of top predictions to include in results |
| `model.name` | string | Model name from catalog (e.g., "mobilenet-v2", "resnet18") |

## Environment Profiles

### Development (`dev/config.json`)
- **Processing Rate**: 5 Hz (process every 6th frame at 30 FPS)
- **Use Case**: Low CPU usage, fast iteration
- **Top-K**: 5 predictions

### Common (`common/config.json`)
- **Processing Rate**: 10 Hz (process every 3rd frame at 30 FPS)
- **Use Case**: Balanced performance and accuracy
- **Top-K**: 5 predictions

### Production (`production/config.json`)
- **Processing Rate**: 30 Hz (process every frame)
- **Use Case**: Maximum accuracy, requires more CPU
- **Top-K**: 3 predictions (only most confident)

## Swapping Models

To use a different model, just change the `model.name` field:

```json
{
  "model": {
    "name": "resnet18"  // Changed from mobilenet-v2
  }
}
```

Available models:
- `mobilenet-v2` - Fast, 2.5MB (recommended)
- `resnet18` - More accurate, 44MB

See `packages/cli/model_catalog.toml` for full list.

## Where Configs Are Copied

During `mecha10 init` or `mecha10 add image-classifier`, these files are copied to:

```
<project-root>/
└── configs/
    ├── dev/
    │   └── nodes/
    │       └── image-classifier/
    │           └── config.json
    ├── production/
    │   └── nodes/
    │       └── image-classifier/
    │           └── config.json
    └── common/
        └── nodes/
            └── image-classifier/
                └── config.json
```

## Customization

Users can customize these configs in their projects without modifying the framework. Changes in the project override the framework defaults.

## Adding New Models

To add a new model to the catalog:

```bash
# From monorepo root
pnpm models:add
```

Or manually edit `packages/cli/model_catalog.toml`.

See `docs/guides/ADDING_MODELS.md` for details.
