Explore and label the ‘sparse labels’ Data#

This notebook uses the napari-easy-augment-batch-dl widget to explore and label the data. We point the plugin to the ‘ladybugs_sparse’ directory which contains 3 highly clustered lady bug images, and we use the ‘ladybug_sparse’ model which has been pretrained on the sparse labels.

Take home point: The model does pretty predicting ladybugs that were not labeled on the same images that were partially labeled. However not so good on the image which did not have any data labeled. More training images are likely needed to get a good lady bug model… the good news is we probably don’t have to label every single ladybug on all images, we can sparsely label several images to accelerate the process.

import os
import numpy as np
import napari
from napari_easy_augment_batch_dl import easy_augment_batch_dl
INFO:albumentations.check_version:A new version of Albumentations is available: 1.4.21 (you have 1.4.8). Upgrade using: pip install --upgrade albumentations
viewer = napari.Viewer()

batch_dl = easy_augment_batch_dl.NapariEasyAugmentBatchDL(viewer, label_only = False)

viewer.window.add_dock_widget(
    batch_dl
)

data_path = r'../../data'
parent_path = os.path.join(data_path, 'ladybugs_sparse')
model_path = os.path.join(parent_path, 'models')

model_name = 'ladybug_sparse'
model_type = "Stardist Model"
batch_dl.load_image_directory(parent_path)


if model_name is not None:
    batch_dl.network_architecture_drop_down.setCurrentText(model_type)
    batch_dl.deep_learning_project.set_pretrained_model(os.path.join(model_path, model_name), model_type)
    widget = batch_dl.param_widgets[model_type]
    widget.sync_with_model()
No module named 'segment_everything'
found class  StardistInstanceModel
Loading network weights from 'weights_best.h5'.
Couldn't load thresholds from 'thresholds.json', using default values. (Call 'optimize_thresholds' to change that.)
Using default values: prob_thresh=0.5, nms_thresh=0.4.