Lab 5 - #5
Open
tutoringjedi wants to merge 5 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PULL REQUEST TITLE: UofT-DSI | Deep Learning - Lab 5
What changes are you trying to make?
Fixing a series of bugs in lab_5.ipynb (the object detection notebook) that were preventing it from running end-to-end, and completing the "build a better model" exercise. Changes include:
Restoring extract_xml_annotation to its original form after a stray edit had broken it
Fixing tensorize_ground_truth to work with the flattened annotation format ({"size", "filename", "class", "bbox"}) instead of assuming the old nested "objects" structure
Adding the missing call classes, boxes = tensorize_ground_truth(annotations), which had been defined but never invoked
Fixing display_prediction and compute_acc to read annotations in the correct flat format
Removing a duplicate cell that was silently overwriting the trained better_model with fresh random weights before evaluation
Adding a stale-cache check when loading voc_representations.h5, so a mismatched cache from an earlier run can't cause a length mismatch
Implementing classif_and_loc, the two-headed (classification + localization) model for the exercise, using a Conv2D layer before global average pooling plus dropout, trained with Adam(learning_rate=1e-4)
What did you learn from the changes you have made?
That annotations needs to hold a single consistent shape throughout the whole notebook — inconsistent formats for the same variable (nested vs. flattened) across cells is what caused most of the KeyErrors. Also reinforced that a function being defined doesn't mean it's been called — silent gaps like that are easy to miss when scanning a long notebook cell by cell rather than tracing the full variable lifecycle.
Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?
Considered keeping multiple objects per image (instead of filtering down to single-object images) and flattening to one row per object rather than one row per image, which would make the dataset closer to a true multi-object detection setup. Went with the single-object simplification instead, consistent with how the notebook was originally structured.
Were there any challenges? If so, what issue(s) did you face? How did you overcome it?
The main challenge was a Python/TensorFlow environment mismatch on Windows — a .venv, a conda env (deep-learning-env), and base anaconda3 were all layered on top of each other, so the notebook's Jupyter kernel wasn't necessarily the one active in the terminal. Resolved by explicitly registering ipykernel inside the conda env and confirming via pip show tensorflow and where python that the kernel and terminal were pointing at the same environment. Also hit a dead GitHub mirror for the PASCAL VOC 2007 dataset and switched to the pjreddie.com mirror with a fallback to the original host.
How were these changes tested?
Verified all cells parse without syntax errors. Traced the notebook's full variable lifecycle (annotations → reprs → classes/boxes → model inputs) cell by cell to confirm consistent data shapes throughout, rather than testing cells in isolation.
A reference to a related issue in your repository (if applicable)
(add issue link here if you have one)
Checklist