Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/classpose/entrypoints/predict_wsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ def fill_queue(self):
"""
self._init_slide()
self._get_tissue_contours()
if self.tissue_detection_model_path is not None and not self.tissue_cnts:
logger.warning("No tissue detected in slide. Skipping inference.")
for _ in range(self.n_none):
self.q.put((None, None))
return
n = 0
with tqdm(self.coords, desc="Tiles to predict: 0", position=0) as pbar:
for coords, tile_size in pbar:
Expand Down
9 changes: 9 additions & 0 deletions src/classpose/grandqc/wsi_tissue_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ def detect_tissue_wsi(
cv2.CHAIN_APPROX_SIMPLE,
)

if hierarchy is None:
grandqc_logger.warning("No tissue contours detected in slide.")
empty_geojson = {"type": "FeatureCollection", "features": []}
filled_class_map = np.zeros_like(end_image_class_map)
del model
del preprocessing_fn
del slide
return (image, filtered_mask, filled_class_map, {}, empty_geojson, mpp_model_td)

holes_idx = np.where(hierarchy[0, :, 3] != -1)[0]
scaling_array = np.array([observed_reduction_w, observed_reduction_h])
output_cnts = {}
Expand Down