Scene Understanding
Module: Computer Vision | Difficulty: Intermediate
Scene Classification
Places365
365 scene categories with CNN features.
Scene Graph Generation
Visual Relationship Detection
Scene Attribute Prediction
import torch
import torch.nn as nn
class SceneGraphHead(nn.Module):
def __init__(self, obj_classes, rel_classes, feat_dim=256):
super().__init__()
self.obj_embed = nn.Embedding(obj_classes, feat_dim)
self.rel_predictor = nn.Sequential(
nn.Linear(feat_dim * 3, 512),
nn.ReLU(True),
nn.Linear(512, rel_classes)
)
def forward(self, subj_feat, obj_feat, region_feat):
s = self.obj_embed(subj_feat)
o = self.obj_embed(obj_feat)
combined = torch.cat([s, o, region_feat], dim=1)
return self.rel_predictor(combined)
Key Takeaways
- Scene understanding goes beyond object detection
- Scene graphs represent relationships between objects
- Holistic analysis combines classification, detection, and description