# marks0kolov/chimuffnet architecture

> Architecture diagram of the GitHub repository marks0kolov/chimuffnet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marks0kolov/chimuffnet
- Repository: https://github.com/marks0kolov/chimuffnet

## Overview

##### Project type and purpose
- This is a standalone Python-based AI inference tool (“Muffin vs Chihuahua Detector”).
- It loads an ONNX image‐classification model, applies it to one or more input images, and prints out predicted labels with confidence.

##### File structure
- run_model.py
– Entry point for inference.
– Parses CLI args, loads model + labels, traverses input path, runs inference.
- model/
– model.onnx (trained ResNet-18 fine-tuned for muffin vs chihuahua)
– labels.txt (maps output indices to class names)
- readme_images/
– Documentation assets only (no runtime role)
- README.md, LICENSE, .gitignore

No “build” or “deploy” scripts—this is a simple client tool.

##### Insights from README
- Describes inference workflow: CLI → ONNX Runtime → label mapping → console output.
- Mentions training was done externally (not in this repo).
- Lists external dependencies: Python3, ONNX Runtime (and optionally NVIDIA Jetson Orin Nano if accelerated).

A. CLI Frontend
- Parses flags: --model, --labels, --input
- Supports single image or batch folder
B. Pre-processing Module
- Reads image file(s)
- Resizes, normalizes pixel values
C. ONNX Inference Engine
- Loads model.onnx via ONNX Runtime
- Executes forward pass to produce raw logits
D. Post-processing Module
- Applies softmax on logits
- Maps top index to human-readable label from labels.txt
E. Output / Reporting
- Prints “Class: X, Confidence: Y” to console

F. External Dependencies (sidepiece)
- Python 3 interpreter
- ONNX Runtime library
- (Optional) GPU / Jetson hardware accelerator

##### Architectural patterns & principles
- Pipeline pattern: clear separation between stages (ingest → preprocess → infer → postprocess → output).
- Single-responsibility: each module has one clear task.
- Extensibility point: swapping model.onnx for different ONNX models without code change.

##### Details to capture
- CLI argument parsing (flags)
- Single image vs batch folder loop
- ONNX Runtime load and session creation
- Console output formatting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Pipeline stages
    CLI[/CLI Frontend/]:::io
    Pre[Pre-processing Module]:::proc
    Inference[ONNX Inference Engine]:::infer
    Post[Post-processing Module]:::proc
    Console[/Console Output/]:::io

    %% Data stores
    Model[(model.onnx)]:::data
    Labels[(labels.txt)]:::data

    %% External dependencies
    subgraph "External Dependencies"
        Py["Python 3 Interpreter"]:::ext
        ORT["ONNX Runtime Library"]:::ext
        GPU["Optional GPU / Jetson"]:::ext
    end

    %% Data flow
    CLI -->|parses CLI args| Pre
    Pre -->|processed image tensors| Inference
    Model -->|loaded model| Inference
    Inference -->|raw logits| Post
    Post -->|mapped label & confidence| Console
    Post -.->|lookup index| Labels

    %% Click events
    click CLI "https://github.com/marks0kolov/chimuffnet/blob/main/run_model.py"
    click Pre "https://github.com/marks0kolov/chimuffnet/blob/main/run_model.py"
    click Inference "https://github.com/marks0kolov/chimuffnet/blob/main/run_model.py"
    click Post "https://github.com/marks0kolov/chimuffnet/blob/main/run_model.py"
    click Console "https://github.com/marks0kolov/chimuffnet/blob/main/run_model.py"
    click Model "https://github.com/marks0kolov/chimuffnet/blob/main/model/model.onnx"
    click Labels "https://github.com/marks0kolov/chimuffnet/blob/main/model/labels.txt"

    %% Styles
    classDef io fill:#d4f1be,stroke:#333
    classDef proc fill:#aed6f1,stroke:#333
    classDef infer fill:#f5b041,stroke:#333
    classDef data fill:#d5dbdb,stroke:#333
    classDef ext fill:#f7dc6f,stroke:#333
```
