ποΈStep 1: Integrating Lens AI Python Profiler
Last updated
Last updated
# lensai profiler library
from lensai_profiler.metrics import process_batch
from lensai_profiler.sketches import Sketches
# Initialize Lens AI sketches
num_channels = 3 # Assuming RGB images
sketches = Sketches(num_channels)
# Apply map function in parallel to compute metrics
base_metrics = train_dataset.map(
lambda images, labels: process_batch(images),
num_parallel_calls=tf.data.AUTOTUNE
)
# Iterate through the dataset and update the KLL sketches in parallel
for brightness, sharpness, channel_mean, snr, channel_pixels in train_dataset:
sketches.tf_update_sketches(brightness, sharpness, channel_mean, snr, channel_pixels)# Save the KLL sketches to a specified directory
save_path = '/content/sample_data/'
sketches.save_sketches(save_path)sketches.compute_thresholds()