Reference
Detailed reference
class Babylog
Used to log information about image predictions made by a computer vision model. The class has several features, including the ability to save log information locally, in the cloud (on Amazon S3), the ability to stream log information, and the ability to use multiple worker threads to handle logging tasks.
The
__init__
method is used to initialize the class and set various properties, such as the configuration path, whether to save logs locally and/or in the cloud, and whether to stream log information. The method also creates a thread pool executor, which is used to handle logging tasks.
config_path
str
path to the yaml config file
Required
N/A
save_local
bool
setting to save logs locally
Optional
True
save_cloud
bool
setting to save logs on the cloud
Optional
False
stream
bool
setting to stream logs via tcp
Optional
False
The
log
method is used to log information about an image prediction. The method takes a number of arguments, including the image, the model type, the model name and version, and various other information about the prediction, such as the prediction itself, the timestamp, the latency, and the inference device. The method submits a logging task to the thread pool executor, which will handle the task in the background.
image
np.ndarray
raw image to be logged
Required
N/A
N/A
model_type
VisionModelType
type of vision model
Required
N/A
(VisionModelType.DETECTION, VisionModelType.CLASSIFICATION)
model_name
str
name of model used
Required
N/A
'resnet50_'inetuned
model_version
str
version of model used
Required
N/A
'1.0.0'
home_dir
str
directory for local logging
Optional
'./babylog/'
'./babylog/'
prediction
np.ndarray
prediction image (annotated...)
Optional
None
N/A
timestamp
int
timestamp
Optional
None
1674993193473
latency
int
inference time in ms
Optional
None
10
inference_device
InferenceDevice
type of inference device
Optional
None
(InferenceDevice.CPU, InferenceDevice.GPU, InferenceDevice.CUDA)
classification
Dict[str, float]
dictionary containing classification information
Optional
None
detection
List[Dict]
dictionary containing detection information
Optional
None
error_message
str
error message while inference was done
Optional
''
"Out of memory error"
class LoggedPrediction
Used to deserialize a logged prediction and return logged information(image, annotation, errors,...)
the
from_path
method is a class method to load a saved serialized message('.bin') fromfilepath
of type strthe
from_bytes
method is a class method to load a serialized message frombinary_
of typebytes
LoggedPrediction:
model
Dict
dictionary storing model information
inference_stats
Dict
dictionary for storing inference information
device_details
Dict
dictionary for storing device details
timestamp
int
timestamp
1674993193473
classification
List[Dict]
dictionary containing classification information
detection
List[Dict]
dictionary containing detection information
image
np.ndarray
logged raw image
N/A
prediction
np.ndarray
logged prediction image
N/A
Last updated