You've already forked DataMate
init datamate
This commit is contained in:
6
runtime/ops/formatter/slide_formatter/__init__.py
Normal file
6
runtime/ops/formatter/slide_formatter/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from datamate.core.base_op import OPERATORS
|
||||
|
||||
OPERATORS.register_module(module_name='SlideFormatter',
|
||||
module_path="ops.formatter.slide_formatter.process")
|
||||
16
runtime/ops/formatter/slide_formatter/metadata.yml
Normal file
16
runtime/ops/formatter/slide_formatter/metadata.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
name: '病理图片内容抽取'
|
||||
name_en: 'Pathology Image Content Extraction'
|
||||
description: '解析病理图片。'
|
||||
description_en: 'Analyze pathological images.'
|
||||
language: 'python'
|
||||
vendor: 'huawei'
|
||||
raw_id: 'SlideFormatter'
|
||||
version: '1.0.0'
|
||||
types:
|
||||
- 'collect'
|
||||
modal: 'image'
|
||||
effect:
|
||||
before: ''
|
||||
after: ''
|
||||
inputs: 'image'
|
||||
outputs: 'image'
|
||||
36
runtime/ops/formatter/slide_formatter/process.py
Normal file
36
runtime/ops/formatter/slide_formatter/process.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# -- encoding: utf-8 --
|
||||
|
||||
"""
|
||||
Description: 医疗图片解析载入
|
||||
Create: 2025/02/08 11:00
|
||||
"""
|
||||
|
||||
import time
|
||||
from typing import Dict, Any
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from datamate.core.base_op import Mapper
|
||||
|
||||
|
||||
class SlideFormatter(Mapper):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SlideFormatter, self).__init__(*args, **kwargs)
|
||||
|
||||
def execute(self, sample: Dict[str, Any]) -> Dict[str, Any]:
|
||||
'''
|
||||
Read medical image and corresponding mask file, each as Image type in COntent value. Return Content.
|
||||
'''
|
||||
start = time.time()
|
||||
file_type = sample[self.filetype_key]
|
||||
types_openslide = ['svs', 'tif', 'dcm', 'vms', 'vmu',
|
||||
'ndpi', 'scn', 'mrxs', 'tiff', 'svslide',
|
||||
'bif', 'czi', 'sdpc']
|
||||
if file_type not in types_openslide:
|
||||
raise TypeError(f"Format not supported: {file_type}. Supported formats are: {', '.join(types_openslide)}.")
|
||||
|
||||
file_name = sample[self.filename_key]
|
||||
logger.info(f"fileName: {file_name}, method: SlideFormatter costs {(time.time() - start):6f} s")
|
||||
# Not really loading the slide, instead, use path as lazy loading.
|
||||
return sample
|
||||
Reference in New Issue
Block a user