Skip to content

Codebase analysis: fix 5 runtime bugs and create missing src/data package - #1

Draft
Krishna-Modi12 with Copilot wants to merge 2 commits into
masterfrom
copilot/analyse-codebase
Draft

Codebase analysis: fix 5 runtime bugs and create missing src/data package#1
Krishna-Modi12 with Copilot wants to merge 2 commits into
masterfrom
copilot/analyse-codebase

Conversation

Copilot AI commented Mar 8, 2026

Copy link
Copy Markdown

Full analysis of the Face Analysis AI V6 codebase. Found and fixed 5 bugs that would cause crashes or silent training failures, plus created a missing module that made every main entry point unrunnable.

Bugs Fixed

Critical: src/data/ package missing (ModuleNotFoundError)

predict.py, eval_multitask_proper.py, train_multitask_v3.py, and scripts/debug_predictions_v2.py all import from src.data.dataset — the package simply didn't exist. Created src/data/dataset.py with:

  • FaceAnalysisDataset — multi-task dataset reading the build_multitask_annotations.py JSON format (shape, eye, brow, lip, age, gender, landmarks, Monk skin scale)
  • extract_hsv_histogram_np — normalised 48-dim HSV histogram used by SkinTower
  • get_train_transforms / get_val_transforms

Also fixed .gitignoredata/ glob was suppressing the new src/data/ source package.

Critical: SkinTower called with wrong arity (TypeError)

train_multitask_v3.py called self.model.skin_tone_head(detached_features) but SkinTower.forward requires (bb_features, hsv_histogram):

# before — TypeError at first training step
skin_tone_logits = self.model.skin_tone_head(detached_features)

# after
hsv_placeholder = torch.zeros(detached_features.shape[0], 48, device=detached_features.device)
skin_tone_logits = self.model.skin_tone_head(detached_features, hsv_placeholder)

High: skin_tone_head excluded from optimizer param groups

get_optimizer_param_groups() in FaceAnalysisModel listed every head except skin_tone_head, so its weights never received gradient updates when using FaceAnalysisLightningModule. Added list(self.skin_tone_head.parameters()) to head_params.

High: Wrong LOSS_WEIGHTS key names in MultiTaskLoss (KeyError)

losses.py looked up weights['shape'], weights['features'], weights['skin'] but LOSS_WEIGHTS in config.py uses face_shape_weight, features_weight, skin_tone_weight.

Low: Dead computation in FaceAnalysisModel.forward()

fused = self._get_fused_features(features, geometric_ratios) was computed on every forward pass and immediately discarded — the face shape head calls it internally. Removed.

Documentation

Added CODEBASE_ANALYSIS.md covering architecture (all 14 prediction heads, data flow, training phases), dataset sources, all bugs found, performance benchmarks, and known remaining limitations.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…base analysis

Co-authored-by: Krishna-Modi12 <178945358+Krishna-Modi12@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze the entire codebase for improvements Codebase analysis: fix 5 runtime bugs and create missing src/data package Mar 8, 2026
@Krishna-Modi12

Copy link
Copy Markdown
Owner

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants