# tearcake/video-sentiment-model architecture

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

- Interactive diagram: https://gitdiagram.com/tearcake/video-sentiment-model
- Repository: https://github.com/tearcake/video-sentiment-model

## Overview

This repository trains and serves a tri-modal video emotion and sentiment classifier. MELD examples are tokenized and converted into text, frame, and audio features; the training loop optimizes emotion and sentiment heads and saves a model. At inference, a video request is transcribed and split into utterances, processed, classified, and serialized. SageMaker scripts support cloud training and endpoint deployment. The main training and inference paths are sampled; some inference details and the deployment model’s runtime wiring are not, so uncertain links are omitted.

Main entry points: [`deployment/inference.py`](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py) (Inference handler), [`training/train.py`](https://github.com/tearcake/video-sentiment-model/blob/main/training/train.py) (Training loop), [`deployment/deploy_endpoint.py`](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/deploy_endpoint.py) (Model repackaging), [`train_sagemaker.py`](https://github.com/tearcake/video-sentiment-model/blob/main/train_sagemaker.py) (Cloud training launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["MELD Training"]
  node_dataset["Dataset loader<br/>[meld_dataset.py]"]
  node_trainloop["Training loop<br/>[train.py]"]
  node_trainer["Trainer and metrics<br/>[models.py]"]
end

subgraph group_model["Classification Models"]
  node_trainmodel["Multimodal model<br/>[models.py]"]
  node_deploymodel["Serving model<br/>[models.py]"]
end

subgraph group_serving["Video Inference"]
  node_handler["Inference handler<br/>[inference.py]"]
  node_transcriber["Speech transcription<br/>[inference.py]"]
  node_utterances["Utterance segmentation<br/>[inference.py]"]
  node_processors["Audio/video processing<br/>[inference.py]"]
  node_response["JSON predictions<br/>[inference.py]"]
end

subgraph group_cloud["SageMaker Cloud"]
  node_s3model[("Model artifacts")]
  node_cloudtrain["Cloud training launcher<br/>[train_sagemaker.py]"]
  node_repackage["Model repackaging<br/>[deploy_endpoint.py]"]
  node_endpoint["Endpoint provisioning<br/>[deploy_endpoint.py]"]
end

node_user(("Video requester"))
node_meld[("MELD dataset")]
node_sagemaker["SageMaker"]

node_meld -->|"provides examples"| node_dataset
node_trainloop -->|"loads batches"| node_dataset
node_trainloop -->|"creates trainer"| node_trainer
node_trainloop -->|"creates model"| node_trainmodel
node_trainer -->|"trains and evaluates"| node_trainmodel
node_trainloop -->|"saves weights"| node_s3model
node_cloudtrain -->|"launches training"| node_sagemaker
node_cloudtrain -->|"configures entry script"| node_trainloop
node_s3model -->|"downloads artifact"| node_repackage
node_repackage -->|"uploads package"| node_s3model
node_repackage -->|"provides model package"| node_endpoint
node_endpoint -->|"creates endpoint"| node_sagemaker
node_user -->|"submits video"| node_handler
node_handler -->|"transcribes video"| node_transcriber
node_handler -->|"extracts segments"| node_utterances
node_utterances -->|"uses processors"| node_processors
node_handler -.->|"runs predictions"| node_deploymodel
node_handler -->|"serializes result"| node_response
node_endpoint -->|"runs inference code"| node_handler

click node_dataset "https://github.com/tearcake/video-sentiment-model/blob/main/training/meld_dataset.py"
click node_trainloop "https://github.com/tearcake/video-sentiment-model/blob/main/training/train.py"
click node_trainer "https://github.com/tearcake/video-sentiment-model/blob/main/training/models.py"
click node_trainmodel "https://github.com/tearcake/video-sentiment-model/blob/main/training/models.py"
click node_deploymodel "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/models.py"
click node_cloudtrain "https://github.com/tearcake/video-sentiment-model/blob/main/train_sagemaker.py"
click node_repackage "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/deploy_endpoint.py"
click node_endpoint "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/deploy_endpoint.py"
click node_handler "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py"
click node_transcriber "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py"
click node_utterances "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py"
click node_processors "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py"
click node_response "https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.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_dataset,node_trainloop,node_trainer toneBlue
class node_trainmodel,node_deploymodel,node_meld toneAmber
class node_handler,node_transcriber,node_utterances,node_processors,node_response,node_user toneMint
class node_s3model,node_cloudtrain,node_repackage,node_endpoint toneRose
class node_sagemaker toneIndigo
```

## Components

### MELD Training

- [Dataset loader](https://github.com/tearcake/video-sentiment-model/blob/main/training/meld_dataset.py): `training/meld_dataset.py`
- [Training loop](https://github.com/tearcake/video-sentiment-model/blob/main/training/train.py): `training/train.py`
- [Trainer and metrics](https://github.com/tearcake/video-sentiment-model/blob/main/training/models.py): `training/models.py`

### Classification Models

- [Multimodal model](https://github.com/tearcake/video-sentiment-model/blob/main/training/models.py): `training/models.py`
- [Serving model](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/models.py): `deployment/models.py`

### Video Inference

- [Inference handler](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py): `deployment/inference.py`
- [Speech transcription](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py): `deployment/inference.py`
- [Utterance segmentation](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py): `deployment/inference.py`
- [Audio/video processing](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py): `deployment/inference.py`
- [JSON predictions](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/inference.py): `deployment/inference.py`

### SageMaker Cloud

- **Model artifacts**
- [Cloud training launcher](https://github.com/tearcake/video-sentiment-model/blob/main/train_sagemaker.py): `train_sagemaker.py`
- [Model repackaging](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/deploy_endpoint.py): `deployment/deploy_endpoint.py`
- [Endpoint provisioning](https://github.com/tearcake/video-sentiment-model/blob/main/deployment/deploy_endpoint.py): `deployment/deploy_endpoint.py`

### Other components

- **Video requester**
- **MELD dataset**
- **SageMaker**

## Connections

- MELD dataset → Dataset loader: provides examples (evidence: `README.md`)
- Training loop → Dataset loader: loads batches (evidence: `training/train.py`)
- Training loop → Trainer and metrics: creates trainer (evidence: `training/train.py`)
- Training loop → Multimodal model: creates model (evidence: `training/train.py`)
- Trainer and metrics → Multimodal model: trains and evaluates (evidence: `training/models.py`)
- Training loop → Model artifacts: saves weights (evidence: `training/train.py`)
- Cloud training launcher → SageMaker: launches training (evidence: `train_sagemaker.py`)
- Cloud training launcher → Training loop: configures entry script (evidence: `train_sagemaker.py`)
- Model artifacts → Model repackaging: downloads artifact (evidence: `deployment/deploy_endpoint.py`)
- Model repackaging → Model artifacts: uploads package (evidence: `deployment/deploy_endpoint.py`)
- Model repackaging → Endpoint provisioning: provides model package (evidence: `deployment/deploy_endpoint.py`)
- Endpoint provisioning → SageMaker: creates endpoint (evidence: `deployment/deploy_endpoint.py`)
- Video requester → Inference handler: submits video (evidence: `deployment/inference.py`)
- Inference handler → Speech transcription: transcribes video (evidence: `deployment/inference.py`)
- Inference handler → Utterance segmentation: extracts segments (evidence: `deployment/inference.py`)
- Utterance segmentation → Audio/video processing: uses processors (evidence: `deployment/inference.py`)
- Inference handler → Serving model: runs predictions
- Inference handler → JSON predictions: serializes result (evidence: `deployment/inference.py`)
- Endpoint provisioning → Inference handler: runs inference code (evidence: `deployment/deploy_endpoint.py`)
