Engine.predict_stream
Engine.predict_stream(model_name=None, split='test', *, space='model')(case, prediction) one source image at a time, instead of all of them at once.
predict returns a stacked array, so the whole split has to fit in memory. For a tiled split that is the whole thing at full resolution - 200 FIVES retinas at 2048 is 6.7 GB for the result alone - and tiling exists precisely for images too large to resize, so the stacked form is least usable exactly where splits is most needed. This yields one image, lets the caller keep what it wants, and drops it.
The case name comes with the prediction rather than being left to the caller to line up against samples: predictions arrive in the dataset’s order, and anything that pairs two sequences by position is one drop_last away from scoring the wrong image. group_of turns a case into a group the same way evaluate_cases does.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| model_name | str | None | Which model, by name. Defaults to the first. | None |
| split | str | Which data to predict on. | 'test' |
| space | str | As for predict - "model" for the network’s grid, "source" for the grid of the file each prediction came from. |
'model' |
Returns
| Name | Type | Description |
|---|---|---|
| Iterator[tuple[str, np.ndarray]] | An iterator of (case, prediction) in the dataset’s order. An iterator rather |
|
| Iterator[tuple[str, np.ndarray]] | than a list on purpose: a list would hold the whole split again. |