@@ -7331,7 +7331,7 @@ class LoadImage(Feature):
73317331 """Load an image from disk and preprocess it.
73327332
73337333 `LoadImage` loads an image file using multiple fallback file readers
7334- (`imageio `, `numpy `, `Pillow`, and `OpenCV`) until a suitable reader is
7334+ (`ImageIO `, `NumPy `, `Pillow`, and `OpenCV`) until a suitable reader is
73357335 found. The image can be optionally converted to grayscale, reshaped to
73367336 ensure a minimum number of dimensions, or treated as a list of images if
73377337 multiple paths are provided.
@@ -7342,36 +7342,28 @@ class LoadImage(Feature):
73427342 The path(s) to the image(s) to load. Can be a single string or a list
73437343 of strings.
73447344 load_options: PropertyLike[dict[str, Any]], optional
7345- Additional options passed to the file reader. It defaults to `None`.
7345+ Additional options passed to the file reader. Defaults to `None`.
73467346 as_list: PropertyLike[bool], optional
73477347 If `True`, the first dimension of the image will be treated as a list.
7348- It defaults to `False`.
7348+ Defaults to `False`.
73497349 ndim: PropertyLike[int], optional
7350- Ensures the image has at least this many dimensions. It defaults to
7351- `3`.
7350+ Ensures the image has at least this many dimensions. Defaults to `3`.
73527351 to_grayscale: PropertyLike[bool], optional
7353- If `True`, converts the image to grayscale. It defaults to `False`.
7352+ If `True`, converts the image to grayscale. Defaults to `False`.
73547353 get_one_random: PropertyLike[bool], optional
73557354 If `True`, extracts a single random image from a stack of images. Only
7356- used when `as_list` is `True`. It defaults to `False`.
7355+ used when `as_list` is `True`. Defaults to `False`.
73577356
73587357 Attributes
73597358 ----------
73607359 __distributed__: bool
7361- Indicates whether this feature distributes computation across inputs.
7362- It defaults to `False`.
7360+ Set to `False`, indicating that this feature’s `.get()` method
7361+ processes the entire input at once even if it is a list, rather than
7362+ distributing calls for each item of the list.
73637363
73647364 Methods
73657365 -------
7366- `get(
7367- path: str | list[str],
7368- load_options: dict[str, Any] | None,
7369- ndim: int,
7370- to_grayscale: bool,
7371- as_list: bool,
7372- get_one_random: bool,
7373- **kwargs: Any,
7374- ) -> NDArray | list[NDArray] | torch.Tensor | list[torch.Tensor]`
7366+ `get(...) -> NDArray | list[NDArray] | torch.Tensor | list[torch.Tensor]`
73757367 Load the image(s) from disk and process them.
73767368
73777369 Raises
@@ -7390,21 +7382,25 @@ class LoadImage(Feature):
73907382 >>> import deeptrack as dt
73917383
73927384 Create a temporary image file:
7385+
73937386 >>> import numpy as np
73947387 >>> import os, tempfile
73957388 >>>
73967389 >>> temp_file = tempfile.NamedTemporaryFile(suffix=".npy", delete=False)
73977390 >>> np.save(temp_file.name, np.random.rand(100, 100, 3))
73987391
73997392 Load the image using `LoadImage`:
7393+
74007394 >>> load_image_feature = dt.LoadImage(path=temp_file.name)
74017395 >>> loaded_image = load_image_feature.resolve()
74027396
74037397 Print image shape:
7398+
74047399 >>> loaded_image.shape
74057400 (100, 100, 3)
74067401
74077402 If `to_grayscale=True`, the image is converted to single channel:
7403+
74087404 >>> load_image_feature = dt.LoadImage(
74097405 ... path=temp_file.name,
74107406 ... to_grayscale=True,
@@ -7414,6 +7410,7 @@ class LoadImage(Feature):
74147410 (100, 100, 1)
74157411
74167412 If `ndim=4`, additional dimensions are added if necessary:
7413+
74177414 >>> load_image_feature = dt.LoadImage(
74187415 ... path=temp_file.name,
74197416 ... ndim=4,
@@ -7423,13 +7420,15 @@ class LoadImage(Feature):
74237420 (100, 100, 3, 1)
74247421
74257422 Load an image as a PyTorch tensor by setting the backend of the feature:
7423+
74267424 >>> load_image_feature = dt.LoadImage(path=temp_file.name)
74277425 >>> load_image_feature.torch()
74287426 >>> loaded_image = load_image_feature.resolve()
74297427 >>> type(loaded_image)
74307428 <class 'torch.Tensor'>
74317429
74327430 Cleanup the temporary file:
7431+
74337432 >>> os.remove(temp_file.name)
74347433
74357434 """
@@ -7455,19 +7454,19 @@ def __init__(
74557454 list of strings.
74567455 load_options: PropertyLike[dict[str, Any]], optional
74577456 Additional options passed to the file reader (e.g., `mode` for
7458- OpenCV, `allow_pickle` for NumPy). It defaults to `None`.
7457+ OpenCV, `allow_pickle` for NumPy). Defaults to `None`.
74597458 as_list: PropertyLike[bool], optional
74607459 If `True`, treats the first dimension of the image as a list of
7461- images. It defaults to `False`.
7460+ images. Defaults to `False`.
74627461 ndim: PropertyLike[int], optional
74637462 Ensures the image has at least this many dimensions. If the loaded
7464- image has fewer dimensions, extra dimensions are added. It defaults
7465- to `3`.
7463+ image has fewer dimensions, extra dimensions are added. Defaults to
7464+ `3`.
74667465 to_grayscale: PropertyLike[bool], optional
7467- If `True`, converts the image to grayscale. It defaults to `False`.
7466+ If `True`, converts the image to grayscale. Defaults to `False`.
74687467 get_one_random: PropertyLike[bool], optional
74697468 If `True`, selects a single random image from a stack when
7470- `as_list=True`. It defaults to `False`.
7469+ `as_list=True`. Defaults to `False`.
74717470 **kwargs: Any
74727471 Additional keyword arguments passed to the parent `Feature` class,
74737472 allowing further customization.
@@ -7486,19 +7485,19 @@ def __init__(
74867485
74877486 def get (
74887487 self : Feature ,
7489- * ign : Any ,
7488+ * _ : Any ,
74907489 path : str | list [str ],
74917490 load_options : dict [str , Any ] | None ,
74927491 ndim : int ,
74937492 to_grayscale : bool ,
74947493 as_list : bool ,
74957494 get_one_random : bool ,
74967495 ** kwargs : Any ,
7497- ) -> NDArray [Any ] | torch .Tensor | list :
7496+ ) -> NDArray [Any ] | torch .Tensor | list [ NDArray [ Any ] | torch . Tensor ] :
74987497 """Load and process an image or a list of images from disk.
74997498
75007499 This method attempts to load an image using multiple file readers
7501- (`imageio `, `numpy `, `Pillow`, and `OpenCV`) until a valid format is
7500+ (`ImageIO `, `NumPy `, `Pillow`, and `OpenCV`) until a valid format is
75027501 found. It supports optional processing steps such as ensuring a minimum
75037502 number of dimensions, grayscale conversion, and treating multi-frame
75047503 images as lists.
@@ -7514,25 +7513,25 @@ def get(
75147513 loads one image, while a list of paths loads multiple images.
75157514 load_options: dict of str to Any, optional
75167515 Additional options passed to the file reader (e.g., `allow_pickle`
7517- for NumPy, `mode` for OpenCV). It defaults to `None`.
7516+ for NumPy, `mode` for OpenCV). Defaults to `None`.
75187517 ndim: int
75197518 Ensures the image has at least this many dimensions. If the loaded
7520- image has fewer dimensions, extra dimensions are added. It defaults
7521- to `3`.
7519+ image has fewer dimensions, extra dimensions are added. Defaults to
7520+ `3`.
75227521 to_grayscale: bool
7523- If `True`, converts the image to grayscale. It defaults to `False`.
7522+ If `True`, converts the image to grayscale. Defaults to `False`.
75247523 as_list: bool
75257524 If `True`, treats the first dimension as a list of images instead
7526- of stacking them into a NumPy array. It defaults to `False`.
7525+ of stacking them into a NumPy array. Defaults to `False`.
75277526 get_one_random: bool
75287527 If `True`, selects a single random image from a multi-frame stack
7529- when `as_list=True`. It defaults to `False`.
7528+ when `as_list=True`. Defaults to `False`.
75307529 **kwargs: Any
75317530 Additional keyword arguments.
75327531
75337532 Returns
75347533 -------
7535- array
7534+ array or list of arrays
75367535 The loaded and processed image(s). If `as_list=True`, returns a
75377536 list of images; otherwise, returns a single NumPy array or PyTorch
75387537 tensor.
0 commit comments