-
Notifications
You must be signed in to change notification settings - Fork 656
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Search before asking
- I have searched the RF-DETR issues and found no similar feature requests.
Description
Feature Request: Accept pathlib.Path objects for path parameters
Currently, all path-related parameters in RFDETR only accept strings:
from pathlib import Path
from rfdetr import RFDETRNano
# Fails
model = RFDETRNano(pretrain_weights=Path("weights/model.pth"))
# PyDantic ValidationError: Input should be a valid string
# Must convert explicitly:
model = RFDETRNano(pretrain_weights=str(Path("weights/model.pth")))This is inconvenient when integrating RFDETR with other Python code that uses pathlib.Path throughout.
Accept both str and pathlib.Path for all path-related configuration parameters.
Use case
I did a small test by updating the config class to accept Path:
class RFDETRNanoConfig(RFDETRBaseConfig):
"""
The configuration for an RF-DETR Nano model.
"""
out_feature_indexes: List[int] = [3, 6, 9, 12]
num_windows: int = 2
dec_layers: int = 2
patch_size: int = 16
resolution: int = 384
positional_encoding_size: int = 24
pretrain_weights: Optional[str | Path] = "rf-detr-nano.pth"Prediction with Path objects work correctly after this change:
Dataset classes: ['Test']
Number of dataset classes: 1
Loading images: 100%|██████████| 2/2 [00:00<00:00, 3.15it/s]Additional
This aligns with modern Python conventions as similar libraries accept pathlib.Path objects.
Are you willing to submit a PR?
- Yes I'd like to help by submitting a PR!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request