Add MD5 validation for file downloads and pretrained weights handling - #679
Merged
Merged
Conversation
…sets module Move model weights handling from main.py to new rfdetr.assets.model_weights module to improve code organization and separation of concerns. Update imports across affected modules to reference the new location.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #679 +/- ##
=======================================
+ Coverage 58% 58% +1%
=======================================
Files 50 52 +2
Lines 6595 6733 +138
=======================================
+ Hits 3805 3935 +130
- Misses 2790 2798 +8 🚀 New features to boost your workflow:
|
Borda
marked this pull request as ready for review
February 13, 2026 15:12
Borda
requested review from
SkalskiP,
isaacrob and
probicheaux
as code owners
February 13, 2026 15:13
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request introduces a comprehensive model weight asset management system with MD5 validation for RF-DETR. The changes centralize model metadata (filename, URL, MD5 hash) into a ModelWeights enum registry, refactor download logic with integrity validation, and add extensive test coverage for the new functionality.
Changes:
- Introduced a new
ModelWeightsenum-based registry withModelWeightAssetdataclass for centralized model asset management - Added MD5 hash computation and validation utilities to
src/rfdetr/util/files.pywith enhanced download logic - Refactored model download and validation logic with backward compatibility for legacy platform models
- Added comprehensive unit tests for MD5 validation, model weights registry, and download flows
- Updated CI workflow to validate model instantiation and downloads instead of just import checks
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
src/rfdetr/assets/__init__.py |
New public API exposing ModelWeights, ModelWeightAsset, and ModelWeightsBase |
src/rfdetr/assets/model_weights.py |
Core implementation of model registry with enum-based assets, download logic with MD5 validation, and rf-detr-plus integration |
src/rfdetr/util/files.py |
Added MD5 computation/validation functions and enhanced download with temporary file handling |
src/rfdetr/main.py |
Integrated new model_weights module, added MD5 validation before loading, updated OPEN_SOURCE_MODELS for backward compatibility |
src/rfdetr/detr.py |
Updated import to use download_pretrain_weights from assets module, minor log message formatting |
tests/assets/__init__.py |
Test package initialization with license header |
tests/assets/test_model_weights.py |
Unit tests for ModelWeights enum methods and asset validation |
tests/assets/test_downloads.py |
Comprehensive mocked tests for download logic including priority order, MD5 validation, and error handling |
tests/util/test_file_validation.py |
Unit tests for MD5 computation and validation functions |
tests/try_instantiate_all_models.py |
Integration script to validate all model downloads and instantiation |
.github/workflows/ci-integrations.yml |
Updated CI job to run model instantiation validation instead of simple import check |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Borda
added a commit
that referenced
this pull request
Feb 16, 2026
…#679) * Add MD5 validation for file downloads and pretrained weights handling * refactor(assets): extract model weights functionality to dedicated assets module * Move model weights handling from main.py to new rfdetr.assets.model_weights module to improve code organization and separation of concerns. Update imports across affected modules to reference the new location. * refactor(main, model_weights): move and reuse weight validation logic * test(util, download): add comprehensive tests for MD5 validation and file download logic * fix(pre-commit): 🎨 auto format pre-commit hooks * Apply suggestions from code review --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Borda
added a commit
that referenced
this pull request
Feb 16, 2026
…#679) * Add MD5 validation for file downloads and pretrained weights handling * refactor(assets): extract model weights functionality to dedicated assets module * Move model weights handling from main.py to new rfdetr.assets.model_weights module to improve code organization and separation of concerns. Update imports across affected modules to reference the new location. * refactor(main, model_weights): move and reuse weight validation logic * test(util, download): add comprehensive tests for MD5 validation and file download logic * fix(pre-commit): 🎨 auto format pre-commit hooks * Apply suggestions from code review --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Borda
added a commit
that referenced
this pull request
Mar 13, 2026
…#679) * Add MD5 validation for file downloads and pretrained weights handling * refactor(assets): extract model weights functionality to dedicated assets module * Move model weights handling from main.py to new rfdetr.assets.model_weights module to improve code organization and separation of concerns. Update imports across affected modules to reference the new location. * refactor(main, model_weights): move and reuse weight validation logic * test(util, download): add comprehensive tests for MD5 validation and file download logic * fix(pre-commit): 🎨 auto format pre-commit hooks * Apply suggestions from code review --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
This pull request introduces a new, robust mechanism for handling model weight assets in the RF-DETR codebase. The main improvements are the introduction of a centralized
ModelWeightsregistry with MD5 validation, enhanced and refactored download logic, and comprehensive unit tests to ensure reliability. These changes improve security, maintainability, and test coverage for model asset management.Model asset management and download improvements:
src/rfdetr/assets/__init__.pyand a newModelWeightsregistry for model weight assets, centralizing model filename, URL, and MD5 hash metadata. This enables consistent access and validation across the codebase.download_pretrain_weightstorfdetr.assets.model_weights, added MD5 hash validation, and updated the download process to use the new registry. The legacy dictionary is now used only for backward compatibility. [1] [2] [3] [4]src/rfdetr/util/files.pyto support MD5 hash computation and validation, downloading to a temporary file, and improved logging. [1] [2]Testing and validation:
tests/assets/test_downloads.pyto cover all aspects of the new download and validation logic, including integration withrf-detr-plus, fallback behavior, error handling, and MD5 correctness.assetstest directory.CI/CD improvements:
Minor improvements:
These changes make model asset management more secure, reliable, and maintainable, while also providing strong test coverage and improved developer experience.