Integrate ResNet model pool and enhance image classification fine-tuning#148
Conversation
…t and resolve_checkpoint_path
…guration files, and ResNet model pool integration
…nd enhance dataset handling in image classification
…et model YAML files, and enhance initialization parameters
… with training and testing instructions
…ne-tuning with logging and model saving
…se trainer log directory if available
There was a problem hiding this comment.
Pull Request Overview
This PR integrates ResNet model pool support and enhances image classification fine-tuning capabilities within FusionBench, providing comprehensive infrastructure for training and testing ResNet models on standard datasets.
- Adds ResNet model pool support for both torchvision and transformers backends
- Introduces enhanced image classification fine-tuning with PyTorch Lightning integration
- Creates comprehensive configuration files and documentation for ResNet fine-tuning workflows
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| mkdocs.yml | Adds new ResNet guides section to documentation navigation |
| fusion_bench/utils/rich_utils.py | Imports rich traceback functionality for better error reporting |
| fusion_bench/utils/path.py | Adds symlink creation utility with rank-zero decorator |
| fusion_bench/utils/lazy_state_dict.py | Enhances checkpoint loading with improved documentation and comments |
| fusion_bench/tasks/clip_classification/init.py | Adds convenience functions for dataset metadata access |
| fusion_bench/programs/fusion_program.py | Creates new standard fusion program without Lightning Fabric |
| fusion_bench/programs/fabric_fusion_program.py | Updates import to use lightning_utilities |
| fusion_bench/programs/init.py | Registers the new ModelFusionProgram class |
| fusion_bench/modelpool/resnet_for_image_classification.py | Implements ResNet model pool for image classification |
| fusion_bench/modelpool/base_pool.py | Adds dataset availability check properties |
| fusion_bench/modelpool/init.py | Registers ResNet model pool in lazy imports |
| fusion_bench/method/classification/image_classification_finetune.py | Implements ResNet fine-tuning and testing methods |
| fusion_bench/method/classification/init.py | Converts to lazy imports and adds new methods |
| fusion_bench/method/init.py | Registers new fine-tuning methods |
| fusion_bench/dataset/clip_dataset.py | Extends processor support to include BaseImageProcessor |
| fusion_bench/init.py | Exports ResNet model pool in package API |
| docs/guides/resnet/image_classification_finetune.md | Creates comprehensive ResNet fine-tuning guide |
| config/modelpool/ResNetForImageClassfication/* | Adds ResNet model pool configurations |
| config/model_fusion.yaml | Creates main fusion configuration file |
| config/method/classification/* | Adds fine-tuning method configurations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| # create symbol link to hydra output directory | ||
| if ( | ||
| self.fabric.is_global_zero | ||
| rank_zero_only.rank==0 |
There was a problem hiding this comment.
Missing space around the equality operator. This should be rank_zero_only.rank == 0 for proper Python style.
| rank_zero_only.rank==0 | |
| rank_zero_only.rank == 0 |
|
|
||
| model.classifier[1] = nn.Linear( | ||
| model.classifier[1].in_features, | ||
| len(classnames) if model.config.num_labels > 0 else nn.Identity(), |
There was a problem hiding this comment.
This expression returns an integer when num_labels > 0 but a class (nn.Identity) when num_labels <= 0. The nn.Linear constructor expects an integer for out_features. This should likely be len(classnames) if model.config.num_labels > 0 else 0 or similar logic.
| len(classnames) if model.config.num_labels > 0 else nn.Identity(), | |
| len(classnames) if model.config.num_labels > 0 else 0, |
…ion_finetune and clean up whitespace in state_dict_arithmetic
This PR integrates the ResNet model pool, enhances image classification fine-tuning with logging and model saving, and updates related configuration and documentation.\n\nKey changes:\n- Integrate ResNet model pool\n- Enhance image classification fine-tuning with logging and model saving\n- Add and update configuration files for ResNet and image classification\n- Improve documentation and guides for fine-tuning\n- Refactor and improve code quality in related modules\n\nPlease review and provide feedback.