Utilities
Learn about utility functions available for use with Autodistill.
Plot an Image with Predictions¶
Plot bounding boxes or segmentation masks on an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
np.ndarray
|
The image to plot on |
required |
detections |
The detections to plot |
required | |
classes |
List[str]
|
The classes to plot |
required |
raw |
Whether to return the raw image or plot it interactively |
False
|
Returns:
Type | Description |
---|---|
The raw image (np.ndarray) if raw=True, otherwise None (image is plotted interactively |
Source code in autodistill/utils.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
Compare Models¶
Compare the predictions of multiple models on multiple images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models |
list
|
The models to compare |
required |
images |
List[str]
|
The images to compare |
required |
Returns:
Type | Description |
---|---|
A grid of images with the predictions of each model on each image. |
Source code in autodistill/utils.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
Load an Image¶
Load an image from a file path, URI, PIL image, or numpy array.
This function is for use by Autodistill modules. You don't need to use it directly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Any
|
The image to load |
required |
return_format |
The format to return the image in |
'cv2'
|
Returns:
Type | Description |
---|---|
Any
|
The image in the specified format |
Source code in autodistill/helpers.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
Split Video Frames¶
Split a video into frames and save them to a directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_path |
str
|
The path to the video |
required |
output_dir |
str
|
The directory to save the frames to |
required |
stride |
int
|
The stride to use when splitting the video into frames |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in autodistill/helpers.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|