Skip to content

Raise error for unknown parameters in class ModelConfig(BaseModel) #196

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
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Ahmed-Samir11
Copy link

After fine-tuning the model on multiple datasets, I tried to predict an image and found out that the predictions are that of the base model. I found out that the issue is a mistake while writing the model parameter:

model = RFDETRBase(num_classes=1, pretrained_weights = 'path/to/checkpoint_best_total.pth')
# incorrect param: pretrained_weights 

model = RFDETRBase(num_classes=1, pretrain_weights = 'path/to/checkpoint_best_total.pth')
# correct param usage: pretrain_weights 

So I added to the 'rfdetr/config.py' a raise error functionality based on pydantic, which states the incorrect parameter and lists the correct available parameters.

  • Bug fix (non-breaking change which fixes an issue)

A test case:
Success:

from rfdetr import RFDETRBase
model = RFDETRBase(num_classes=1, pretrain_weights = '/kaggle/input/redetr-tuned/checkpoint_best_total.pth')

Output: Loading pretrain weights

Faliure:

from rfdetr import RFDETRBase
model_2 = RFDETRBase(num_classeseses=1, pretrain_weights = '/kaggle/input/redetr-tuned/checkpoint_best_total.pth')

Output:

ValidationError: 1 validation error for RFDETRBaseConfig
  Value error, Unknown parameter(s): 'num_classeseses'. Available fields are: amp, bbox_reparam, ca_nheads, dec_layers, dec_n_points, device, encoder, gradient_checkpointing, group_detr, hidden_dim, layer_norm, lite_refpoint_refine, num_classes, num_queries, num_select, out_feature_indexes, pretrain_weights, projector_scale, resolution, sa_nheads, two_stage [type=value_error, input_value={'num_classeseses': 1, 'p...ckpoint_best_total.pth'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error

I have also attached the notebook where I tested my work on Kaggle as a PDF.
rf-detr-pr-raisecfcerror.pdf

raise an error for misspelled parameters or non-existent ones
@CLAassistant
Copy link

CLAassistant commented May 4, 2025

CLA assistant check
All committers have signed the CLA.

@Ahmed-Samir11
Copy link
Author

I have read the CLA Document and I sign the CLA.

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.

2 participants