Skip to content

Commit e843785

Browse files
Merge branch 'main' into codeflash/optimize-select_top_confidence_detection-m7drsd4o
2 parents f3ebc61 + 70cd538 commit e843785

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1211
-115
lines changed

docs/fine-tuned/rfdetr.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
RF-DETR is Roboflow's new Real-Time SOTA Object Detector.
2+
3+
## Supported Model Types
4+
5+
You can deploy the following RF-DETR model types with Inference:
6+
7+
- Object Detection
8+
9+
## Model Overview
10+
11+
- [Read More About RF-DETR](https://blog.roboflow.com/rf-detr/)
12+
13+
## Usage Example
14+
15+
```
16+
import os
17+
import supervision as sv
18+
from inference import get_model
19+
from PIL import Image
20+
from io import BytesIO
21+
import requests
22+
23+
response = requests.get("https://media.roboflow.com/dog.jpeg")
24+
25+
if response.status_code == 200:
26+
image_data = BytesIO(response.content)
27+
28+
image = Image.open(image_data)
29+
30+
model = get_model("rfdetr-base")
31+
32+
predictions = model.infer(image, confidence=0.5)[0]
33+
34+
detections = sv.Detections.from_inference(predictions)
35+
36+
labels = [prediction.class_name for prediction in predictions.predictions]
37+
38+
annotated_image = image.copy()
39+
annotated_image = sv.BoxAnnotator().annotate(annotated_image, detections)
40+
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)
41+
42+
sv.plot_image(annotated_image)
43+
44+
annotated_image.save("annotated_image_base.jpg")
45+
46+
model = get_model("rfdetr-large")
47+
48+
predictions = model.infer(image, confidence=0.5)[0]
49+
50+
detections = sv.Detections.from_inference(predictions)
51+
52+
labels = [prediction.class_name for prediction in predictions.predictions]
53+
54+
annotated_image = image.copy()
55+
annotated_image = sv.BoxAnnotator().annotate(annotated_image, detections)
56+
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)
57+
58+
sv.plot_image(annotated_image)
59+
60+
annotated_image.save("annotated_image_large.jpg")
61+
```
62+
63+
## License
64+
65+
See our [Licensing Guide](https://roboflow.com/licensing) for more information about how your use of RF-DETR is licensed when using Inference to deploy your model.

inference/core/roboflow_api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import re
55
import urllib.parse
66
from enum import Enum
7+
from hashlib import sha256
78
from pathlib import Path
89
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
910

@@ -555,8 +556,9 @@ def get_workflow_specification(
555556
if not re.match(r"^[\w\-]+$", workflow_id):
556557
raise ValueError("Invalid workflow id")
557558

559+
workflow_hash = sha256(workflow_id.encode()).hexdigest()
558560
local_file_path = (
559-
Path(MODEL_CACHE_DIR) / "workflow" / "local" / f"{workflow_id}.json"
561+
Path(MODEL_CACHE_DIR) / "workflow" / "local" / f"{workflow_hash}.json"
560562
)
561563
if not local_file_path.exists():
562564
raise FileNotFoundError(f"Local workflow file not found: {local_file_path}")

inference/core/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.43.0"
1+
__version__ = "0.44.0"
22

33

44
if __name__ == "__main__":

inference/core/workflows/core_steps/common/query_language/operations/detections/base.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ def select_top_confidence_detection(detections: sv.Detections) -> sv.Detections:
113113

114114
def select_leftmost_detection(detections: sv.Detections) -> sv.Detections:
115115
if len(detections) == 0:
116-
return deepcopy(detections)
116+
return detections # Directly return the original empty detections if empty
117+
117118
centers_x = detections.get_anchors_coordinates(anchor=Position.CENTER)[:, 0]
118-
min_value = centers_x.min()
119-
index = np.argwhere(centers_x == min_value)[0].item()
119+
index = np.argmin(centers_x)
120120
return detections[index]
121121

122122

123123
def select_rightmost_detection(detections: sv.Detections) -> sv.Detections:
124124
if len(detections) == 0:
125-
return deepcopy(detections)
125+
return detections
126+
126127
centers_x = detections.get_anchors_coordinates(anchor=Position.CENTER)[:, 0]
127-
max_value = centers_x.max()
128-
index = np.argwhere(centers_x == max_value)[-1].item()
128+
index = centers_x.argmax()
129129
return detections[index]
130130

131131

inference/landing/out/404.html

+1-1
Large diffs are not rendered by default.

inference/landing/out/_next/static/bH3ygzSzorxw1C1hab7Ow/_buildManifest.js

-1
This file was deleted.

inference/landing/out/_next/static/chunks/41-a7c92d93876b3716.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inference/landing/out/_next/static/chunks/4bd1b696-49be05dc45317ca5.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inference/landing/out/_next/static/chunks/4bd1b696-bac15167ab046aa1.js

-1
This file was deleted.

inference/landing/out/_next/static/chunks/517-bd83e9c7e082f489.js

-2
This file was deleted.

inference/landing/out/_next/static/chunks/684-33d03c73eebe7a0a.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inference/landing/out/_next/static/chunks/747-bd09866fd27e9742.js

-1
This file was deleted.

0 commit comments

Comments
 (0)