Downloads · 30 days
4
8% of all-time downloads
smilelab/visual-valence-model
visual-valence-model is a machine learning model from smilelab. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
A deep neural network model of associative emotional (Pavlovian fear) learning.
Downloads · 30 days
4
8% of all-time downloads
All-time downloads
50
Public
Repo size
2.3 GB
Likes
0
Public
Click a slice to open those files.
.pth2.3 GB · 100%
From the Hugging Face model README
A deep neural network model of associative emotional (Pavlovian fear) learning.
Companion model repository for "Associative Emotional Learning in Convolutional Neural Networks" (Leem, Keil, Ding & Fang; Neural Computation, in press).
Note: This model is a research artifact for computational/cognitive neuroscience, released to reproduce and extend the paper's findings. It is not a general-purpose sentiment/emotion API and is not validated for clinical, diagnostic, or production affective-computing use.
The Visual-Valence Model predicts the affective valence of a visual scene (1 = extreme displeasure, 9 = extreme pleasure) and reproduces hallmarks of Pavlovian (fear) conditioning when a novel, initially neutral stimulus is repeatedly paired with an emotionally-charged one.
The architecture (Visual_Cortex_Amygdala in models/VGG_Model.py)
has three components, loosely modeling the primate visual/affective pathway:
| Component | Role | Implementation |
|---|---|---|
| Visual Cortex module ("High Road") | Ventral visual stream | VGG-16 (Simonyan & Zisserman, 2015), ImageNet-pretrained, frozen |
| Shortcut Pathway ("Middle Road") | Fast, low-resolution route from early vision to affect circuitry | Multi-scale pooling of VGG-16's early layers (layer index 10), combined via an Efficient Channel Attention (ECA) module (Wang et al., 2020) |
| Valence Module | Combines both pathways into a scalar valence judgment | Two fully-connected layers (amygdala LA/CE-nuclei- and OFC-inspired) + one sigmoid output unit |
The High Road output (4096-d) and Middle Road output (512-d) are concatenated (4608-d) and passed through
the Valence Module's fully connected layers to a single sigmoid unit, which is linearly rescaled from
[0, 1] to the [1, 9] IAPS valence scale at evaluation time.
This repository hosts every checkpoint along the training pipeline described in the
GitHub README — same architecture
(Visual_Cortex_Amygdala) throughout, so any of them can be loaded with the same code:
| File | Stage | Description |
|---|---|---|
vca_ckvideo_batch128_lr2e-5_epoch20.pth | 0 | Trained from scratch on the Cowen & Keltner Videoframe dataset |
vca_IAPS_batch10_lr2e-4_epoch23.pth | 1 | Fine-tuned on full-size IAPS images |
base_model_vca_IAPS_quadrant.pth | 2 | Fine-tuned to the quadrant-cropped input layout — pre-conditioning: has learned to decode valence from natural scenes (the US) but has never seen the conditioned stimulus (CS, a Gabor patch) |
base_model_conditioned_orientation_epoch1.pth | 3, epoch 1 | First epoch of Pavlovian conditioning (CS+ Gabor patch paired with pleasant/unpleasant IAPS US); early/under-trained, kept for provenance |
base_model_conditioned_orientation_epoch100.pth | 3, epoch 100 | Post-conditioning (final) — used throughout the paper's conditioning/generalization/representational-alignment analyses |
Comparing the pre- (Stage 2) and post-conditioning (Stage 3, epoch 100) checkpoints' responses to the CS alone is what reveals the learned CS→valence association (and, at the representation level, the increasing CS/US alignment reported in the paper).
Visual_Cortex_Amygdala_wo_Attention) for research purposes.Channel_Activity_Extraction.py,
Manifold_Visualization.py, SVM_Analysis_*.py in the GitHub repo) for downstream neuroscience analyses.Out of scope: general-purpose sentiment analysis, affect recognition on non-IAPS-like natural images, clinical/diagnostic use, or any decision-making about real individuals' emotional states.
Model quality is reported using:
reg_eval_model / cond_eval_model in utils.py.Channel_Activity_Extraction.py, Manifold_Visualization.py,
SVM_Analysis_Emotion.py, SVM_Analysis_Before_After.py) are used to assess whether conditioning
reproduces human associative-learning signatures.The full quantitative results (per-stage R/MSE, generalization curves, and alignment statistics) are reported in the paper's tables/figures — see https://arxiv.org/abs/2607.19327.
Training proceeds in stages, each building on the previous stage's checkpoint (see the GitHub README's Training section for exact commands):
| Stage | Dataset | Purpose |
|---|---|---|
| 0 | Cowen & Keltner (2017) Videoframe dataset (2,185 emotion-eliciting video clips, one frame sampled every 10th frame) | Pretrain valence regression from scratch on natural scenes |
| 1 | International Affective Picture System (IAPS; Bradley & Lang, 1994/2007), full-size images, 8:1:1 train/val/test split | Adapt to the US stimuli used in conditioning |
| 2 | IAPS, quadrant-cropped layout | Fine-tune to the spatial layout used during conditioning |
| 3 | IAPS (US, in the 4th quadrant) × Gabor patches (CS, in the 2nd quadrant; 45°/135° orientation, varying spatial frequency/contrast, generated via Gabor4Seowung.m) | Pavlovian conditioning: pair CS+ with pleasant/unpleasant US |
Labels are human valence ratings on a 1–9 scale (Self-Assessment Manikin; Bradley & Lang, 1994). The IAPS images themselves are not redistributed with the code or this model repository due to a data-use/confidentiality agreement — obtain access to IAPS independently to reproduce training from scratch. The Gabor-patch CS stimuli are procedurally generated and have no such restriction.
Note the input layout differs by stage: Stage 0/1 checkpoints expect a full-frame natural image (resize + normalize only), while Stage 2/3 checkpoints expect the quadrant-cropped layout (see Data preprocessing in the GitHub README) — feeding a full-frame image to a Stage 2/3 checkpoint (or vice versa) will not reproduce the reported behavior.
This is a plain PyTorch checkpoint (not a transformers model), so inference requires the model class
definition from the companion GitHub repository. See inference_example.py in
this repository for a complete, runnable example. In short:
git clone https://github.com/lab-smile/FearConditioningAI.git
cd FearConditioningAI
pip install -r requirements.txt # or: conda env create -f environment-<platform>.yml
import torch
from huggingface_hub import hf_hub_download
from models.VGG_Model import Visual_Cortex_Amygdala
repo_id = "smilelab/visual-valence-model"
# swap in any filename from the checkpoint table above, e.g. "vca_ckvideo_batch128_lr2e-5_epoch20.pth"
ckpt_path = hf_hub_download(repo_id=repo_id, filename="base_model_conditioned_orientation_epoch100.pth")
model = Visual_Cortex_Amygdala()
checkpoint = torch.load(ckpt_path, map_location="cpu", weights_only=False)
model.load_state_dict(checkpoint["state_dict"], strict=False)
model.eval()
See inference_example.py for image preprocessing (resize/normalize + quadrant placement of the CS/US)
and how to rescale the model's sigmoid output back to the 1–9 valence scale.
If you use this model, please cite the paper:
@article{leem2026associative,
title = {Associative Emotional Learning in Convolutional Neural Networks},
author = {Leem, Seowung and Keil, Andreas and Ding, Mingzhou and Fang, Ruogu},
journal = {Neural Computation},
year = {2026},
note = {in press},
eprint = {2607.19327},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2607.19327}
}
Please also cite the datasets and methods this model builds on (IAPS, Cowen & Keltner Videoframe, SAM, VGG-16, ImageNet, ECA-Net, Rescorla-Wagner) — full references in the GitHub README's Citations section.
This model is released under the MIT License, matching the GitHub repository.
| Name | |
|---|---|
| Seowung Leem | leem.s@ufl.edu |
| Dr. Ruogu Fang | ruogu.fang@bme.ufl.edu |