Skip to content

Integrate ResNet model pool and enhance image classification fine-tuning#148

Merged
tanganke merged 10 commits into
mainfrom
feature/resnet
Sep 15, 2025
Merged

Integrate ResNet model pool and enhance image classification fine-tuning#148
tanganke merged 10 commits into
mainfrom
feature/resnet

Conversation

@tanganke
Copy link
Copy Markdown
Owner

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.

Copilot AI review requested due to automatic review settings September 15, 2025 11:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space around the equality operator. This should be rank_zero_only.rank == 0 for proper Python style.

Suggested change
rank_zero_only.rank==0
rank_zero_only.rank == 0

Copilot uses AI. Check for mistakes.

model.classifier[1] = nn.Linear(
model.classifier[1].in_features,
len(classnames) if model.config.num_labels > 0 else nn.Identity(),
Copy link

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
len(classnames) if model.config.num_labels > 0 else nn.Identity(),
len(classnames) if model.config.num_labels > 0 else 0,

Copilot uses AI. Check for mistakes.
@tanganke tanganke merged commit 44a85d0 into main Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants