# mohitagarwal17/caninesense architecture

> Architecture diagram of the GitHub repository mohitagarwal17/caninesense, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohitagarwal17/caninesense
- Repository: https://github.com/mohitagarwal17/caninesense

## Overview

CanineSense provides a two-stage dog-emotion inference workflow: a caller submits an image to the pipeline, which rejects non-dogs or classifies a dog’s emotion and optionally produces a Grad-CAM++ explanation. Separate notebooks document model training and explainability experimentation. The README describes shared preprocessing and external datasets; the sampled source confirms inference calls and model loading. Notebook internals and model-weight files were not sampled, so those relationships are based on README documentation.

Main entry points: [`src/pipeline.py`](https://github.com/mohitagarwal17/caninesense/blob/main/src/pipeline.py) (Prediction pipeline), [`src/dog_or_not.py`](https://github.com/mohitagarwal17/caninesense/blob/main/src/dog_or_not.py) (Dog gate), [`src/emotion.py`](https://github.com/mohitagarwal17/caninesense/blob/main/src/emotion.py) (Emotion classifier), [`src/gradcam_utils.py`](https://github.com/mohitagarwal17/caninesense/blob/main/src/gradcam_utils.py) (Grad-CAM++ maps)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Inference pipeline"]
  node_pipeline["Prediction pipeline<br/>[pipeline.py]"]
  node_dog_gate["Dog gate<br/>[dog_or_not.py]"]
  node_emotion["Emotion classifier<br/>[emotion.py]"]
end

subgraph group_shared["Shared model services"]
  node_preprocess["Image preprocessing<br/>[preprocessing.py]"]
  node_model_loader["Learner loader<br/>[model_io.py]"]
end

subgraph group_training["Model training"]
  node_dog_training["Dog-gate training"]
  node_emotion_training["Emotion training"]
end

subgraph group_explainability["Explainability"]
  node_gradcam["Grad-CAM++ maps<br/>[gradcam_utils.py]"]
  node_xai_notebook["Inference and XAI notebook"]
end

node_caller(("Image caller"))
node_dog_dataset[("Dog vs. non-dog dataset")]
node_emotion_dataset[("Dog emotion dataset")]

node_caller -->|"submits image"| node_pipeline
node_pipeline -->|"checks dog"| node_dog_gate
node_pipeline -->|"classifies dog"| node_emotion
node_pipeline -->|"requests explanation"| node_gradcam
node_dog_gate -->|"preprocesses image"| node_preprocess
node_emotion -->|"preprocesses image"| node_preprocess
node_gradcam -->|"preprocesses image"| node_preprocess
node_dog_gate -->|"loads learner"| node_model_loader
node_emotion -->|"loads learner"| node_model_loader
node_dog_dataset -->|"trains on"| node_dog_training
node_emotion_dataset -->|"trains on"| node_emotion_training
node_dog_training -.->|"trains gate"| node_dog_gate
node_emotion_training -.->|"trains classifier"| node_emotion
node_xai_notebook -.->|"experiments with"| node_gradcam

click node_pipeline "https://github.com/mohitagarwal17/caninesense/blob/main/src/pipeline.py"
click node_dog_gate "https://github.com/mohitagarwal17/caninesense/blob/main/src/dog_or_not.py"
click node_emotion "https://github.com/mohitagarwal17/caninesense/blob/main/src/emotion.py"
click node_preprocess "https://github.com/mohitagarwal17/caninesense/blob/main/src/preprocessing.py"
click node_model_loader "https://github.com/mohitagarwal17/caninesense/blob/main/src/model_io.py"
click node_dog_training "https://github.com/mohitagarwal17/caninesense/blob/main/notebooks/01_dog_or_not_training.ipynb"
click node_emotion_training "https://github.com/mohitagarwal17/caninesense/blob/main/notebooks/02_emotion_classifier_training.ipynb"
click node_gradcam "https://github.com/mohitagarwal17/caninesense/blob/main/src/gradcam_utils.py"
click node_xai_notebook "https://github.com/mohitagarwal17/caninesense/blob/main/notebooks/03_inference_gradcam_xai.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pipeline,node_dog_gate,node_emotion toneBlue
class node_preprocess,node_model_loader,node_dog_dataset,node_emotion_dataset toneAmber
class node_dog_training,node_emotion_training toneMint
class node_gradcam,node_xai_notebook toneRose
class node_caller toneIndigo
```

## Components

### Inference pipeline

- [Prediction pipeline](https://github.com/mohitagarwal17/caninesense/blob/main/src/pipeline.py): `src/pipeline.py`
- [Dog gate](https://github.com/mohitagarwal17/caninesense/blob/main/src/dog_or_not.py): `src/dog_or_not.py`
- [Emotion classifier](https://github.com/mohitagarwal17/caninesense/blob/main/src/emotion.py): `src/emotion.py`

### Shared model services

- [Image preprocessing](https://github.com/mohitagarwal17/caninesense/blob/main/src/preprocessing.py): `src/preprocessing.py`
- [Learner loader](https://github.com/mohitagarwal17/caninesense/blob/main/src/model_io.py): `src/model_io.py`

### Model training

- [Dog-gate training](https://github.com/mohitagarwal17/caninesense/blob/main/notebooks/01_dog_or_not_training.ipynb): `notebooks/01_dog_or_not_training.ipynb`
- [Emotion training](https://github.com/mohitagarwal17/caninesense/blob/main/notebooks/02_emotion_classifier_training.ipynb): `notebooks/02_emotion_classifier_training.ipynb`

### Explainability

- [Grad-CAM++ maps](https://github.com/mohitagarwal17/caninesense/blob/main/src/gradcam_utils.py): `src/gradcam_utils.py`
- [Inference and XAI notebook](https://github.com/mohitagarwal17/caninesense/blob/main/notebooks/03_inference_gradcam_xai.ipynb): `notebooks/03_inference_gradcam_xai.ipynb`

### Other components

- **Image caller**
- **Dog vs. non-dog dataset**
- **Dog emotion dataset**

## Connections

- Image caller → Prediction pipeline: submits image (evidence: `README.md`)
- Prediction pipeline → Dog gate: checks dog (evidence: `src/pipeline.py`)
- Prediction pipeline → Emotion classifier: classifies dog (evidence: `src/pipeline.py`)
- Prediction pipeline → Grad-CAM++ maps: requests explanation (evidence: `src/pipeline.py`)
- Dog gate → Image preprocessing: preprocesses image (evidence: `src/dog_or_not.py`)
- Emotion classifier → Image preprocessing: preprocesses image (evidence: `src/emotion.py`)
- Grad-CAM++ maps → Image preprocessing: preprocesses image (evidence: `src/gradcam_utils.py`)
- Dog gate → Learner loader: loads learner (evidence: `src/dog_or_not.py`)
- Emotion classifier → Learner loader: loads learner (evidence: `src/emotion.py`)
- Dog vs. non-dog dataset → Dog-gate training: trains on (evidence: `README.md`)
- Dog emotion dataset → Emotion training: trains on (evidence: `README.md`)
- Dog-gate training → Dog gate: trains gate (evidence: `README.md`)
- Emotion training → Emotion classifier: trains classifier (evidence: `README.md`)
- Inference and XAI notebook → Grad-CAM++ maps: experiments with (evidence: `README.md`)
