-
Notifications
You must be signed in to change notification settings - Fork 4
Major Inference Refactor & Performance Optimization 🚀 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kahnertk
wants to merge
7
commits into
main
Choose a base branch
from
performance-optimization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
Key changes: - Create new SubCellDataset class with pandas-based CSV reading - Refactor inference.py to handle batched data processing instead of single images - Add progress tracking with tqdm progress bars - Add tqdm dependency to requirements - Fix bug in image_utils.py (convert_bitdepth parameter error) - Adapt variable naming in min_max_standardize function - Add command-line arguments for batch processing control - Add quiet mode option to reduce verbose logging
…o 15.5h for 2.56M images Major optimizations implemented: - Async file saving with ThreadPoolExecutor to reduce I/O bottlenecks - H5AD output format option for efficient batch storage - Embeddings-only mode to skip classification when not needed - Optimized image loading with tifffile for TIFF images and PIL for others - Min-max normalization option for better image preprocessing - Immediate GPU memory cleanup after each batch - Configurable attention map saving (disabled by default in async mode) Performance improvements: - Batch processing with async I/O operations - Memory-efficient data handling - Optimized image loading pipeline - Reduced disk I/O overhead Note: This is work in progress and needs cleanup and testing, but is working and has achieved significant performance gains.
Major architectural improvements, bug fixes, and performance enhancements: ## Architecture & Refactoring - Split monolithic process.py into modular components (config.py, cli.py, model_loader.py, output_handlers.py) - Added comprehensive type hints throughout - Enhanced error handling with specific exceptions and actionable messages ## Critical Bug Fixes - Fixed attention map saving (was passing None after GPU cleanup) - Fixed duplicate normalization (images normalized twice - dataset + inference) - Fixed output format naming consistency ("h5ad" → "combined") - Removed unused utils.py and scikit-learn dependency ## Performance Improvements - Eliminated duplicate min-max normalization in inference pipeline - Optimized async_saving pattern (removed nested ThreadPoolExecutors) - Extracted duplicate save logic into shared helper function - Updated default batch_size to 128 for better stability ## API Improvements - Renamed output formats: "individual" and "combined" (more intuitive) - Changed -t to -m for model_type flag - Removed redundant negative boolean flags (--no-create_csv, etc.) - Simplified parameter organization (Basic vs Additional) ## Documentation - Modernized README.md with professional formatting, badges, and tables - Updated parameter documentation with clear examples - Added publication link and repository references ## Dependencies - Removed scikit-learn (unused) - Added tifffile (required by image_utils.py) - Updated config.yaml with new defaults
Updated project description in README.md.
Critical fixes: - Fix probability normalization bug - apply softmax to ensure probabilities sum to 1.0 (inference.py) - Previously probabilities were raw logits and summed to ~2-3 instead of 1.0 PyTorch compatibility: - Suppress torch.load FutureWarning by explicitly setting weights_only=False (vit_model.py) - Fix SDPA attention warning by using eager attention implementation (vit_model.py) Error handling improvements: - Add comprehensive CUDA OOM error handling with actionable suggestions (process.py) - Suggests reducing batch_size, num_workers, or switching to CPU Logging improvements: - Fix incomplete output file logging - explicitly list embedding, probability, and attention map files (process.py) - Previously only showed generic "individual files" message User experience: - Add CLI examples and common mistakes to help output (cli.py) - Shows correct usage patterns when users run --help
…lts overriding config This commit addresses two major design issues: 1. Hardcoded config and input file paths - Added --config parameter (default: config.yaml) - Added --path-list parameter (default: path_list.csv) - Standardized PATH_LIST_CSV constant (removed unnecessary ./ prefix) 2. Critical bug: CLI defaults were overwriting config file values - Changed all CLI argument defaults to argparse.SUPPRESS - Modified parse_args() to filter out unprovided arguments - Only explicitly provided CLI args now override config file values Configuration priority is now correctly: Default values → Config file → Explicit CLI arguments Updated documentation (README.md, CLAUDE.md) with new parameters and examples.
Added --config and --path-list parameters, fix CLI defaults overriding config This addresses two major design issues:
Configuration priority is now correctly: Updated documentation (README.md, CLAUDE.md) with new parameters and examples. |
Changed parameter name from --path-list to --path_list to match the naming convention of other parameters (using underscores instead of hyphens). Updated documentation in README.md and CLAUDE.md to reflect the change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
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.
This PR introduces a comprehensive refactor of the inference pipeline, focused on substantially improving runtime performance, scalability, and code structure, while preserving the original CLI workflow via
process.py
.Key Technical Changes
Expanded CLI & Configuration Functionality
process.py
entry point was extended with additional flags and configuration options.Modularization of Processing Logic
Data Loading & Preprocessing Enhancements
SubCellDataset
class using pandas CSV parsing for scalable image list handling.Batched Inference Pipeline
I/O and Output Refactor
.npy
files usingThreadPoolExecutor
.Core Improvements & Bug Fixes
image_utils.py
(e.g.,convert_bitdepth
parameter handling).Documentation Updates
Impact