📖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.

ArgumentTypeDescriptionRequiredDefault Value

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.

ArgumentTypeDescriptionRequiredDefault ValueExamples

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

{"dog": 0.8,
 "cat": 0.2
 }

detection

List[Dict]

dictionary containing detection information

Optional

None

[
    {
        "x": 10,
        "y": 10,
        "width": 100,
        "height": 220,
        "confidence": 0.97,
        "classification": {"dog": 0.8, "cat": 0.2},
    },

    {
        "x": 20,
        "y": 10,
        "width": 100,
        "height": 220,
        "confidence": 0.97,
        "classification": {"dog": 0.8, "cat": 0.2},
    },
]

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_pathmethod is a class method to load a saved serialized message('.bin') from filepath of type str

  • the from_bytesmethod is a class method to load a serialized message from binary_ of type bytes

  • LoggedPrediction:

PropertyTypeDescriptionExamples

model

Dict

dictionary storing model information

{
  'type': 'DETECTION', 
  'version': '1.0.0', 
  'name': 'resnet50_finetuned'
}

inference_stats

Dict

dictionary for storing inference information

{
  'latency': 50, 
  'inferenceDevice': 'CPU', 
  'errorMessage': ''
}

device_details

Dict

dictionary for storing device details

{
  'deviceName': 'DEVICE_NAME',
  'groupName': 'GROUP_NAME'
}

timestamp

int

timestamp

1674993193473

classification

List[Dict]

dictionary containing classification information

[
  {'className': 'dog', 'probability': 0.5}, 
  {'className': 'cat', 'probability': 0.5}
]

detection

List[Dict]

dictionary containing detection information

[{'x': 1, 'y': 1, 'width': 100, 'height': 220, 'confidence': 0.97, 'classificationResult': [{'className': 'dog', 'probability': 0.8}, {'className': 'cat', 'probability': 0.2}]}, {'x': 1, 'y': 1, 'width': 50, 'height': 150, 'confidence': 0.97, 'classificationResult': [{'className': 'dog', 'probability': 0.5}, {'className': 'cat', 'probability': 0.5}]}]

image

np.ndarray

logged raw image

N/A

prediction

np.ndarray

logged prediction image

N/A

Last updated