predict
predict
#
predict — a monocular model's depth for every image of an array, in one GPU run.
- Weights. The model's snapshot is fetched (
cgr.depth.snapshot) before the GPU lock is taken, so a download never holds the GPU. - Run. The images are staged and the model's driver runs once over all
of them under
cgr.gpu_lock(): loading weights costs seconds and a prediction a fraction of one, so a page chooses the batch (a session). - Read. Each depth and confidence plane comes back as a
RelativeDepthat the staged size.
predict(images, model, max_dimension=1600)
#
The depth model predicts for each of images on its own, in the model's units.
The result is keyed on the whole array and the model, so call it per session rather than per scene and a new session never re-evaluates the old ones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
Array[Image]
|
The photographs to predict for. |
required |
model
|
Model
|
The model to run. |
required |
max_dimension
|
int
|
The longest side, in pixels, the images are staged at, which is the size the predictions come back at. |
1600
|
Raises:
| Type | Description |
|---|---|
ScratchError
|
If no GPU interpreter can be found. |
CalledProcessError
|
If the driver fails; the exception carries the tail of its log. |