init datamate

This commit is contained in:
Dallas98
2025-10-21 23:00:48 +08:00
commit 1c97afed7d
692 changed files with 135442 additions and 0 deletions

View 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")

View 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'

View 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