Skip to content

Add model input validation#298

Open
Chandraveersingh1717 wants to merge 14 commits intomlverse:mainfrom
Chandraveersingh1717:add-model-input-validation
Open

Add model input validation#298
Chandraveersingh1717 wants to merge 14 commits intomlverse:mainfrom
Chandraveersingh1717:add-model-input-validation

Conversation

@Chandraveersingh1717
Copy link
Contributor

Add Input Validation to Model Functions

This PR adds simple input validation to catch common mistakes when users pass invalid arguments to model functions.

What changed

Added validation checks for pretrained and progress parameters in model functions. Now they properly check if you're passing TRUE/FALSE instead of accepting strings, numbers, or other invalid types.

Why this matters

Users were getting confusing torch errors deep in the stack when they made simple mistakes like:

  • model_resnet18(pretrained = "yes") instead of TRUE
  • model_vgg16(pretrained = 1) instead of TRUE
  • model_alexnet(pretrained = c(TRUE, FALSE)) passing a vector

Now they get a clear message right away: 'pretrained' must be a single logical value

Implementation

  • Added the same validation pattern to all model functions
  • Uses the existing value_error() function that's already in the codebase
  • Placed validation in helper functions where possible (so one check covers multiple models)
  • Covers 50+ model functions: ResNet, VGG, AlexNet, MobileNet, EfficientNet, ViT, MaxViT, ConvNeXt, Inception, FCN, DeepLabV3, Faster R-CNN

Demonstrate C++ function export with parameters for GSoC evaluation
Demonstrate C++ function export with parameters for GSoC evaluation
- Implement drawing lines between keypoints using connectivity matrix
- Add graphics::segments() to draw skeleton connections
- Update documentation with connectivity parameter and examples
- Add test for connectivity feature
- Add keypoint-skeleton.R example for human pose visualization
Add connectivity parameter to draw lines between keypoints with human pose example
Prevents 2D tensor from collapsing to 1D when indexing with single element.
Fixes convnext_detection model test failure.
C++ version clamps negative areas to 0, R version doesn't.
Correctness is tested separately, this only tests performance.
Documents latest output API, follows fcnresnet structure
@Chandraveersingh1717
Copy link
Contributor Author

Can you review this PR and other PRs
Is there something I need to fix or any reason for which it still haven't gotten reviewed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant