Paul Kumswa Submission - #5
Open
PaulKumswa wants to merge 16 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Implements the missing scaffold sections for the steel surface defect classification final project, covering the end-to-end pipeline from data loading and preprocessing through model training, checkpointing, inference, and Streamlit UI display, plus adds MkDocs-based project documentation.
Changes:
- Implemented CNN model definition, training/validation loops, and checkpoint saving.
- Implemented dataset scanning/splitting and Albumentations preprocessing pipelines.
- Added inference + Streamlit result wiring and introduced MkDocs configuration/docs content (plus a data prep script and a committed runtime log).
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| final_project/steel_defect/train.py | Implements loss/optimizer setup, train/val epochs, and best-checkpoint saving. |
| final_project/steel_defect/preprocessing.py | Adds training and validation Albumentations transform pipelines. |
| final_project/steel_defect/model.py | Defines the SteelCNN architecture and forward pass. |
| final_project/steel_defect/inference.py | Implements checkpoint loading and single-image prediction with class scores. |
| final_project/steel_defect/dataset.py | Implements dataset directory scanning, stratified splits, and __getitem__. |
| final_project/steel_defect/app.py | Wires inference results into the Streamlit “Prediction” stats panel. |
| final_project/requirements.txt | Adds MkDocs dependencies. |
| final_project/mkdocs.yml | Adds MkDocs site configuration for project docs. |
| final_project/logs/app.log | Adds a generated application/training log file to the repo. |
| final_project/docs/index.md | Adds a project writeup for MkDocs. |
| final_project/data_prep.py | Adds a dataset reorganization/copy script for preparing class folders. |
Suppressed comments (5)
final_project/steel_defect/preprocessing.py:80
- Same as training transforms: this should use the shared IMAGE_SIZE constant rather than a hardcoded (256, 256) to stay consistent with the documented behavior and avoid future drift.
A.Resize(256, 256),
final_project/docs/index.md:25
- Spelling: “abou” → “about”.
Model info: It has abou 103k params, and convolutional blocks with 32, 64, and 128 output channels.
final_project/docs/index.md:29
- Spelling: “onl” → “only”.
The training loop used a CrossEntropyLoss loss function, an Adam optimizer, learning rate of 0.001, and a batch size of 32. I used onl a CPU for training and the model ran for 20 epochs.
final_project/docs/index.md:33
- Spelling: “tranin gtime” → “training time”.
Total tranin gtime was about 4 hours for me, and epoch 17 had the best validation accuracy. My final validation accuracy was 0.791.
final_project/docs/index.md:37
- Spelling/capitalization: “streamlitapp” → “Streamlit app”, and start the sentence with “My”.
I was able to run the application in streamlitapp, with about 60ms of inference time. my final model accuracy was 79.1%.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # raise NotImplementedError("PREPROCESS-1: Implement training transforms") | ||
|
|
||
| return A.Compose([ | ||
| A.Resize(256, 256), |
Comment on lines
+98
to
+100
| checkpoint = torch.load(self.checkpoint_path, map_location=self.device) | ||
| model = SteelCNN(num_classes=NUM_CLASSES) | ||
| model.load_state_dict(checkpoint["model_state_dict"]) |
Comment on lines
+95
to
+96
| if not self.checkpoint_path.exists(): | ||
| raise FileNotFoundError("No checkpoint found") |
Comment on lines
+193
to
+196
| loaded_image = cv2.imread(image_path) | ||
| if loaded_image is None: | ||
| raise FileNotFoundError("No image at filepath") | ||
| loaded_image = cv2.cvtColor(loaded_image, cv2.COLOR_BGR2RGB) |
|
|
||
| ## Data Preprocessing | ||
|
|
||
| The preprocessing had traning and validation pipelines. All images were resized to 256x256. In order to augement training, images were given a random flip probability and also a random brightness contrast. The flip and brightness were not added to validation, for the sake of reproducibility. |
Comment on lines
+8
to
+22
| #create paths | ||
| project_root = Path(__file__).resolve().parent | ||
| raw_root = project_root / "data" / "severstal-steel-defect-detection" | ||
| csv_path = raw_root / "train.csv" | ||
| train_images_path = raw_root / "train_images" | ||
| steel_defect_path = project_root / "data" / "steel_defect" | ||
| print(project_root) | ||
| print(raw_root) | ||
| print(csv_path) | ||
|
|
||
| # loading csv | ||
| df = pd.read_csv(csv_path) | ||
| print(df.shape) | ||
| print(df.columns) | ||
| print(df.head()) |
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.
No description provided.