You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #120 from FocoosAI/feat/implement-rtmo
Key Changes
✨ Introduce keypoints models
add RTMO-S/M/L-COCO keypoint pretrained model
example:
from focoos import ModelManager
from PIL import Image
im = "https://public.focoos.ai/samples/federer.jpg"
model = ModelManager.get("rtmo-s-coco")
detections = model.infer(im,annotate=True, threshold=0.5)
Image.fromarray(detections.image) # visualise or save annotated image
📷 Unified Inference API
Standardize infer Method Signatures
consistent infer() method across FocoosModel, InferModel, and RemoteModel with unified parameters: infer(image, threshold=0.5, annotate=False) and use unified image loader for infer methods (with also remote image support)
add default threshold to 0.5
Remove dependency on external annotate_image() function calls
Streamlined workflow: get detections and visual annotations in a single call
example torch and exported model:
from focoos import ModelManager, RuntimeType
from PIL import Image
im = "https://public.focoos.ai/samples/motogp.jpg" # remote image, can also be local path, numpy array, or PIL image
model = ModelManager.get("fai-detr-l-obj365")
detections = model.infer(im,annotate=True, threshold=0.5) # annotatate param
# Image.fromarray(detections.image) # visualise or save annotated image
# export model
model = model.export(RuntimeType.ONNX_CUDA32)
res = model.infer(im, annotate=True, threshold=0.5)
Image.fromarray(detections.image) # visualise or save annotated image
example with remote inference:
from focoos import FocoosHUB
from PIL import Image
hub = FocoosHUB()
model_ref = "fai-detr-l-obj365" # use any of pretrained model on app.focoos.ai or your own model reference
remote_model = hub.get_remote_model(model_ref)
im = "https://public.focoos.ai/samples/federer.jpg"
detections = remote_model.infer(im,annotate=True, threshold=0.5)
Image.fromarray(detections.image) # visualise or save annotated image
Enhanced FocoosDetections Structure
add new image field: stores annotated results as base64 string or numpy array
migrated from Pydantic to pure Python dataclasses for better performance,
Improved serialization and memory usage
add new keypoints field
add pprint and print_infer methods to unify detections prints.
⌨️ CLI
add new CLI command: focoos gradio to launch a Gradio interface for image and video inference using Focoos pretrained models.
🕹️ Trainer
fix missing model preprocessing when amp=True (Automatic Mixed Precision) is enabled
add COSINE scheduler quadratic warmup
add KeypointEvaluator
enhance logging with additional info
Update Visualizer (preview hook) to save RGB images instead of BGR
Restore TensorBoard Hook
📖 ModelRegistry
model registry now support automatic loading json configs from registry folder instead of declare model configs manually
🏞️ Processor
add image_size into init instead of preprocess methods
improve image loader performance
add non-blocking image transfer
optimize preprocessor speed
add focoos palette to annotators
📖 Docs
add RTMO docs
update Readme, Docs and notebook with from focoos import x for all exported classes and functions instead of absolute path
@@ -16,7 +20,7 @@ Whether you're working in the cloud or on edge devices, the Focoos library seaml
16
20
### Key Features 🔑
17
21
18
22
1.**Frugal Pretrained Models** 🌿
19
-
Get started quickly by selecting one of our efficient, [pre-trained models](https://focoosai.github.io/focoos/models/models/) that best suits your data and application needs.
23
+
Get started quickly by selecting one of our efficient, [pre-trained models](https://focoosai.github.io/focoos/models/) that best suits your data and application needs.
20
24
Focoos Model Registry give access to 11 pretrained models of different size from different families: RTDetr, Maskformer, BisenetFormer
21
25
22
26
2.**Fine Tune Your Model** ✨ Adapt the model to your specific use case by customize its config and training it on your own dataset.
im ="https://public.focoos.ai/samples/motogp.jpg"# can be local/remote path, np.array, PIL image
45
49
46
50
model = ModelManager.get("fai-detr-l-obj365") # any models from ModelRegistry, FocoosHub or local folder
47
51
48
-
detections = model(im)
52
+
detections = model.infer(im,annotate=true)
49
53
50
54
```
51
55
@@ -110,7 +114,7 @@ Using Focoos AI helps you save both time and money while delivering high-perform
110
114
-**4x Cheaper** 💰: Our models require up to 4x less computational power, letting you save on hardware or cloud bill while ensuring high-quality results.
111
115
-**Tons of CO2 saved annually per model** 🌱: Our models are energy-efficient, helping you reduce your carbon footprint by using less powerful hardware with respect to mainstream models.
112
116
113
-
See the list of our models in the [models](https://focoosai.github.io/focoos/models/models) section.
117
+
See the list of our models in the [models](https://focoosai.github.io/focoos/models/) section.
Copy file name to clipboardExpand all lines: docs/concepts.md
+16-9Lines changed: 16 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ The Focoos Hub is a cloud-based model repository where you can store, share, and
28
28
**Requirements**: Valid API key for private models, internet connection for initial download.
29
29
30
30
```python
31
+
from focoos import FocoosHub, ModelManager
31
32
# Loading from hub using hub:// protocol
32
33
# The model is automatically downloaded and cached locally
33
34
hub = FocoosHUB(api_key="your_api_key")
@@ -51,6 +52,7 @@ The Model Registry contains curated, pretrained models that are immediately avai
51
52
**Requirements**: No internet connection needed, models are bundled with the library.
52
53
53
54
```python
55
+
from focoos import ModelRegistry, ModelManager
54
56
# Loading pretrained models from registry
55
57
# Object detection model trained on COCO dataset
56
58
model = ModelManager.get("fai-detr-l-coco")
@@ -59,7 +61,6 @@ model = ModelManager.get("fai-detr-l-coco")
59
61
model = ModelManager.get("fai-mf-l-ade")
60
62
61
63
# Check available models first
62
-
from focoos import ModelRegistry
63
64
available_models = ModelRegistry.list_models()
64
65
print("Available models:", available_models)
65
66
@@ -133,7 +134,7 @@ model_info = ModelInfo(
133
134
model = ModelManager.get("custom_detector", model_info=model_info)
134
135
```
135
136
136
-
### Predict
137
+
### Inference
137
138
138
139
Performs end-to-end inference on input images with automatic preprocessing and postprocessing. The model accepts input images in various formats including:
139
140
@@ -151,7 +152,9 @@ The input images are automatically preprocessed to the correct size and format r
151
152
This provides a simple, unified interface for running inference regardless of the underlying model architecture or task.
152
153
153
154
**Parameters:**
154
-
-`inputs`: Input images in various supported formats (`PIL.Image.Image`, `numpy.ndarray`, `torch.Tensor`)
155
+
-`image`: Input image in various supported formats (`PIL.Image.Image`, `numpy.ndarray`, `torch.Tensor`, local or remote path)
156
+
-`threshold`: detections threshold
157
+
-`annotate`: if you want to annotate detections on provided image
155
158
-`**kwargs`: Additional arguments passed to postprocessing
Performs end-to-end inference on input images with automatic preprocessing and postprocessing on the selected runtime. The model accepts input images in various formats including:
265
270
@@ -277,7 +282,9 @@ The input images are automatically preprocessed to the correct size and format r
277
282
This provides a simple, unified interface for running inference regardless of the underlying model architecture or task.
278
283
279
284
**Parameters:**
280
-
-`inputs`: Input images in various supported formats (`PIL.Image.Image`, `numpy.ndarray`, `torch.Tensor`)
285
+
-`image`: Input image in various supported formats (`PIL.Image.Image`, `numpy.ndarray`, `torch.Tensor`, local or remote path)
286
+
-`threshold`: detections threshold
287
+
-`annotate`: if you want to annotate detections on provided image
281
288
-`**kwargs`: Additional arguments passed to postprocessing
Copy file name to clipboardExpand all lines: docs/inference.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ Using the model is as simple as it could! Just call it with an image.
56
56
```python
57
57
fromPILimport Image
58
58
image = Image.open("<PATH-TO-IMAGE>")
59
-
detections = model(image)
59
+
detections = model.infer(image)
60
60
```
61
61
62
62
`detections` is a [FocoosDetections](/focoos/api/ports/#focoos.ports.FocoosDetections) object, containing a list of [FocoosDet](/focoos/api/ports/#focoos.ports.FocoosDet) objects and optionally a dict of information about the latency of the inference. The `FocoosDet` object contains the following attributes:
@@ -66,13 +66,14 @@ detections = model(image)
66
66
-`cls_id`: Class ID (0-indexed).
67
67
-`label`: Label (name of the class).
68
68
-`mask`: Mask (base64 encoded string having origin in the top left corner of bbox and the same width and height of the bbox).
69
+
-`keypoints`: keypoints detected
69
70
70
-
If you want to visualize the result on the image, there's a utily for you.
71
+
If you want to visualize the result on the image,just set annotate=true
You can use different runtimes that may fit better your device, such as TensorRT. See the list of available Runtimes at [`RuntimeTypes`](/focoos/api/ports/#focoos.ports.RuntimeType). Please note that you need to install the relative packages for onnx and tensorRT for using them.
0 commit comments