Role Breakdown

Responsibility Lead
Data Collection & Preprocessing Anupam Patil
Text Model Development Nandini Soni
Image Model Development Anupam Patil
Fusion Model & Report Nandini Soni

Data

Dataset Overview

  • Source: TMDB API
  • D1: ~15,000 movies from 1975–2000
  • D2: ~17,000 movies from 2001–2025
  • Method: Collected using API querying by genre and year range, then parsed into structured metadata including title, overview, genres, and poster_path.
  • Merged Dataset – D3: Combined D1 and D2 into a unified dataset (D3: ~27,000 movies)
Dataset D1 Dataset D2 Dataset D2 Dataset D2

Exploratory Data Analysis

We used genre-wise filtering to equalize the number of samples across all 12 selected genres. Undersampled dominant genres to reduce label imbalance. Removing 3625 rows with no genres. Cleaned file saved (23645 rows remain).

Text pipeline
Text pipeline Text pipeline
Genre bar chart Genre pie chart

Challenges & Solutions

  • Genre Imbalance
    Used undersampling to balance the dataset by reducing the number of samples from overrepresented genres, ensuring more equitable genre representation for model training.
  • Multi-label Complexity
    Handled each movie having multiple genres by converting genres into multi-hot encoded vectors, enabling the model to learn multi-label outputs.
  • Sparse Genre Combinations
    Explored genre co-occurrence via EDA visualizations (heatmaps/bar plots) to understand which combinations are most/least common, guiding informed preprocessing choices like filtering or merging underrepresented combinations.
  • Data Loss from Undersampling
    Carefully tuned the undersampling threshold to maintain genre diversity without excessively discarding useful data, balancing model fairness and generalization.

Final Cleaned Dataset

Dataset Overview:

movie_id title overview poster_path poster_file genres title_length overview_length num_genre source_genre Drama Comedy Documentary Romance Action Thriller Horror Crime Music Animation TV Movie Family
86497 Wide Open A philandering cab driver decides to help his girlfriend's attractive sister, who is in trouble with drug dealers. /uzIFp9Wu4QPyTJ1eqgkcIVYud7S.jpg /content/drive/MyDrive/Tmdb_posters_custom/movie_posters/86497.jpg ['Comedy', 'Drama'] 9 114 2 ['Drama', 'Comedy'] 1 1 0 0 0 0 0 0 0 0 0 0
16219 Gladiator Tommy Riley has moved with his dad to Chicago from a 'nice place'. He keeps to himself, goes to school... /w0YjBWVfu689txEXZG3xa4Aev3i.jpg /content/drive/MyDrive/Tmdb_posters_custom/movie_posters/16219.jpg ['Drama', 'Action'] 9 236 2 ['Drama', 'Action'] 1 0 0 0 1 0 0 0 0 0 0 0
512062 Vinayapoorvam Vidyadharan Vidyadharan is a bank employee, who loses his job due to his wife's extravagant lifestyle... /t4P0xquN818fyhMdsCsGR5BecV5.jpg /content/drive/MyDrive/Tmdb_posters/movie_posters/512062.jpg ['Comedy', 'Family', 'Drama'] 25 172 3 ['Drama', 'Comedy', 'Family'] 1 1 0 0 0 0 0 0 0 0 1 1
43089 Roadgames A truck driver plays a cat-and-mouse game with a mysterious serial killer in a van... /zj3eE1lNkp3oWWnOHu4Aj7Gkqj2.jpg /content/drive/MyDrive/Tmdb_posters_custom/movie_posters/43089.jpg ['Thriller', 'Mystery', 'Horror'] 9 158 2 ['Thriller', 'Horror'] 0 0 0 0 0 1 1 0 0 0 0 0
270016 Elvis by the Presleys Priscilla Presley, her daughter, their family and their friends open their hearts in the backdrop of Graceland... /rdYML6V994npU7RKcnjijLIJ8Fj.jpg /content/drive/MyDrive/Tmdb_posters_custom/movie_posters/270016.jpg ['Music', 'Documentary'] 21 152 2 ['Documentary', 'Music'] 0 0 1 0 0 0 0 0 1 0 0 0
Download CSV

Split Management

LSTM accuracy

Text Model

Text Cleaning and Transformation Pipeline

The NLTK library is used to preprocess movie overviews by tokenizing, removing stopwords, and lemmatizing text to create clean, standardized inputs for the model.

Cleaned and Tokenized Movie Overviews:

  • Text Preprocessing:
    • Tokenized movie overviews using NLTK's word_tokenize.
    • Built vocabulary from tokenized words with <unk> for unknown tokens.
    • Converted texts to index sequences.
    • Fixed input length: 300 tokens, padded with <unk> as needed.
LSTM accuracy LSTM confusion matrix

Baseline LSTM with GloVe Embeddings

GloVe embeddings are used to provide pre-trained, static word vectors for representing movie overviews as numerical inputs to the LSTM model for genre classification.

  • Embeddings:
    • Source: GloVe (glove-wiki-gigaword-100), preloaded with Gensim.
    • Embedding Dimension: 100
    • nn.Embedding.from_pretrained() used to load embedding matrix.
    • Frozen embeddings (not fine-tuned during training).
  • Model Architecture:
    • Embedding Layer: Initialized with pretrained GloVe vectors.
    • LSTM Layer:
      • 1-layer unidirectional LSTM
      • Hidden Dimension: 32
      • batch_first=True, dropout=0.3 applied inside the LSTM.
LSTM accuracy
LSTM F1 Micro
LSTM F1 Macro

LSTM with Bert Tokenizer V1

  • Text Preprocessing:
    • Cleaned movie overviews used as input.
    • Tokenized using bert-base-uncased tokenizer.
    • Padded/truncated to fixed length: 256 tokens.
    • Used tokenizer(text, max_length=..., padding='max_length', truncation=True) for uniform shape.
  • Label Preparation:
    • Multi-label binarization of genres using MultiLabelBinarizer.
    • Labels converted to binary vectors of size equal to number of genres (12).
  • Model Architecture:
    • Embedding Layer:
      • Used nn.Embedding layer initialized randomly.
      • Embedding Dimension: 128
      • Optionally frozen (freeze_embedding toggle).
    • LSTM Layer:
      • 2-layer BiLSTM
      • Hidden Dimension: 32
      • Output: Final hidden state from last time step (x[:, -1, :]), size (batch_size, 64) due to bidirectionality.
      • Applied Dropout (0.5) to LSTM output.
    • Classifier Head:
      • Fully Connected Layer: Linear(64 → 12) for multi-label output.
  • Output:
    • Raw logits (no sigmoid).
    • Used with BCEWithLogitsLoss for multi-label classification.
ParameterValue
Input Sequence Length256 tokens
Embedding Dimension128
LSTM Layers2
LSTM Hidden Dimension32 (bidirectional → output size 64)
Dropout Rate0.3
Output Size12
Loss FunctionBCEWithLogitsLoss (with class weights)
OptimizerAdam
Learning Rate1e-3
Weight Decay1e-5
Batch Size32
Epochs10
DeviceGPU (if available)
LSTM accuracy
LSTM F1 Micro
LSTM F1 Macro

LSTM with Bert Tokenizer V2

Final Text Model

This model addresses overfitting by tweaking hyperparameters such as the number of epochs and hidden dimensions, incorporating a learning rate scheduler, L2 regularization, dropout and using a Bidirectional LSTM architecture.

ParameterValue
Embedding LayerFrozen(non-trainable)
LSTM Hidden Dimension256 (bidirectional → output size 512)
Dropout Rate0.5
Loss FunctionBCEWithLogitsLoss
OptimizerAdamW
Learning Rate1e-4
Weight Decay1e-5
LR SchedulerReduceLROnPlateau (monitors val F1)
Epochs40

Results

Advanced LSTM Advanced LSTM Advanced LSTM Advanced LSTM

Predictions

Correct

LSTM accuracy

Misclassified

LSTM accuracy

Image Model

Preprocessing

Poster Standardization and Augmentation

Preprocessing Preprocessing

Post Preprocessing

Preprocessing

BASELINE IMAGE MODEL TRAIN TEST EfficientNet

    • Models: EfficientNet-B0 and B3
    • Dataset: TMDB Cleaned Dataset D3
    • Loss: BCEWithLogitsLoss
    • Optimizer: AdamW
    • Epochs: 20
    • Hyperparameters:
      • Batch Size: 32 and 64
      • Learning Rate: 0.001, 0.0004
      • Dropout: 0.3 and L2 Regularization in AdamW
      • Other Parameters:
        • CosineAnnealingLR (T_max = 20)
        • Transformations: Per Image transformations using torchvision transforms
  • EfficientNet_B3 with IMAGENET1K_V1

    Preprocessing

    EfficientNet-B3 Image Model V1

    EfficientNet-B3 Image Model V1

    • Image Preprocessing:
      • Input Conversion: Loaded poster images from local_poster_path and converted to RGB.
      • Training Augmentation:
        • Resized shorter side to 256 px.
        • Randomly cropped to 224 × 224 px.
        • Applied horizontal flip (p = 0.5).
        • Applied color jitter (brightness, contrast, saturation ± 0.1).
        • Converted to tensor and normalized (mean = [0.485, 0.456, 0.406], std = [0.229, 0.224, 0.225]).
      • Validation Preprocessing:
        • Resized to 256 px and center-cropped to 224 × 224 px.
        • Converted to tensor and normalized with same ImageNet statistics.
    • Label Preparation:
      • Multi-label binarization of genres via MultiLabelBinarizer, producing 12-dimensional multi-hot vectors stored as genre_label.
    • Model Architecture:
      • Base Model: Pretrained EfficientNet-B3 (EfficientNet_B3_Weights.IMAGENET1K_V1) with all MBConv + Squeeze-and-Excitation blocks intact, yielding a 1,536-dim feature vector.
      • Classifier Head:
        • Dropout layer (p = 0.3).
        • Fully connected layer (1,536 → 12).
    • Mixed-Precision Training:
      • Used torch.amp.autocast and GradScaler for faster, memory-efficient CUDA training.
    • Loss & Optimization:
      • Loss Function: BCEWithLogitsLoss with pos_weight = inverse mean frequency per genre.
      • Optimizer: AdamW (lr = 1 × 10⁻³, weight_decay = 1 × 10⁻⁴).
      • LR Scheduler: CosineAnnealingLR (T_max = 20 epochs).
    • Output:
      • Model returns raw logits of shape (batch_size × 12). At inference, apply sigmoid to convert logits to per-genre probabilities.

    EfficientNet-B0

    CNN architecture

    EfficientNet-B3

    CNN architecture

    ResNet Model

    Final Image Model

    Architecture.

    • Input Layer: Receives the input image.
    • Initial Convolution and Pooling:
      • Convolution Layer: 7×7 kernel, 64 filters, stride 2.
      • Batch Normalization: Normalizes the output of the convolution layer.
      • ReLU Activation: Applies the ReLU activation function.
      • Max Pooling: 3×3 kernel, stride 2.
    • Residual Blocks:
      • Conv2_x: 3 residual blocks with 64 filters each.
      • Conv3_x: 4 residual blocks with 128 filters each.
      • Conv4_x: 6 residual blocks with 256 filters each.
      • Conv5_x: 3 residual blocks with 512 filters each.
      • Each residual block contains:
        • Two 3×3 convolutional layers.
        • Batch normalization and ReLU activation after each convolution.
        • A skip connection that adds the input of the block to its output.
    • Final Layers:
      • Global Average Pooling: Reduces each feature map to a single value.
      • Fully Connected Layer: Outputs the final classification scores.
      • Softmax Activation: Converts scores to probabilities.

    IMAGE MODEL TRAIN TEST ResNet 18(V2), ResNet 50(V1)

    TO CONTROL OVERFITTING VARIED HYPERPARAMETERS AND SELECTED BELOW FOR DESIRED RESULTS

    • Models: ResNet 18, 50 (Used ResNet18 based on results)
    • Dataset: → TMDB Cleaned Dataset D3
    • Loss: BCEWithLogitsLoss
    • Optimizer: AdamW
    • Epochs: 20
    • Hyperparameters:
      • Batch Size: 32 and 64
      • Learning Rate: 0.0001
      • Dropout: 0.3
      • L2 Regularization in optimizer
      • Weight Decay: 1e-4
      • LR Scheduler: ReduceLROnPlateau (lower the learning rate by a factor of 0.1 based on val loss)
      Image model results

    Results

    Image model results Image model results Fusion metrics

    Single Genre Confusion Matrix

    Fusion metrics Fusion metrics Fusion metrics

    Predictions

    Fusion metrics Fusion metrics Fusion metrics

    Multimodal Fusion Model

    Architecture

    FUSION MODEL TRAIN TEST (LSTM with BERT Tokenizer + ResNet with Poster Embeddings)

    • Fusion Strategy:
      • Applied attention-based fusion using Multihead Self-Attention to integrate text (LSTM output) and image (precomputed ResNet/EfficientNet embeddings).
      • This method learns to focus on the most informative parts of both modalities, improving genre prediction.
    • Text Model:
      • 2-layer BiLSTM on tokenized movie overview
      • Embedding Dimension: 128, Hidden Dimension: 256, Output Feature Size: 256
    • Image Model:
      • Used precomputed 1280-dimensional image embeddings from EfficientNet
      • Projected to 512-dimensional space using a linear layer with ReLU and Dropout
    • Fusion Layer:
      • Stacked text and image features into a sequence
      • Applied MultiheadAttention with 8 heads (embed dimension: 512)
      • Fused output by averaging attention outputs
      • Passed through Dropout and then Linear(512 → 12) for multi-label genre classification
    • Loss: BCEWithLogitsLoss
    • Optimizer: AdamW with L2 regularization (weight decay: 0.0001)
    • Epochs: 20
    • Hyperparameters:
      • Batch Size: 16
      • Learning Rate: 2e-5
      • Dropout: 0.3 (applied to text, image, and fusion layers)
      • L2 Regularization in AdamW

    Training & Evaluation

    Fusion metrics

  • Superior Multimodal Performance: Our fusion model blends text and image data, achieving a micro F1-score of ~0.47–0.50, surpassing text-only (0.4520) and image-only (0.3348) models by leveraging movie titles, overviews, and poster embeddings.
  • Navigating Multi-Label Challenges: With ~0.16–0.20 accuracy, the model navigates multi-label genre prediction challenges, outperforming text-only (0.1581) and image-only (0.1039) baselines despite the difficulty of exact label matches.
  • Stable and Efficient Training: The model shows steady loss reduction over 10 epochs, trained on CPU. Frozen text and image models limit optimization, but the fusion layer ensures stable performance.
  • Balancing Text and Image Strengths: Combining LSTM text features and ResNet image embeddings, the model balances genre cues, excelling in text-driven genres and improving on visually subtle ones, though limited by precomputed embeddings.
  • Results

    Metrics Comparison

    Model comparison bar graph

    Comparison Plots

    Text-Only

    Model comparison bar graph

    Image-Only

    Model comparison bar graph

    Fusion

    Model comparison bar graph

    Predictions

    Fusion metrics

    Potential Improvements:

    1. Cross-Modal Transformers or Co-Attention Networks:
      • Description: Replace separate models with multimodal transformers (e.g., VisualBERT, ViLT, MMBT) for unified text-image processing.
      • Requirements: Restructure data loaders and input pipelines to support a unified architecture. Accommodate longer training times due to increased complexity.
    2. Contrastive Multimodal Training:
      • Description: Implement contrastive loss for aligned text-image pairs, inspired by models like CLIP.
      • Requirements: Manage paired triplet data (text, image, label). Develop image-text matching logic. Modify the training objective to prioritize contrastive learning.
    3. Dynamic Routing or Gating Mechanisms:
      • Description: Introduce a gating mechanism to dynamically weigh text vs. image features based on sample characteristics.
      • Benefits: Enhances model adaptability to diverse genre styles. Challenges: Increases architectural complexity.

    Future Work

    Discussion & Future Work

    Lessons Learned

    This project provided valuable insights into multimodal deep learning,while leveraging transfer learning, particularly in combining diverse data types like textual overviews and poster images. Initially, we assumed both modalities would perform equally well, but we discovered that each excelled in different areas depending on the genre.

    • The LSTM+ BERT Tokenizer based text model effectively captured genres reliant on story structure, such as Drama and Documentary, using overview. However, it struggled with genres like Animation or Action, where visual context is more critical.
    • The Image model, utilizing ResNet-18 and EfficientNet-B3, performed better for genres with strong visual cues, such as Horror, Animation, or Family, but lacked the ability to capture context-heavy predictions.
    • The Fusion model with an attention mechanism significantly improved performance. By weighing the importance of each modality per sample, it enhanced predictions for mixed-genre cases like Crime & Drama or Comedy & Romance.

    We also encountered challenges with skewed data, particularly for underrepresented genres like TV Movie or Music, which were harder to predict due to their low frequency despite one-hot encoding and balanced sampling.

    Finally, we learned the importance of preprocessing. Cleaning the dataset, removing failed poster downloads, filtering for usable genres, and properly cleaning and tokenizing overview text were critical to achieving meaningful results. Without these steps, the models would have struggled to learn effectively.

    Potential Improvements

    To enhance the model’s performance and applicability, we propose the following improvements:

    1. Improving Dataset Balance: Despite filtering for the top 12 genres and using undersampling, some genres dominated the dataset. A more evenly distributed dataset with diverse genre combinations (e.g., Crime + Music or TV Movie + Family) would enable the model to learn subtle genre relationships and reduce reliance on dominant patterns.
    2. Replacing LSTM with Transformer-Based Models: The LSTM model performed adequately but struggled with longer plot overviews. Replacing the BiLSTM with transformer models like BERT or RoBERTa, which are pretrained on large corpora, could improve semantic understanding whilst ensuring a large dataset(preferably in millions). Our experiments with the BERT tokenizer suggest that integrating BERT embeddings end-to-end could yield better results.
    3. Limitations in Poster-Based Genre Modeling:
      • While our ResNet models was trained directly on poster images with data augmentation and class balancing, we acknowledge some limitations in our current image modeling approach. First, the model does not leverage the spatial layout or composition patterns typical to certain genres, such as title placement or character arrangement.
      • We did not extract or use on-poster text content (like taglines or actor names), which can provide semantic genre hints. Additionally, we used a fixed-size single-resolution input, which may miss details in complex poster layouts. Lastly, the model was not trained using contrastive learning or style-aware grouping, which could further improve generalization across genres with overlapping visual styles.
    4. Exploring Other Fusion Architectures: Our multihead self-attention fusion, inspired by Attention is All You Need, was effective, but advanced methods like co-attention or cross-modal transformers could better capture feature interactions. We plan to experiment with these architectures in future iterations.
    5. Applying Better Techniques for Class Imbalance: Genres like Music, TV Movie, and Crime had fewer samples, impacting performance. Incorporating class weights in the loss function or using oversampling techniques like SMOTE could generate more training examples for rare genres.
    6. Introducing More Modalities: Using audio or subtitle sentiment scores could provide additional context. For example, background score patterns could help distinguish Thriller from Horror.

    Research Papers That Helped Us

    • ResNet: Deep Residual Learning for Image Recognition (He, K., Zhang, X., Ren, S., & Sun, J., 2015)
      Guided our use of ResNet-18 by explaining the benefits of skip connections for stable training in deep CNNs.
    • EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks (Tan, M., & Le, Q. V., 2019)
      Informed our use of EfficientNet-B3 for extracting robust and scalable poster embeddings.
    • A Multi-Attention Approach Using BERT and Stacked Bidirectional LSTM for Improved Dialogue State Tracking (Khan, M. A., Huang, Y., Feng, J., Prasad, B. K., Ali, Z., Ullah, I., & Kefalas, P.)
      Provided insights into combining BERT with attention mechanisms, informing our consideration of transformer-based models for text processing.
    • Attention Is All You Need (Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., & Polosukhin, I.)
      Inspired our multihead self-attention fusion strategy, enabling effective integration of textual and visual features.

    Final Thoughts

    This project demonstrated the power of multimodal learning when effective fusion techniques are applied. Each modality contributed unique strengths, and the attention-based fusion architecture intelligently leveraged these to improve genre predictions.

    With a larger and more balanced dataset, end-to-end fine-tuning, and advanced architectures like BERT, GPT or co-attention-based fusion layers, the model’s performance can be significantly enhanced. For the image stream, exploring sophisticated convolutional architectures such as YOLO, EfficientNet-V2, or DenseNet-201 could capture deeper visual features and stylistic patterns in posters, particularly for diverse or high-resolution datasets.

    Course Certifications

    Nandini Soni

    Scientific Computing with Python

    View Certificate

    Data Analysis with Python

    View Certificate

    College Algebra with Python

    View Certificate

    Anupam Patil

    Scientific Computing with Python

    View Certificate

    Data Analysis with Python

    View Certificate

    College Algebra with Python

    View Certificate