Introduction
Image Sentiment Analysis (ISA) aims to automatically predict the emotional response evoked by visual stimuli. While deep learning has significantly advanced computer vision, sentiment remains a subjective and context-dependent field. A single visual scene can elicit vastly different emotions depending on the underlying context—for instance, a crowded street might represent "excitement" in a festival setting but "fear" during a period of civil unrest.
Traditional models often focus exclusively on pixel-level data, potentially missing the semantic nuances that humans use to interpret emotion. To bridge this gap, we present SentiFormer, a novel transformer-based framework that integrates visual features with automatically generated metadata—including natural language captions, object tags, and scene categories—to provide a richer context for sentiment prediction.
Methodology
SentiFormer operates through a three-stage pipeline designed to extract, weight, and fuse multi-modal information.
1. Feature Representation and Metadata Generation
Recognizing that many sentiment datasets lack descriptive metadata, SentiFormer employs a suite of pre-trained models to generate contextual information:
- Captions: Generated via BLIP to provide a natural language description of the image.
- Object Tags: Extracted using Faster R-CNN to identify the top-10 most prominent objects.
- Scene Tags: Identified using Hiera to categorize the overall environment (e.g., "beach," "forest").
All visual and textual components are then projected into a unified 512-dimensional semantic space using a CLIP-based encoder, ensuring compatibility across modalities.
2. Adaptive Relevance Learning
Not all metadata is equally relevant to the sentiment of every image. SentiFormer introduces an Adaptive Relevance Learning module utilizing Multi-Head Attention (MHA). By treating visual features as the "query" and metadata as "keys" and "values," the model dynamically weights the contribution of each metadata type. This allows the system to prioritize scene tags for landscapes or object tags for close-up portraits, effectively filtering out "noise" that does not contribute to the emotional signal.
3. Cross-modal Fusion
The final stage utilizes a deep Cross-modal Transformer stack. This module fuses the visual features with the weighted metadata representations. A dedicated "class token" is prepended to the sequence to aggregate global sentiment information, which is then passed to a final classification head.
Experimental Results
SentiFormer was evaluated against several state-of-the-art (SOTA) benchmarks, including the FI (Flickr & Instagram) and Twitter_LDL datasets.
Performance Benchmarks
The model demonstrated significant improvements over existing methods:
- FI Dataset: SentiFormer achieved an accuracy of 79.48%, representing a substantial ~6% improvement over the previous SOTA (OEAN at 73.40%).
- Twitter_LDL: The model reached 74.12% accuracy, outperforming previous benchmarks by nearly 4%.
Zero-Shot Generalization
To test the robustness of the learned emotional concepts, the model was evaluated on the Artphoto dataset in a zero-shot setting (trained on FI, tested on Artphoto). SentiFormer achieved 47.83% accuracy, significantly outperforming other transformer-based models like EmoVIT (44.90%) and MAM (39.56%). This suggests that the inclusion of metadata helps the model move beyond simple pixel-pattern recognition toward a more generalized understanding of sentiment.
Discussion and Ablation Studies
Ablation experiments confirmed that the synergy between different metadata types is key to the model's success. The removal of any single component—captions, object tags, or scene tags—resulted in a measurable decline in performance. Furthermore, the use of "heuristic prompts" (e.g., "the scene is [SceneTag], and the image contains [ObjectTags]") was found to be more effective than feeding raw tags into the encoder, as it provides the model with better structural cues for understanding the relationships between keywords.
Conclusion
SentiFormer demonstrates that metadata is a powerful tool for enhancing image sentiment analysis. By intelligently fusing visual data with generated textual context, the model achieves new state-of-the-art results and shows improved generalization. While the reliance on multiple pre-trained models introduces computational overhead, the performance gains highlight the importance of context in the computational modeling of human emotion. Future work will focus on optimizing the pipeline for real-time applications and exploring methods to handle lower-quality or missing metadata.
Summary updated