Spaces:
Sleeping
Sleeping
Commit History
-
Keep core models loaded across requests on T4
Unverified signatureOn T4 with concurrency_limit=1, models are now loaded once globally and persist across all sequential requests. Only Paladin models are cleaned up after each request, while core models (CTransPath, Optimus, Aeon, marker_classifier) remain in GPU memory. This eliminates the overhead of reloading 8-12GB of models for every single-slide request on T4 instances. High-memory GPUs continue to use the previous per-batch loading strategy. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>a2d70a9 -
Centralize hardware detection and optimize T4 GPU memory management
Unverified signature- Create new mosaic.hardware module for centralized GPU detection - Set T4 concurrency limit to 1 to prevent concurrent OOM errors - Update analysis.py, model_manager.py, and ui/app.py to use centralized detection - Simplify cleanup logic: only Paladin models cleared on T4, core models persist - Remove redundant GPU cleanup code (already handled by model_cache.cleanup()) Fixes T4 memory issues by enforcing sequential processing while maintaining efficient batch processing on high-memory GPUs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>42a4892 -
Add aggressive GPU memory cleanup after UI analysis
Unverified signature- Clear intermediate data structures (all_slide_masks, all_aeon_results, etc) - Force garbage collection and CUDA cache clearing - Log both allocated and reserved GPU memory after cleanup - Should reduce memory footprint from 4GB to near zero after analysis - Helps prevent OOM on consecutive T4 runs4fda083 -
Add aggressive GPU memory cleanup for T4 instances
Unverified signature- Force CUDA synchronization before cache clearing - Add explicit garbage collection after model cleanup - Log GPU memory usage after cleanup for debugging - Prevents OOM crashes when running multiple slides consecutively - Especially important for T4 GPUs with limited VRAM (~16GB)5549e2b -
Fix invalid OMP_NUM_THREADS environment variable
Unverified signature- Check for empty, zero, or negative OMP_NUM_THREADS values - Set to reasonable default (half of CPU count, min 1, max 8) - Prevents 'Invalid value for environment variable' error on startup - Ensures OpenMP libraries can initialize properlyc96b0f8 -
Improve model download performance on HF Spaces
Unverified signature- Enable HF_HUB_ENABLE_HF_TRANSFER for faster downloads - Add informative logging about download size and expected time - Helps prevent timeout perception on T4 instances with slower network - Model download is ~1GB and may take several minutes on first runa15a72c -
Handle legacy 'Unknown' sex values gracefully
Unverified signature- Silently convert 'Unknown' to empty string in validation - Handle 'Unknown' in update_settings_column function - Prevents 'Unknown is not in choices' error from Gradio - Update uv.lock for Python version constraint - Users will need to manually select Male/Female for analysis6bb43ff -
build: leave .git in docker image
Unverified signature96e060d -
Add progressive results display and sex validation to UI
Unverified signature- Add sex requirement check before analysis starts - Display AEON and PALADIN results progressively as slides are processed - Show settings table during multi-slide processing for progress tracking - Add initial yield to make UI responsive immediately - Fix sex dropdown to use None instead of 'Unknown' as default - Convert None to empty string when building settings DataFrame - Ensure Score column is numeric before rounding in PALADIN results - Hide settings table for single-slide mode, show for multi-slide mode7c7a1ba -
Fix premature sex validation warnings
Unverified signature- Only warn about invalid sex values (not Male/Female), not empty/None - Empty or None sex values will be validated at analysis time - Prevents annoying warnings when settings are first created - Improve warning message to show the invalid valuee66cef9 -
Add python_version to HF Spaces metadata
Unverified signature- Specify python_version: 3.11 in README.md frontmatter - This forces HF Spaces to use Python 3.11 instead of 3.13 - Resolves mussel package compatibility issue (requires <3.12)e3bcefe -
Fix Python version compatibility for Hugging Face Spaces
Unverified signature- Update requires-python to '>=3.10,<3.12' to match mussel dependency - Change .python-version to 3.11 (within compatible range) - Resolves 'Package mussel requires a different Python' error61be48a -
Add comprehensive tests for settings upload functionality
Unverified signature- Add new test suite for CSV settings upload - Test validation of sex, site type, and other parameters - Test error handling for invalid or missing required fields - Ensure proper DataFrame structure and column handling7bdb8f6 -
Update tests to use required sex parameter
Unverified signature- Replace 'Unknown' sex values with 'Male' or 'Female' in test fixtures - Update test CSV files to include sex column with valid values - Fix test assertions to account for new UI component visibility behavior - Adjust expected output structure to include settings_input in yields6ba0947 -
Add mock Gradio components for testing
Unverified signature- Create MockComponent class to track visibility attributes - Add mocks for DownloadButton, DataFrame, Label, and Textbox - Enables proper testing of UI component state changes76070ab -
Enforce required sex parameter in Gradio CLI app
Unverified signature- Remove 'Unknown' as default sex value - Add validation to ensure sex is provided for single slide processing - Update help text to indicate sex is required parameter - Remove fallback to 'Unknown' when sex is missingac41c6b -
Update AEON inference to require sex parameter
Unverified signature- Remove 'Unknown' from sex choices in CLI arguments - Update docstrings to indicate sex is required - Clarify that sex must be 'Male' or 'Female' for inference0d1b788 -
Remove 'Unknown' sex option from UI utilities
Unverified signature- Update SEX_OPTIONS to only include 'Male' and 'Female' - Remove automatic defaulting to 'Unknown' for missing sex values - Update validation to handle empty/null sex values appropriatelyddfa8f1 -
Make sex parameter required in encode_sex function
Unverified signature- Remove 'Unknown' as valid sex option, only accept 'Male' or 'Female' - Raise ValueError if invalid sex value is provided - Update documentation to clarify sex is required parameter466e964 -
Fix AEON results column naming for multiple slides
Unverified signatureWhen running multiple slides, rename the 'Confidence' column to the slide name before concatenation. This ensures each slide has a uniquely named column in the combined results table instead of duplicate 'Confidence' column names.7774e34
-
Fix missing metadata files in model download
Include metadata/* pattern in snapshot_download to ensure metadata/target_dict.tsv is downloaded. This fixes FileNotFoundError when running Aeon inference. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>df63a56
-
Fix GitHub Actions Docker build secret passing
Unverified signatureChanged from 'secret-files' to 'secrets' for passing GitHub token to Docker build. The Dockerfile expects the secret as a string value, not a file path. This fixes the authentication error when cloning the paladin repository: - cat: /run/secrets/github_token: No such file or directory - Authentication failed for paladin.git Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>ee292d9 -
Fix HF Spaces build: allow requirements.txt in Docker context
Unverified signatureRemoved requirements*.txt from .dockerignore to allow HF Spaces Docker builds to access the requirements.txt file. This was causing the build to fail with "requirements.txt: not found" error. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>9785652 -
Trigger HF Spaces rebuild
Unverified signatureCo-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>62ce804 -
Add comprehensive CLI options reference to README
Unverified signatureAdded detailed CLI options section organized by category: - Processing options (slide-path, slide-csv, output-dir) - Single slide parameters (site-type, cancer-subtype, etc.) - Performance options (num-workers) - Model management (skip/download-only) - Web server options (server-name, server-port, share) - Debugging options (debug flag) Improves documentation for users running Mosaic from command line. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>8fe3b28 -
Merge pull request #14 from pathology-data-mining/dev
Unverified signatureBatch processing optimization and HuggingFace cache fixesdfc8cb1 -
format
Unverified signature2f29552 -
Refactor inference modules to eliminate code duplication
Unverified signatureSimplified run() and run_model() functions to delegate to their _with_model/_with_preloaded counterparts after loading the model, removing ~125 lines of duplicated inference logic across both modules. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>0ab0da6 -
Add CLI options to control model downloads
Unverified signature- Add --download-models-only flag to download models and exit - Add --skip-model-download flag to skip model download (use cached) - Update Makefile download-models target to use new CLI option - Document new options in README Advanced Usage section - Use getattr() for robust handling in tests Usage: mosaic --download-models-only # Pre-download models mosaic --skip-model-download <args> # Skip download check make download-models # Download via Makefile14c1ba6 -
Add HF_TOKEN environment variable to test workflow
Unverified signature- Set HF_TOKEN from secrets for dependency installation and tests - Enables access to HuggingFace models during CI if neededee005bb -
Update README with new Aeon inference parameters and add required CSV data files
Unverified signature- Document new sex and tissue site parameters for improved Aeon inference - Update all CSV examples to include optional Sex and Tissue Site columns - Add required data files: sex_original_to_idx.csv, tissue_site_original_to_idx.csv, paladin_model_map.csv - These files are needed for tests and application functionality4ba0ba5 -
Apply Black code formatting to test files
Unverified signature6241f9d -
Fix test failures in CI environment
Unverified signature- Fix GradioMock.Warning to properly accept message argument - Add torch.cuda.get_device_properties and memory_allocated mocks for GPU tests - All 107 tests now pass in both local and CI environmentsb52343d -
Update src/mosaic/inference/paladin.py
Unverified signatureCo-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>414e6c1 -
Fix GitHub Actions workflows to handle SSH private repository access
Unverified signature- Add SSH key setup step to all workflows - Configure Docker build to forward SSH agent - Required for accessing private paladin repository dependency8d082ea -
Add GitHub Actions workflows and comprehensive test suite
Unverified signature- Add CI/CD workflows for tests, code quality, and Docker builds - Add comprehensive Makefile with test, lint, format, and Docker targets - Add new test files for CLI, fixtures, UI components, and UI events - Refactor batch analysis into main analysis module - Update model manager and inference modules - Add .dockerignore for cleaner Docker builds - Update dependencies in uv.lock4780d8d
-
Fix remaining hardcoded data paths after rebase
Unverified signatureFound and fixed 3 hardcoded paths that weren't using get_data_directory(): - analysis.py:468 - Paladin model map path in batch processing - aeon.py:77 - Metadata path in run_with_model function - model_manager.py:157 - Data directory in load_all_models function All paths now use get_data_directory() to properly resolve HF cache or local data directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>c2c8715 -
Fix all failing batch processing tests
Unverified signatureFixed mock configuration issues in batch analysis and model manager tests: Batch Analysis Tests: - Fixed DataFrame mock to return new instances each time (side_effect) - Fixed aeon_results DataFrame structure: Cancer Subtype should be index, not a column (matches actual implementation) - This prevented ValueError when batch_analysis tried to rename columns Model Manager Tests: - Fixed test_load_models_missing_aeon_file to properly mock Path.exists - Now checks filename instead of using fragile call_count logic Root Cause: The batch_analysis code does `aeon_results.columns = [slide_name]` which requires a single-column DataFrame. The real aeon_results has 'Cancer Subtype' as an index (set by _run_inference_pipeline_with_models), not as a column. Tests were mocking it incorrectly with 2 columns. All 27 tests now pass: - 14/14 model_manager tests ✓ - 8/8 batch_analysis tests ✓ - 6/6 regression tests ✓ Coverage: - batch_analysis.py: 99% - model_manager.py: 96% 🤖 Generated with [Cl…e706d9f -
Fix test mocks for segment_tissue return value
Unverified signaturesegment_tissue returns 4 values (polygon, _, coords, attrs) but tests were mocking it to return only 2 values, causing unpacking errors. Fixes: - Mock segment_tissue to return all 4 values - Mock gr.Warning to avoid argument mismatch errors - Use tempfile for directory creation in Gradio test - Mock DataFrame.to_csv to avoid file system issues All regression tests now pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>b6dcc8c -
Document comprehensive logging features in batch processing
Unverified signatureUpdate BATCH_PROCESSING_IMPLEMENTATION.md to highlight the detailed logging system that helps verify the batch processing optimization is working correctly. Includes example log output showing: - GPU detection and memory tracking - Model loading phase with memory usage - Per-slide processing with cache hit indicators - Comprehensive batch summary with timing statistics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>0f7e9b1 -
Add comprehensive logging for batch processing verification
Unverified signatureImproves logging throughout the batch processing pipeline to clearly demonstrate that the optimization is working correctly. Model Manager (src/mosaic/model_manager.py): - Add detailed GPU detection and memory reporting - Show total GPU memory and memory before/after loading each model - Log memory management strategy (T4 aggressive vs A100 caching) - Clear banner indicating models loaded ONCE per batch - Show Paladin model cache hits vs new loads with ✓ indicators - Distinguish between aggressive mode (load/free) and caching mode Batch Analysis (src/mosaic/batch_analysis.py): - Add comprehensive timing for entire batch and per-slide processing - Log batch start with clear separator - Show per-slide progress with [n/total] indicators - Track and report slide processing times (avg, min, max, total) - Calculate and display batch overhead vs processing time - Add detailed summary at end with: * Success/failure counts * Model loading time (done once) * Total batch time * Per-slid…6e06a36 -
Fix segment_tissue unpacking in batch analysis
Unverified signatureThe analyze_slide_with_models function was incorrectly calling segment_tissue and unpacking its return value. segment_tissue returns 4 values (polygon, _, coords, attrs) but we were only unpacking 2. This fix: - Converts seg_config string to config object (BiopsySegConfig, etc.) - Calls segment_tissue with proper individual parameters - Correctly unpacks all 4 return values - Uses polygon for slide mask visualization Fixes: ValueError: too many values to unpack (expected 2) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>42bcf72 -
Add batch processing optimization for slide analysis
Unverified signatureImplements batch processing to reduce model loading overhead by ~90% when processing multiple slides. Models are now loaded once per batch instead of once per slide, providing 25-45% overall speedup for multi-slide batches. New features: - ModelCache class with adaptive memory management (T4 vs A100 GPUs) - Batch coordinator that loads models once and reuses across all slides - Automatic batch mode for >1 slide in both Gradio UI and CLI - GPU type detection for memory-optimized strategies - Comprehensive test suite with unit, integration, and regression tests Implementation: - src/mosaic/model_manager.py: Model loading and caching infrastructure - src/mosaic/batch_analysis.py: Batch processing coordinator - src/mosaic/analysis.py: Batch-optimized pipeline functions - src/mosaic/inference/aeon.py: Add run_with_model() for pre-loaded models - src/mosaic/inference/paladin.py: Add run_with_models() for batch mode - src/mosaic/ui/app.py: Integrate batch mode in Gradio UI - src/mosaic/grad…0234c58
-
Fix user directory creation and hide HF Spaces logs locally
Unverified signature- Fix create_user_directory return type inconsistency that caused TypeError - Only show GPU allocation and user auth logs when running on HF Spaces - Prevents confusing log messages when running the app locally 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>07d6e0e
-
Merge pull request #16 from pathology-data-mining/fix/hf-cache-model-location
Unverified signatureFix circular import by moving get_data_directory to separate module524d53a -
Merge pull request #15 from pathology-data-mining/fix/hf-cache-model-location
Unverified signatureFix model file location to use HuggingFace cache directory42589c0 -
Fix circular import by moving get_data_directory to separate module
Unverified signatureMoved get_data_directory() function from gradio_app.py to a new data_directory.py module to avoid circular imports. The circular import occurred because gradio_app.py imports from ui/utils.py, which was trying to import back from gradio_app.py. Changes: - Create src/mosaic/data_directory.py with get_data_directory() and set_data_directory() functions - Update gradio_app.py to import and use set_data_directory() - Update all other modules (aeon.py, data.py, utils.py, analysis.py) to import from data_directory module instead of gradio_app 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>52f8cb9 -
Fix model file location to use HuggingFace cache directory
Unverified signatureChanged all model file references from hardcoded local data/ directory to use HuggingFace cache directory. This fixes the issue where files couldn't be found after downloading from HuggingFace Hub. Changes: - Add get_data_directory() function to gradio_app.py that checks MOSAIC_DATA_DIR environment variable first, then falls back to local data/ for development - Update gradio_app.py to download to HF cache (removed local_dir parameter) and set MOSAIC_DATA_DIR environment variable - Update all model file references in aeon.py, data.py, utils.py, and analysis.py to use get_data_directory() instead of hardcoded paths 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>751062d
-
Merge pull request #7 from pathology-data-mining/dev
Unverified signatureAdd comprehensive sex and tissue site parameter supportc5e7bb2 -
Merge pull request #13 from pathology-data-mining/copilot/sub-pr-7-please-work
Unverified signatureReplace magic number with named constant for default tissue site indexa3010ef