rf-detr
rf-detr copied to clipboard
Raise error for unknown parameters in class ModelConfig(BaseModel)
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.
- [x] 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
I have read the CLA Document and I sign the CLA.
Hi @Ahmed-Samir11 , I created a new PR https://github.com/Ahmed-Samir11/rf-detr/pull/1 which mainly adds a base class to cover the ModelConfig and TrainConfig class, removes deprecated methods of Pydantic and changes the wording for better clarity and understanding. Have a look please 😄 .
Hello @nok, your work looks amazing! I haven't considered removing Pydantic's deprecated methods. Thank you for the experience!
@isaacrob-roboflow Hello, any updates on this PR?