# jhziiiig/care architecture

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

- Interactive diagram: https://gitdiagram.com/jhziiiig/care
- Repository: https://github.com/jhziiiig/care

## Overview

CARE preprocesses CASAS event streams into model-ready sequence and image representations, then jointly learns aligned representations and ADL classifications. Users can train/evaluate or test from a checkpoint, with K-fold tuning available. The excerpts show preprocessing outputs, model components, and training/evaluation code; some preprocessing and loader details are omitted, so those connections are documented or marked unverified rather than inferred from filenames.

Main entry points: [`ContrastLearning.py`](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py) (Training loop), [`DataGeneration.py`](https://github.com/jhziiiig/care/blob/main/DataGeneration.py) (Preprocessing), [`dataset`](https://github.com/jhziiiig/care/tree/main/dataset) (CASAS streams)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_preparation["Data preparation"]
  node_preprocess["Preprocessing<br/>[DataGeneration.py]"]
  node_segments["Segmented sequences<br/>[DataGeneration.py]"]
  node_sensor_images["Sensor images<br/>[DataGeneration.py]"]
  node_loader["Dataset loader"]
end

subgraph group_learning["Representation learning"]
  node_sequence_encoder["Sequence encoder"]
  node_image_encoder["Image encoder"]
  node_fusion_classifier["Fusion classifier"]
  node_contrastive_loss["Contrastive loss"]
  node_classification_loss["Classification loss"]
end

subgraph group_evaluation["Training and evaluation"]
  node_training["Training loop"]
  node_evaluation_run["Evaluation and tuning"]
end

subgraph group_artifacts["Model artifacts"]
  node_checkpoints["Checkpoints"]
  node_metrics["Metrics and logs"]
end

node_user(("Research user"))
node_casas["CASAS streams"]

node_user -->|"runs preprocessing"| node_preprocess
node_casas -->|"provides raw data"| node_preprocess
node_preprocess -->|"writes sequences"| node_segments
node_preprocess -.->|"renders images"| node_sensor_images
node_user -->|"starts training"| node_training
node_segments -.->|"loads sequences"| node_loader
node_sensor_images -.->|"loads images"| node_loader
node_loader -.->|"supplies batches"| node_training
node_training -->|"encodes sequences"| node_sequence_encoder
node_training -->|"encodes images"| node_image_encoder
node_sequence_encoder -.->|"provides features"| node_fusion_classifier
node_image_encoder -.->|"provides features"| node_fusion_classifier
node_training -->|"computes alignment loss"| node_contrastive_loss
node_training -->|"computes class loss"| node_classification_loss
node_training -->|"saves models"| node_checkpoints
node_user -->|"runs evaluation"| node_evaluation_run
node_checkpoints -->|"loads checkpoint"| node_evaluation_run
node_evaluation_run -->|"records metrics"| node_metrics
node_evaluation_run -->|"selects best model"| node_checkpoints

click node_casas "https://github.com/jhziiiig/care/tree/main/dataset"
click node_preprocess "https://github.com/jhziiiig/care/blob/main/DataGeneration.py"
click node_segments "https://github.com/jhziiiig/care/blob/main/DataGeneration.py"
click node_sensor_images "https://github.com/jhziiiig/care/blob/main/DataGeneration.py"
click node_loader "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_sequence_encoder "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_image_encoder "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_fusion_classifier "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_contrastive_loss "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_classification_loss "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_training "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_evaluation_run "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_checkpoints "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"
click node_metrics "https://github.com/jhziiiig/care/blob/main/ContrastLearning.py"

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_preprocess,node_segments,node_sensor_images,node_loader,node_user toneBlue
class node_sequence_encoder,node_image_encoder,node_fusion_classifier,node_contrastive_loss,node_classification_loss toneAmber
class node_training,node_evaluation_run toneMint
class node_checkpoints,node_metrics toneRose
class node_casas toneTeal
```

## Components

### Data preparation

- [Preprocessing](https://github.com/jhziiiig/care/blob/main/DataGeneration.py): `DataGeneration.py`
- [Segmented sequences](https://github.com/jhziiiig/care/blob/main/DataGeneration.py): `DataGeneration.py`
- [Sensor images](https://github.com/jhziiiig/care/blob/main/DataGeneration.py): `DataGeneration.py`
- [Dataset loader](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`

### Representation learning

- [Sequence encoder](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`
- [Image encoder](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`
- [Fusion classifier](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`
- [Contrastive loss](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`
- [Classification loss](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`

### Training and evaluation

- [Training loop](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`
- [Evaluation and tuning](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`

### Model artifacts

- [Checkpoints](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`
- [Metrics and logs](https://github.com/jhziiiig/care/blob/main/ContrastLearning.py): `ContrastLearning.py`

### Other components

- **Research user**
- [CASAS streams](https://github.com/jhziiiig/care/tree/main/dataset): `dataset`

## Connections

- Research user → Preprocessing: runs preprocessing (evidence: `README.md`)
- CASAS streams → Preprocessing: provides raw data (evidence: `README.md`)
- Preprocessing → Segmented sequences: writes sequences (evidence: `DataGeneration.py`)
- Preprocessing → Sensor images: renders images (evidence: `DataGeneration.py`)
- Research user → Training loop: starts training (evidence: `README.md`)
- Segmented sequences → Dataset loader: loads sequences
- Sensor images → Dataset loader: loads images
- Dataset loader → Training loop: supplies batches (evidence: `ContrastLearning.py`)
- Training loop → Sequence encoder: encodes sequences (evidence: `ContrastLearning.py`)
- Training loop → Image encoder: encodes images (evidence: `ContrastLearning.py`)
- Sequence encoder → Fusion classifier: provides features (evidence: `ContrastLearning.py`)
- Image encoder → Fusion classifier: provides features (evidence: `ContrastLearning.py`)
- Training loop → Contrastive loss: computes alignment loss (evidence: `ContrastLearning.py`)
- Training loop → Classification loss: computes class loss (evidence: `README.md`)
- Training loop → Checkpoints: saves models (evidence: `ContrastLearning.py`)
- Research user → Evaluation and tuning: runs evaluation (evidence: `README.md`)
- Checkpoints → Evaluation and tuning: loads checkpoint (evidence: `README.md`)
- Evaluation and tuning → Metrics and logs: records metrics (evidence: `ContrastLearning.py`)
- Evaluation and tuning → Checkpoints: selects best model (evidence: `ContrastLearning.py`)
