{"id":10201,"library":"rfdetr","title":"RF-DETR","description":"RF-DETR is a PyTorch-based library for object detection and instance segmentation, implementing the DETR architecture with enhancements. It provides tools for training, inference, and deployment, integrating with PyTorch Lightning for composable training workflows. The library is actively maintained, with version 1.6.4 released recently, and receives frequent updates.","status":"active","version":"1.6.4","language":"en","source_language":"en","source_url":"https://github.com/roboflow/rf-detr","tags":["object-detection","segmentation","pytorch-lightning","computer-vision","detr"],"install":[{"cmd":"pip install rfdetr","lang":"bash","label":"Core library"},{"cmd":"pip install \"rfdetr[train]\"","lang":"bash","label":"With training dependencies"}],"dependencies":[{"reason":"Underlying deep learning framework.","package":"torch"},{"reason":"Standard computer vision library for PyTorch.","package":"torchvision"},{"reason":"Recommended for easy visualization and annotation of results.","package":"supervision","optional":true},{"reason":"Required for training functionality (included in `rfdetr[train]`).","package":"lightning","optional":true}],"imports":[{"symbol":"RFDETRSmall","correct":"from rfdetr import RFDETRSmall"},{"symbol":"RFDETRBase","correct":"from rfdetr import RFDETRBase"},{"symbol":"RFDETRLarge","correct":"from rfdetr import RFDETRLarge"},{"note":"Dataset classes were refactored into the `rfdetr.data` module.","wrong":"from rfdetr.datasets import DetectionDataset","symbol":"DetectionDataset","correct":"from rfdetr.data import DetectionDataset"}],"quickstart":{"code":"import supervision as sv\nfrom rfdetr import RFDETRSmall\n\n# Initialize model with pre-trained weights. Use \"rfdetr-small\" for the default.\n# For a custom fine-tuned model: pretrain_weights=\"path/to/your/model.pth\"\nmodel = RFDETRSmall(pretrain_weights=\"rfdetr-small\")\n\n# Example image URL for prediction\nimage_url = \"https://media.roboflow.com/dog.jpg\"\n\n# Perform inference with a confidence threshold\ndetections = model.predict(image_url, threshold=0.5)\n\nprint(f\"Detected {len(detections)} objects.\")\n\n# Access new data points introduced in recent versions:\nif \"class_name\" in detections.data:\n    print(f\"Class names: {detections.data['class_name']}\")\nif \"source_image\" in detections.data:\n    print(f\"Source image shape: {detections.data['source_shape']}\")\n\n# Visualize results (requires 'supervision' to be installed)\n# image_bgr = detections.data.get(\"source_image\")\n# if image_bgr is not None:\n#     box_annotator = sv.BoxAnnotator()\n#     annotated_image = box_annotator.annotate(scene=image_bgr.copy(), detections=detections)\n#     sv.plot_image(annotated_image, size=(8, 8))\n","lang":"python","description":"This quickstart demonstrates how to load a pre-trained RF-DETR model, perform inference on an image URL, and inspect the returned detections object. It highlights recently added data fields like class names and source image/shape, which are useful for post-processing and visualization with libraries like `supervision`."},"warnings":[{"fix":"Remove `simplify` and `force` arguments from your `RFDETR.export()` calls.","message":"Arguments `simplify` and `force` in `RFDETR.export()` are deprecated and no-ops, and will be removed in v1.8.","severity":"deprecated","affected_versions":">=1.6.1"},{"fix":"Install with `pip install \"rfdetr[train]\"` to enable training functionality and avoid `ImportError`s.","message":"Training features require the `rfdetr[train]` optional dependencies to be installed.","severity":"gotcha","affected_versions":">=1.6.1"},{"fix":"Ensure the `shape` tuple (e.g., `(480, 640)`) contains dimensions that are multiples of 14 to prevent incorrect processing.","message":"`RFDETR.predict(shape=...)` requires both `height` and `width` dimensions to be positive integers divisible by 14.","severity":"gotcha","affected_versions":">=1.6.2"},{"fix":"If your code assumes a fixed set of keys or iterates through `detections.data` without checking for key existence, adapt it to account for these new additions, e.g., `detections.data.get('class_name')`.","message":"The `detections.data` dictionary returned by `predict()` now includes additional keys like `class_name` (v1.6.4) and `source_image`/`source_shape` (v1.6.3).","severity":"gotcha","affected_versions":">=1.6.3"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install `rfdetr` with its training dependencies: `pip install \"rfdetr[train]\"`","cause":"Attempting to use training-specific modules or functions without installing the optional training dependencies.","error":"ImportError: rfdetr[train] is not installed. Please install with 'pip install \"rfdetr[train]\"'"},{"fix":"Upgrade `rfdetr` to `v1.6.4` or later, or use `detections.data.get('class_name')` and handle `None` for backward compatibility.","cause":"Attempting to access `detections.data['class_name']` using an `rfdetr` version older than 1.6.4, where this key was not present.","error":"KeyError: 'class_name'"},{"fix":"Provide a `shape` where both height and width are positive integers divisible by 14, e.g., `model.predict(..., shape=(480, 640))`.","cause":"The `shape` argument passed to `RFDETR.predict()` had dimensions (height, width) that were not perfectly divisible by 14.","error":"ValueError: Input shape dimensions must be divisible by 14. Got (500, 500)"},{"fix":"Remove the `simplify` and `force` arguments from your `RFDETR.export()` method calls.","cause":"Using the deprecated `simplify` or `force` arguments in `RFDETR.export()`, which are no longer supported since v1.6.1.","error":"TypeError: RFDETR.export() got an unexpected keyword argument 'simplify'"}]}