import cv
The cv module loads the single ESP-DL model stored in the firmware ai_model flash partition and exposes model lifecycle, metadata, profiling, and camera inference helpers.
Quick example
import cv
cv.load("hand_gesture_recognition")
result = cv.run_camera("predict")
if result["ok"]:
print(result["label"])
importcv
Computer vision and ESP-DL model module.
The cv module loads the single ESP-DL model stored in the firmware ai_model flash partition and exposes model lifecycle, metadata, profiling, and camera inference helpers.
cv.load(model_name: str) -> bool
cv.load(model_name: str) -> boolLoad the installed AI model and make it ready for inference.
import cv
cv.load("hand_gesture_recognition")
model_name str, required
Model ID of the model installed on this device.
bool
True when the model was loaded successfully.
Only one AI model is stored on the device at a time. Install or change the model from Studio before calling cv.load(...).
- No model is installed.
model_namedoes not match the installed model.- The model data is invalid.
- There is not enough free memory.
View available models
| Model | Task | Size | What it recognizes |
|---|---|---|---|
cat_detect
Cat Detect
|
Detect | 487 KB | Cat detector for ESP32-S3 camera input. |
dog_detect
Dog Detect
|
Detect | 488 KB | Dog detector for ESP32-S3 camera input. |
face_detect
Face Detect
|
Detect | 469 KB | Human face detector for ESP32-S3 camera input. |
hand_detect
Hand Detect
|
Detect | 486 KB | Hand detector for ESP32-S3 camera input. |
hand_gesture_recognition
Hand Gesture Recognition
|
Predict | 769 KB | Hand gesture classifier for ESP32-S3 camera input. |
pedestrian_detect
Pedestrian Detect
|
Detect | 425 KB | Pedestrian detector for ESP32-S3 camera input. |
if not cv.load("hand_gesture_recognition"):
print("Model failed to load")
cv.unload() -> any
cv.unload() -> anyUnload the current ESP-DL model and free its memory.
any Native unload result.
cv.loaded() -> bool
cv.loaded() -> boolReturn whether a model is currently loaded.
bool True when cv has an active ESP-DL model.
cv.test() -> bool
cv.test() -> boolRun ESP-DL embedded test vectors for the loaded model.
bool True when ESP-DL model self-test passes.
cv.profile(sort_by_latency: bool = None) -> any
cv.profile(sort_by_latency: bool = None) -> anyPrint ESP-DL memory and module latency profiling to firmware logs.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
sort_by_latency |
bool |
positional or keyword | No | Optional boolean to sort module profiling by latency. |
any Native profile result.
cv.profile_memory() -> any
cv.profile_memory() -> anyPrint ESP-DL memory profiling to firmware logs.
any Native profile result.
cv.profile_module(sort_by_latency: bool = None) -> any
cv.profile_module(sort_by_latency: bool = None) -> anyPrint ESP-DL module latency profiling to firmware logs.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
sort_by_latency |
bool |
positional or keyword | No | Optional boolean to sort modules by latency. |
any Native profile result.
cv.metadata(key: any) -> str
cv.metadata(key: any) -> strRead a metadata property from the loaded ESP-DL model.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
key |
any |
positional or keyword | Yes | Metadata property key. |
str Metadata property value as a string.
cv.predict_camera(top_k: int = None, score_threshold: float = None) -> dict
cv.predict_camera(top_k: int = None, score_threshold: float = None) -> dictCapture a camera frame and run it through the loaded image model.
The firmware always returns a map. On success, the map contains: ok: True. label: Top predicted label. Gesture models use labels like "one", "five", "ok", "no_gesture", and "no_hand". score: Top prediction score after softmax. predictions: Compact top-k string such as "five:0.9878, ok:0.0031, no_hand:0.0031". count: Number of returned predictions. class_count: Number of output classes. frame_width/frame_height/frame_len: Captured frame information. input_width/input_height: Model input image size. capture_ms/preprocess_ms/model_ms/postprocess_ms/total_ms: Timing information. On failure, the map contains: ok: False. error: Human-readable error string.
Use prediction models when the frame should produce one best label, such as a gesture or classification result.
label str
The top class returned by the model.
score float
Confidence score for the top label.
ok and count
Check these before reading label or score.
result = cv.predict_camera(top_k=1, score_threshold=0.30)
if result["ok"] and result["count"] > 0:
label = result["label"]
score = result["score"]
print(label)
print(score)
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
top_k |
int |
positional or keyword | No | Optional number of predictions to return. Defaults to 3. |
score_threshold |
float |
positional or keyword | No | Optional minimum score for returned predictions. Defaults to 0.0. |
dict Map-like prediction result.
cv.detect_camera(top_k: int = None, score_threshold: float = None, nms_threshold: float = None) -> dict
cv.detect_camera(top_k: int = None, score_threshold: float = None, nms_threshold: float = None) -> dictCapture a camera frame and run detector postprocessing on the loaded image model.
Supported detector outputs are ESP-DL Pico/ESPDET-style models with score/box tensor stages. On success, the map contains: ok: True. task: "detection". postprocess: Detector postprocessor route, such as "pico", "espdet", or "yolo11". detections: List of detection maps. Each item contains label, class_id, score, x, y, w, h, x1, y1, x2, y2. detections_text: Compact string such as "face:0.9123@[42,30,120,118]". count: Number of detections after thresholding and NMS. candidate_count: Number of candidates before NMS. class_count: Number of detector classes. threshold/nms_threshold: Thresholds used for the result. frame_width/frame_height/frame_len: Captured frame information. input_width/input_height: Model input image size. capture_ms/preprocess_ms/model_ms/postprocess_ms/total_ms: Timing information. On failure, the map contains: ok: False. error: Human-readable error string.
Use detection models when the frame can contain zero, one, or many objects and you need boxes around them.
detections list
Each detection includes label, score, x, y, w, and h.
detections_text str
Compact text for quick printing.
ok and count
Check these before reading detection boxes.
result = cv.detect_camera(top_k=5, score_threshold=0.50)
if result["ok"] and result["count"] > 0:
print(result["detections_text"])
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
top_k |
int |
positional or keyword | No | Optional maximum detections to return. Defaults to 10. |
score_threshold |
float |
positional or keyword | No | Optional minimum score. Defaults to 0.50. |
nms_threshold |
float |
positional or keyword | No | Optional IoU threshold for non-max suppression. Defaults to 0.45. |
dict Map-like detection result.
cv.run_camera(type: str, top_k: int = None, score_threshold: float = None, nms_threshold: float = None) -> dict
cv.run_camera(type: str, top_k: int = None, score_threshold: float = None, nms_threshold: float = None) -> dictConvenience wrapper that runs prediction or detection from one method. The route is not auto-detected from the model.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
type |
str |
positional | Yes | Required route. Use "predict" for classification or "detect" for detection; Studio does not infer this from the loaded model. |
top_k |
int |
positional or keyword | No | Optional prediction/detection count. |
score_threshold |
float |
positional or keyword | No | Optional score threshold. |
nms_threshold |
float |
positional or keyword | No | Optional detection-only NMS threshold. |
dict Map-like result from predict_camera or detect_camera.
cv.info() -> dict
cv.info() -> dictReturn cv module status and memory information.
dict Map-like value with partition, partition_size, loaded, model_name, heap_free, and psram_free.