|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "fa584486", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [ |
| 9 | + { |
| 10 | + "name": "stderr", |
| 11 | + "output_type": "stream", |
| 12 | + "text": [ |
| 13 | + "|2025-12-17|18:50:54.872| [WARNING] /home/u1910100/miniconda3/envs/tiatoolbox-dev/lib/python3.12/site-packages/albumentations/__init__.py:28: UserWarning: A new version of Albumentations is available: '2.0.8' (you have '2.0.4'). Upgrade using: pip install -U albumentations. To disable automatic update checks, set the environment variable NO_ALBUMENTATIONS_UPDATE to 1.\n", |
| 14 | + " check_for_updates()\n", |
| 15 | + "\n" |
| 16 | + ] |
| 17 | + }, |
| 18 | + { |
| 19 | + "ename": "", |
| 20 | + "evalue": "", |
| 21 | + "output_type": "error", |
| 22 | + "traceback": [ |
| 23 | + "\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n", |
| 24 | + "\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n", |
| 25 | + "\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n", |
| 26 | + "\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details." |
| 27 | + ] |
| 28 | + } |
| 29 | + ], |
| 30 | + "source": [ |
| 31 | + "import sys\n", |
| 32 | + "sys.path.append(\"../\")\n", |
| 33 | + "import pathlib\n", |
| 34 | + "from tiatoolbox.models.engine.nucleus_detector import NucleusDetector\n", |
| 35 | + "from tiatoolbox.models.architecture.kongnet import KongNet" |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "code", |
| 40 | + "execution_count": null, |
| 41 | + "id": "78f694c7", |
| 42 | + "metadata": {}, |
| 43 | + "outputs": [ |
| 44 | + { |
| 45 | + "name": "stderr", |
| 46 | + "output_type": "stream", |
| 47 | + "text": [ |
| 48 | + "|2025-12-17|18:50:57.923| [WARNING] GPU is not compatible with torch.compile. Compatible GPUs include NVIDIA V100, A100, and H100. Speedup numbers may be lower than expected.\n" |
| 49 | + ] |
| 50 | + }, |
| 51 | + { |
| 52 | + "name": "stdout", |
| 53 | + "output_type": "stream", |
| 54 | + "text": [ |
| 55 | + "|2025-12-17|18:50:58.126| [INFO] When providing multiple whole slide images, the outputs will be saved and the locations of outputs will be returned to the calling function when `run()` finishes successfully.\n" |
| 56 | + ] |
| 57 | + }, |
| 58 | + { |
| 59 | + "data": { |
| 60 | + "application/vnd.jupyter.widget-view+json": { |
| 61 | + "model_id": "c6892643281f4d72844868ee40e1375d", |
| 62 | + "version_major": 2, |
| 63 | + "version_minor": 0 |
| 64 | + }, |
| 65 | + "text/plain": [ |
| 66 | + "Processing WSIs: 0%| | 0/1 [00:00<?, ?it/s]" |
| 67 | + ] |
| 68 | + }, |
| 69 | + "metadata": {}, |
| 70 | + "output_type": "display_data" |
| 71 | + }, |
| 72 | + { |
| 73 | + "name": "stderr", |
| 74 | + "output_type": "stream", |
| 75 | + "text": [ |
| 76 | + "|2025-12-17|18:50:58.311| [WARNING] Read: Scale > 1.This means that the desired resolution is higher than the WSI baseline (maximum encoded resolution). Interpolation of read regions may occur.\n" |
| 77 | + ] |
| 78 | + }, |
| 79 | + { |
| 80 | + "data": { |
| 81 | + "application/vnd.jupyter.widget-view+json": { |
| 82 | + "model_id": "3342b87637924ddcaa77bb121f27f4e7", |
| 83 | + "version_major": 2, |
| 84 | + "version_minor": 0 |
| 85 | + }, |
| 86 | + "text/plain": [ |
| 87 | + "Inferring patches: 0%| | 0/1004 [00:00<?, ?it/s]" |
| 88 | + ] |
| 89 | + }, |
| 90 | + "metadata": {}, |
| 91 | + "output_type": "display_data" |
| 92 | + }, |
| 93 | + { |
| 94 | + "name": "stdout", |
| 95 | + "output_type": "stream", |
| 96 | + "text": [ |
| 97 | + "Current Memory usage: 75.52868374109333 % exceeds specified threshold: 75. Saving intermediate results to disk.\n" |
| 98 | + ] |
| 99 | + } |
| 100 | + ], |
| 101 | + "source": [ |
| 102 | + "detector = NucleusDetector(model='KongNet_CoNIC_1')\n", |
| 103 | + "\n", |
| 104 | + "wsi_path = \"/media/u1910100/data/slides/TUM1.svs\"\n", |
| 105 | + "\n", |
| 106 | + "out = detector.run(\n", |
| 107 | + " images=[pathlib.Path(wsi_path)],\n", |
| 108 | + " patch_mode=False,\n", |
| 109 | + " device=\"cuda\",\n", |
| 110 | + " save_dir=pathlib.Path(\"/media/u1910100/data/overlays/test\"),\n", |
| 111 | + " overwrite=True,\n", |
| 112 | + " output_type=\"annotationstore\",\n", |
| 113 | + " auto_get_mask=True,\n", |
| 114 | + " memory_threshold=75,\n", |
| 115 | + " num_workers=1,\n", |
| 116 | + " batch_size=8,\n", |
| 117 | + ")" |
| 118 | + ] |
| 119 | + }, |
| 120 | + { |
| 121 | + "cell_type": "code", |
| 122 | + "execution_count": null, |
| 123 | + "id": "b559e6d0", |
| 124 | + "metadata": {}, |
| 125 | + "outputs": [], |
| 126 | + "source": [ |
| 127 | + "from tiatoolbox.annotation.storage import SQLiteStore\n", |
| 128 | + "\n", |
| 129 | + "store_path = \"/media/u1910100/data/overlays/test/wsi1_2k_2k.db\"\n", |
| 130 | + "store = SQLiteStore.open(store_path)\n", |
| 131 | + "\n", |
| 132 | + "for ann in store.values():\n", |
| 133 | + " print(ann)\n" |
| 134 | + ] |
| 135 | + }, |
| 136 | + { |
| 137 | + "cell_type": "code", |
| 138 | + "execution_count": null, |
| 139 | + "id": "e0db521a", |
| 140 | + "metadata": {}, |
| 141 | + "outputs": [], |
| 142 | + "source": [] |
| 143 | + } |
| 144 | + ], |
| 145 | + "metadata": { |
| 146 | + "kernelspec": { |
| 147 | + "display_name": "tiatoolbox-dev", |
| 148 | + "language": "python", |
| 149 | + "name": "python3" |
| 150 | + }, |
| 151 | + "language_info": { |
| 152 | + "codemirror_mode": { |
| 153 | + "name": "ipython", |
| 154 | + "version": 3 |
| 155 | + }, |
| 156 | + "file_extension": ".py", |
| 157 | + "mimetype": "text/x-python", |
| 158 | + "name": "python", |
| 159 | + "nbconvert_exporter": "python", |
| 160 | + "pygments_lexer": "ipython3", |
| 161 | + "version": "3.12.12" |
| 162 | + } |
| 163 | + }, |
| 164 | + "nbformat": 4, |
| 165 | + "nbformat_minor": 5 |
| 166 | +} |
0 commit comments