Label and Predict#

This notebook uses the napari-easy-augment-batch-dl widget to explore and label the data. If we have a model trained we can also predict using that model.

import os
import numpy as np
import napari
from napari_easy_augment_batch_dl import easy_augment_batch_dl
c:\Users\bnort\miniconda3\envs\pytorch_and_SAM3\lib\site-packages\tqdm\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
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_series')
model_path = os.path.join(parent_path, 'models')

model_name = 'cellpose_ladybugs_scale2'
#mod = models.Cellpose(gpu=True, model_type="cyto3")
model_type = "CellPose Instance 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)

    model = batch_dl.deep_learning_project.models[model_type]
    model.prob_thresh = -1
    model.flow_thresh = 0.4
    model.chan_segment = 0
    model.chan2 = 1
       

    widget = batch_dl.param_widgets[model_type]
    widget.sync_with_model()
VIT checkpoint loaded successfully
found class  PytorchSemanticModel
found class  CellPoseInstanceModel
2024-11-11 05:38:33,898 [INFO] WRITING LOG OUTPUT TO C:\Users\bnort\.cellpose\run.log
2024-11-11 05:38:33,899 [INFO] 
cellpose version: 	3.0.9 
platform:       	win32 
python version: 	3.10.14 
torch version:  	2.2.2+cu118
found class  MobileSAMModel
found class  YoloSAMModel
2024-11-11 05:38:42,531 [INFO] ** TORCH CUDA version installed and working. **
2024-11-11 05:38:42,532 [INFO] >>>> using GPU
2024-11-11 05:38:42,660 [INFO] >>>> loading model ../../data\ladybugs_series\models\cellpose_ladybugs_scale2
2024-11-11 05:38:42,870 [INFO] >>>> model diam_mean =  30.000 (ROIs rescaled to this size during training)
2024-11-11 05:38:42,872 [INFO] >>>> model diam_labels =  181.358 (mean diameter of training ROIs)
WARNING: QWindowsWindow::setGeometry: Unable to set geometry 1920x1019+1920+23 (frame: 1936x1058+1912-8) on QWidgetWindow/"_QtMainWindowClassWindow" on "\\.\DISPLAY2". Resulting geometry: 1920x1017+1920+23 (frame: 1936x1056+1912-8) margins: 8, 31, 8, 8 minimum size: 886x1019 MINMAXINFO maxSize=0,0 maxpos=0,0 mintrack=902,1058 maxtrack=0,0)
2024-11-11 06:16:15,613 [WARNING] QWindowsWindow::setGeometry: Unable to set geometry 1920x1019+1920+23 (frame: 1936x1058+1912-8) on QWidgetWindow/"_QtMainWindowClassWindow" on "\\.\DISPLAY2". Resulting geometry: 1920x1017+1920+23 (frame: 1936x1056+1912-8) margins: 8, 31, 8, 8 minimum size: 886x1019 MINMAXINFO maxSize=0,0 maxpos=0,0 mintrack=902,1058 maxtrack=0,0)