Spaces:
Sleeping
Sleeping
| import matplotlib.pyplot as plt | |
| from tiatoolbox.data import small_svs | |
| from tiatoolbox.wsicore.wsireader import WSIReader | |
| import gradio as gr | |
| from pprint import pprint | |
| from PIL import Image | |
| wsi2png_examples = [['images/sample_wsi_small.svs']] | |
| def wsi2png(wsi_file): | |
| print(wsi_file.name) | |
| reader = WSIReader.open(wsi_file.name) | |
| reader.info.objective_power = 1.0 | |
| info_dict = reader.info.as_dict() | |
| pprint(info_dict) | |
| thumbnail = reader.slide_thumbnail(resolution=0.1, units="mpp") | |
| return thumbnail | |
| read_bounds_examples = [['images/sample_wsi_small.png']] | |
| def read_bounds_of_image(image): | |
| return image | |
| mask_wsi_examples = [['images/sample_wsi_small.svs']] | |
| def mask_image(wsi_file, resolution): | |
| reader = WSIReader.open(wsi_file.name) | |
| mask_reader = reader.tissue_mask(resolution=resolution, units="mpp") | |
| mask_thumbnail = mask_reader.slide_thumbnail(resolution=resolution, units="power") | |
| mask_thumbnail *= 255 | |
| return mask_thumbnail | |