blueye.sdk.cv_models
cv_models
Manage the computer vision model packages installed on the drone.
The Blueye X3 Ultra runs CV model packages (an ONNX model plus a
model_meta.json, see the "Bundling CV models" documentation). This module wraps the
drone's HTTP API for managing those packages: listing, uploading, deleting,
downloading, configuring (autolaunch/device/rate), and pre-building inference engines.
The API is plain HTTP and independent of the drone's control connection, so these
methods work on a Drone(auto_connect=False) instance as well — no control over the
drone is taken.
Classes:
-
CvModel–One CV model package installed on the drone.
-
CvModels–CV model package management on the drone.
CvModel
dataclass
CvModel(
name: str,
directory: str,
type: str,
output_format: str,
size_bytes: int,
labels: list[str],
enabled: bool,
raw: dict,
)
One CV model package installed on the drone.
Attributes:
-
name(str) –The human-readable model name from its model_meta.json.
-
directory(str) –The package's directory slug on the drone — this is the identifier the other methods take as
name. -
type(str) –"detection", "sot", or "unknown".
-
output_format(str) –The decoder format (e.g. "yolov8_flat").
-
size_bytes(int) –Size of the model weights file.
-
labels(list[str]) –Class labels.
-
enabled(bool) –Whether the model autolaunches on the drone (runtime.enabled).
-
raw(dict) –The verbatim API entry, including the optional preprocessing/detection/ sot/tracking/runtime blocks when present.
Methods:
-
from_json–Build a CvModel from one entry of the drone's API response.
from_json
classmethod
from_json(entry: dict) -> CvModel
Build a CvModel from one entry of the drone's API response.
Source code in blueye/sdk/cv_models.py
61 62 63 64 65 66 67 68 69 70 71 72 73 | |
CvModels
CvModels(parent_drone: 'blueye.sdk.Drone')
CV model package management on the drone.
Accessed through drone.cv_models, e.g.::
drone = blueye.sdk.Drone(auto_connect=False)
for model in drone.cv_models.list():
print(model.name, model.enabled)
All methods raise requests.exceptions.ConnectionError/ConnectTimeout when the
drone is unreachable, and requests.exceptions.HTTPError (with the drone's error
message included) when the drone rejects a request.
Methods:
-
delete–Delete a model package from the drone.
-
download–Download a model package from the drone as a zip.
-
list–List the model packages installed on the drone.
-
rescan–Ask the drone's vision pipeline to rescan the installed packages.
-
set_device–Set the execution provider a model runs on.
-
set_enabled–Enable or disable a model's autolaunch on the drone.
-
set_hz–Set a model's maximum inference rate.
-
upload–Upload a model package zip to the drone.
-
warmup–Pre-build the model's inference engine on the drone.
Source code in blueye/sdk/cv_models.py
90 91 | |
delete
delete(name: str, timeout: float = 5) -> None
Delete a model package from the drone.
Parameters:
-
name(str) –The package's directory slug (see CvModel.directory).
-
timeout(float, default:5) –Request timeout in seconds.
Source code in blueye/sdk/cv_models.py
148 149 150 151 152 153 154 155 | |
download
download(
name: str,
output_path: Path | str | None = None,
timeout: float = 60,
) -> Path
Download a model package from the drone as a zip.
Parameters:
-
name(str) –The package's directory slug.
-
output_path(Path | str | None, default:None) –Destination file or directory. Defaults to the filename the drone suggests (or
<name>.zip) in the current directory. -
timeout(float, default:60) –Request timeout in seconds.
Returns:
-
Path–The path the zip was written to.
Source code in blueye/sdk/cv_models.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
list
List the model packages installed on the drone.
Parameters:
-
timeout(float, default:5) –Request timeout in seconds.
Returns:
Source code in blueye/sdk/cv_models.py
112 113 114 115 116 117 118 119 120 121 122 123 | |
rescan
rescan(timeout: float = 5) -> None
Ask the drone's vision pipeline to rescan the installed packages.
Uploads, deletions, and configuration changes trigger a rescan automatically; this is only needed after out-of-band changes.
Parameters:
-
timeout(float, default:5) –Request timeout in seconds.
Source code in blueye/sdk/cv_models.py
237 238 239 240 241 242 243 244 245 246 | |
set_device
set_device(
name: str, device: str, timeout: float = 5
) -> None
Set the execution provider a model runs on.
Parameters:
-
name(str) –The package's directory slug.
-
device(str) –One of :data:
VALID_DEVICES("cuda", "tensorrt", "tensorrt-dla0", "tensorrt-dla1"). -
timeout(float, default:5) –Request timeout in seconds.
Source code in blueye/sdk/cv_models.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
set_enabled
set_enabled(
name: str, enabled: bool, timeout: float = 5
) -> None
Enable or disable a model's autolaunch on the drone.
Parameters:
-
name(str) –The package's directory slug.
-
enabled(bool) –True to autolaunch the model, False to disable it.
-
timeout(float, default:5) –Request timeout in seconds.
Source code in blueye/sdk/cv_models.py
185 186 187 188 189 190 191 192 193 194 195 196 197 | |
set_hz
set_hz(name: str, hz: int, timeout: float = 5) -> None
Set a model's maximum inference rate.
Parameters:
-
name(str) –The package's directory slug.
-
hz(int) –One of :data:
VALID_HZ(0, 5, 10, 15); 0 means unlimited. -
timeout(float, default:5) –Request timeout in seconds.
Source code in blueye/sdk/cv_models.py
214 215 216 217 218 219 220 221 222 | |
upload
upload(package: Path | str, timeout: float = 60) -> CvModel
Upload a model package zip to the drone.
The drone validates the archive (it must contain a valid model_meta.json and the model file it references) and installs it into a directory named after the slugified model name — an existing package with the same slug is replaced.
Parameters:
-
package(Path | str) –Path to the package zip (e.g. produced by
blueye bundle-model). -
timeout(float, default:60) –Request timeout in seconds; model files can be large.
Returns:
-
CvModel–The installed model as reported by the drone.
Source code in blueye/sdk/cv_models.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
warmup
warmup(name: str, timeout: float = 600) -> None
Pre-build the model's inference engine on the drone.
For TensorRT devices this compiles the engine, which can take several minutes — subsequent launches then start instantly. Only available on the drone itself (the API answers 503 elsewhere).
Parameters:
-
name(str) –The package's directory slug.
-
timeout(float, default:600) –Request timeout in seconds; engine builds are slow.
Source code in blueye/sdk/cv_models.py
224 225 226 227 228 229 230 231 232 233 234 235 | |