Run this model with HF Jobs
Run Thastp/rf-detr on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Thastp/rf-detr. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Thastp/rf-detr on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Thastp/rf-detr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Thastp/rf-detr with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="Thastp/rf-detr", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForObjectDetection model = AutoModelForObjectDetection.from_pretrained("Thastp/rf-detr", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload model
Browse filesFiles changed (3)
10 unmodified lines1112131415161718 unmodified lines36373839404110 unmodified lines"ca_nheads": 16,"dec_layers": 3,"dec_n_points": 2,"device": "cpu","encoder": "dinov2_windowed_small","gradient_checkpointing": false,"group_detr": 13,18 unmodified lines"resolution": 560,"sa_nheads": 8,"torch_dtype": "float32","transformers_version": "4.50.3","two_stage": true}10 unmodified lines11121314151618 unmodified lines35363738394010 unmodified lines"ca_nheads": 16,"dec_layers": 3,"dec_n_points": 2,"encoder": "dinov2_windowed_small","gradient_checkpointing": false,"group_detr": 13,18 unmodified lines"resolution": 560,"sa_nheads": 8,"torch_dtype": "float32","transformers_version": "4.51.1","two_stage": true}
5 unmodified lines678910111211 unmodified lines242526272829309 unmodified lines404142434445465 unmodified lines### modified from https://github.com/roboflow/rf-detr/blob/main/rfdetr/config.pyDEVICE = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"class RFDetrConfig(PretrainedConfig):model_type = 'rf-detr'11 unmodified linesamp: bool = True,num_classes: int = 90,num_queries: int = 300,device: Literal["cpu", "cuda", "mps"] = DEVICE,resolution: int = 560,group_detr: int = 13,gradient_checkpointing: bool = False,9 unmodified linesself.layer_norm = layer_normself.amp = ampself.num_classes = num_classesself.device = deviceself.resolution = resolutionself.group_detr = group_detrself.gradient_checkpointing = gradient_checkpointing5 unmodified lines678910111211 unmodified lines242526272829309 unmodified lines404142434445465 unmodified lines### modified from https://github.com/roboflow/rf-detr/blob/main/rfdetr/config.py#DEVICE = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"class RFDetrConfig(PretrainedConfig):model_type = 'rf-detr'11 unmodified linesamp: bool = True,num_classes: int = 90,num_queries: int = 300,# device: Literal["cpu", "cuda", "mps"] = DEVICE,resolution: int = 560,group_detr: int = 13,gradient_checkpointing: bool = False,9 unmodified linesself.layer_norm = layer_normself.amp = ampself.num_classes = num_classes# self.device = deviceself.resolution = resolutionself.group_detr = group_detrself.gradient_checkpointing = gradient_checkpointing
39 unmodified lines4041424344454659 unmodified lines1061071081091101111124 unmodified lines11711811912012112212312410 unmodified lines13513613713813914014114239 unmodified lineslayer_norm = config.layer_norm,amp = config.amp,num_classes = config.num_classes,device = config.device,resolution = config.resolution,group_detr = config.group_detr,gradient_checkpointing = config.gradient_checkpointing,59 unmodified lineswr = self.config.resolution / float(w)for label in labels:boxes = label["boxes"].to(device=self.config.device, dtype=torch.float32)# resize boxes to model's resolutionboxes[:, [0, 2]] *= wrboxes[:, [1, 3]] *= hr4 unmodified lines# normalize to [0, 1] by model's resolutionboxes[:] /= self.config.resolutionlabel["boxes"] = boxesif "labels" in label:label["labels"] = label["labels"].to(self.config.device)def forward(self, pixel_values: torch.Tensor, pixel_mask: torch.Tensor, labels=None, **kwargs) -> ModelOutput:resize = Resize((self.config.resolution, self.config.resolution))10 unmodified linesself.criterion.training = False# resize pixel values and mask to model's resolutionpixel_values = pixel_values.to(self.config.device)pixel_mask = pixel_mask.to(self.config.device)pixel_values = resize(pixel_values)pixel_mask = resize(pixel_mask)39 unmodified lines4041424344454659 unmodified lines1061071081091101111124 unmodified lines11711811912012112212312410 unmodified lines13513613713813914014114239 unmodified lineslayer_norm = config.layer_norm,amp = config.amp,num_classes = config.num_classes,#device = config.device,resolution = config.resolution,group_detr = config.group_detr,gradient_checkpointing = config.gradient_checkpointing,59 unmodified lineswr = self.config.resolution / float(w)for label in labels:boxes = label["boxes"]#.to(device=self.config.device, dtype=torch.float32)# resize boxes to model's resolutionboxes[:, [0, 2]] *= wrboxes[:, [1, 3]] *= hr4 unmodified lines# normalize to [0, 1] by model's resolutionboxes[:] /= self.config.resolutionlabel["boxes"] = boxes# if "labels" in label:# label["labels"] = label["labels"].to(self.config.device)def forward(self, pixel_values: torch.Tensor, pixel_mask: torch.Tensor, labels=None, **kwargs) -> ModelOutput:resize = Resize((self.config.resolution, self.config.resolution))10 unmodified linesself.criterion.training = False# resize pixel values and mask to model's resolution# pixel_values = pixel_values.to(self.config.device)# pixel_mask = pixel_mask.to(self.config.device)pixel_values = resize(pixel_values)pixel_mask = resize(pixel_mask)
config.json+1-2
configuration_rf_detr.py+3-3
modeling_rf_detr.py+6-6