[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-mahmoodlab--TRIDENT":3,"tool-mahmoodlab--TRIDENT":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",145895,2,"2026-04-08T11:32:59",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":77,"owner_twitter":78,"owner_website":79,"owner_url":80,"languages":81,"stars":90,"forks":91,"last_commit_at":92,"license":93,"difficulty_score":10,"env_os":94,"env_gpu":95,"env_ram":96,"env_deps":97,"category_tags":106,"github_topics":107,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":114,"updated_at":115,"faqs":116,"releases":145},5604,"mahmoodlab\u002FTRIDENT","TRIDENT","Toolkit for large-scale whole-slide image processing. ","TRIDENT 是一款专为大规模全切片病理图像（WSI）处理打造的开源工具包，由哈佛医学院 Mahmood 实验室研发。它旨在解决病理 AI 研究中处理海量高分辨率扫描图像时面临的效率瓶颈与技术门槛，让从组织分割到特征提取的全流程更加流畅高效。\n\n这款工具非常适合病理学研究人员、生物信息学家以及从事医疗 AI 开发的工程师使用。用户利用 TRIDENT 可以轻松完成多项核心任务：自动从背景中精准提取组织区域（支持去除伪影和笔迹干扰）、按需截取不同倍率的图像块，并调用超过 20 种前沿基础模型（如 UNI、Virchow、GigaPath 等）快速提取高质量的图像特征向量。\n\nTRIDENT 的独特亮点在于其强大的兼容性与扩展性。它不仅原生支持多种主流病理图像格式及转换，还创新性地引入了针对有限存储空间的批量缓存机制，显著提升了在大规模数据集上的处理速度。此外，工具集成了包括最新 Threads 在内的多种切片级基础模型，并提供了详细的安装检查脚本，帮助用户在本地或离线环境中稳定运行复杂的深度学习管道，是加速数字病理研究与临床转化的得力助手。","# 🔱   Trident\n\n [arXiv](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2502.06750) | [Blog](https:\u002F\u002Fwww.linkedin.com\u002Fpulse\u002Fannouncing-new-open-source-tools-accelerate-ai-pathology-andrew-zhang-loape\u002F?trackingId=pDkifo54SRuJ2QeGiGcXpQ%3D%3D) | [Cite](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident?tab=readme-ov-file#reference)\n| [Documentation](https:\u002F\u002Ftrident-docs.readthedocs.io\u002Fen\u002Flatest\u002F) | [License](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident?tab=License-1-ov-file)\n \nTrident is a toolkit for large-scale whole-slide image processing.\nThis project was developed by the [Mahmood Lab](https:\u002F\u002Ffaisal.ai\u002F) at Harvard Medical School and Brigham and Women's Hospital. This work was funded by NIH NIGMS R35GM138216.\n\n> [!NOTE]\n> Contributions are welcome! Please report any issues. You may also contribute by opening a pull request.\n\n### Key Features:\n\n\u003Cimg align=\"right\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmahmoodlab_TRIDENT_readme_a6ad76eba430.jpg\" width=\"250px\" \u002F>\n\n- **Tissue Segmentation**: Extract tissue from background (H&E, IHC, etc.).\n- **Patch Extraction**: Extract tissue patches of any size and magnification.\n- **Patch Feature Extraction**: Extract patch embeddings from 20+ foundation models, including [UNI](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41591-024-02857-3), [Virchow](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41591-024-03141-0), [H-Optimus-0](https:\u002F\u002Fgithub.com\u002Fbioptimus\u002Freleases\u002Ftree\u002Fmain\u002Fmodels\u002Fh-optimus\u002Fv0) and more...\n- **Slide Feature Extraction**: Extract slide embeddings from 5+ slide foundation models, including [Threads](https:\u002F\u002Farxiv.org\u002Fabs\u002F2501.16652) (coming soon!), [Titan](https:\u002F\u002Farxiv.org\u002Fabs\u002F2411.19666), and [GigaPath](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41586-024-07441-w). \n\n### Updates:\n- 07.25: Support for [Feather](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FMIL-Lab) model.\n- 05.25: New batch-wise WSI caching for scalable processing on limited SSD space + nested WSI search (`--search_nested`).\n- 04.25: Native support for PIL.Image and CuCIM (use `wsi = load_wsi(xxx.svs)`). Support for seg + patch encoding without Internet.\n- 04.25: Remove artifacts\u002Fpenmarks from the tissue segmentation with `--remove_artifacts` and `--remove_penmarks`. \n- 02.25: New image converter from `czi`, `png`, etc to `tiff`.\n- 02.25: Support for GrandQC([Citation necessary](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y), [Non-commercial use](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-sa\u002F4.0\u002F), [Original repository](https:\u002F\u002Fgithub.com\u002Fcpath-ukk\u002Fgrandqc)) tissue vs. background segmentation.\n- 02.25: Support for [Madeleine](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FMADELEINE\u002Ftree\u002Fmain), [Hibou](https:\u002F\u002Fgithub.com\u002FHistAI\u002Fhibou), [Lunit](https:\u002F\u002Fhuggingface.co\u002F1aurent\u002Fvit_small_patch8_224.lunit_dino), [Kaiko](https:\u002F\u002Fhuggingface.co\u002Fhistai\u002Fhibou-L), and [H-Optimus-1](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH-optimus-1) models.\n\n> [!NOTE]\n> GrandQC is integrated into Trident under the CC BY-NC-SA 4.0 license. If you use GrandQC, please cite their [original publication](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y).\n\n\n### 🔨 1. **Installation**:\n- Create an environment (Python 3.10 or 3.11): `conda create -n \"trident\" python=3.10`, and activate it `conda activate trident`.\n- Cloning: `git clone https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident.git && cd trident`.\n- Local installation: `pip install -e .`.\n  - This installs the shared model stack (`transformers`, `timm`, `safetensors`, etc.).\n\nOptional install profiles:\n- `pip install -e \".[patch-encoders]\"` for CONCH\u002FMUSK\u002FCTransPath-related extras.\n- `pip install -e \".[slide-encoders]\"` for PRISM\u002FGigaPath\u002FMadeleine-related extras.\n- `pip install -e \".[omezarr]\"` for OME Zarr WSI reader support\n- `pip install -e \".[convert]\"` for slide conversion dependencies.\n- `pip install -e \".[full]\"` to install all pip-installable optional dependencies.\n\nRun checks before launching jobs:\n- `trident-doctor --profile base`\n- `trident-doctor --profile patch-encoders --check-gated`\n- `trident-doctor --profile slide-encoders`\n- `trident-doctor --profile convert`\n- `trident-doctor --profile full --check-gated`\n\n> [!NOTE]\n> Some models still require manual setup (e.g., local CHIEF repository path in `trident\u002Fslide_encoder_models\u002Flocal_ckpts.json`) or HuggingFace gated access approvals.\n\n### 🔨 2. **Running Trident**:\n\nCLI options (all are supported):\n- `python run_batch_of_slides.py ...` (existing command)\n- `python run_single_slide.py ...` (existing command)\n- `trident batch ...`, `trident single ...`, `trident convert ...`, and `trident doctor ...` (wrapper CLI)\n\n**Already familiar with WSI processing?** Perform segmentation, patching, and UNI feature extraction from a directory of WSIs with:\n\n```\npython run_batch_of_slides.py --task all --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\nEquivalent wrapper CLI:\n```\ntrident batch -- --task all --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n**Feeling cautious?**\n\nRun this command to perform all processing steps for a **single** slide:\n```\npython run_single_slide.py --slide_path .\u002Fwsis\u002Fxxxx.svs --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\nEquivalent wrapper CLI:\n```\ntrident single -- --slide_path .\u002Fwsis\u002Fxxxx.svs --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\nConvert images\u002FWSIs to pyramidal TIFF:\n```\ntrident convert --input_dir .\u002Fwsis --mpp_csv .\u002Fwsis\u002Fto_process.csv --job_dir .\u002Fpyramidal_tiff --downscale_by 1 --num_workers 1\n```\n`--mpp_csv` is required and must contain `wsi,mpp` columns. Only files listed in the CSV are converted.\nIf embedded MPP metadata is detected in a slide, Trident compares it to the CSV value and logs mismatches.\n\n**Or follow step-by-step instructions:**\n\n**Step 1: Tissue Segmentation:** Segments tissue vs. background from a dir of WSIs\n - **Command**:\n   ```bash\n   python run_batch_of_slides.py --task seg --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --gpu 0 --segmenter hest\n   ```\n   - `--task seg`: Specifies that you want to do tissue segmentation.\n   - `--wsi_dir .\u002Fwsis`: Path to dir with your WSIs.\n   - `--job_dir .\u002Ftrident_processed`: Output dir for processed results.\n   - `--gpu 0`: Uses GPU with index 0.\n  - `--segmenter`: Segmentation model. Defaults to `hest`. Use `grandqc` ([Citation necessary](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y), [Non-commercial use](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-sa\u002F4.0\u002F), [Original repository](https:\u002F\u002Fgithub.com\u002Fcpath-ukk\u002Fgrandqc)) for fast H&E segmentation or `otsu` for a classical image-processing-only fallback. Add the option `--remove_artifacts` for additional artifact clean up.\n - **Outputs**:\n   - WSI thumbnails in `.\u002Ftrident_processed\u002Fthumbnails`.\n   - WSI thumbnails with tissue contours in `.\u002Ftrident_processed\u002Fcontours`.\n   - GeoJSON files containing tissue contours in `.\u002Ftrident_processed\u002Fcontours_geojson`. These can be opened in [QuPath](https:\u002F\u002Fqupath.github.io\u002F) for editing\u002Fquality control, if necessary.\n\n **Step 2: Tissue Patching:** Extracts patches from segmented tissue regions at a specific magnification.\n - **Command**:\n   ```bash\n   python run_batch_of_slides.py --task coords --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --mag 20 --patch_size 256 --overlap 0\n   ```\n   - `--task coords`: Specifies that you want to do patching.\n   - `--wsi_dir wsis`: Path to the dir with your WSIs.\n   - `--job_dir .\u002Ftrident_processed`: Output dir for processed results.\n   - `--mag 20`: Extracts patches at 20x magnification.\n   - `--patch_size 256`: Each patch is 256x256 pixels.\n   - `--overlap 0`: Patches overlap by 0 pixels (**always** an absolute number in pixels, e.g., `--overlap 128` for 50% overlap for 256x256 patches.\n - **Outputs**:\n   - Patch coordinates as h5 files in `.\u002Ftrident_processed\u002F20x_256px\u002Fpatches`.\n   - WSI thumbnails annotated with patch borders in `.\u002Ftrident_processed\u002F20x_256px\u002Fvisualization`.\n\n **Step 3a: Patch Feature Extraction:** Extracts features from tissue patches using a specified encoder\n - **Command**:\n   ```bash\n   python run_batch_of_slides.py --task feat --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256 \n   ```\n   - `--task feat`: Specifies that you want to do feature extraction.\n   - `--wsi_dir wsis`: Path to the dir with your WSIs.\n   - `--job_dir .\u002Ftrident_processed`: Output dir for processed results.\n   - `--patch_encoder uni_v1`: Uses the `UNI` patch encoder. See below for list of supported models. \n   - `--mag 20`: Features are extracted from patches at 20x magnification.\n   - `--patch_size 256`: Patches are 256x256 pixels in size.\n - **Outputs**: \n   - Features are saved as h5 files in `.\u002Ftrident_processed\u002F20x_256px\u002Ffeatures_uni_v1`. (Shape: `(n_patches, feature_dim)`)\n\nTrident supports 24 patch encoders, loaded via a patch [`encoder_factory`](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Fblob\u002Fmain\u002Ftrident\u002Fpatch_encoder_models\u002Fload.py#L14). Models requiring specific installations will return error messages with additional instructions. Gated models on HuggingFace require access requests.\n\n| Patch Encoder         | Embedding Dim | Args                                                             | Link |\n|-----------------------|---------------:|------------------------------------------------------------------|------|\n| **UNI**               | 1024           | `--patch_encoder uni_v1 --patch_size 256 --mag 20`               | [MahmoodLab\u002FUNI](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FUNI) |\n| **UNI2-h**             | 1536           | `--patch_encoder uni_v2 --patch_size 256 --mag 20`               | [MahmoodLab\u002FUNI2-h](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FUNI2-h) |\n| **CONCH**             | 512            | `--patch_encoder conch_v1 --patch_size 512 --mag 20`             | [MahmoodLab\u002FCONCH](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FCONCH) |\n| **CONCHv1.5**         | 768            | `--patch_encoder conch_v15 --patch_size 512 --mag 20`            | [MahmoodLab\u002Fconchv1_5](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002Fconchv1_5) |\n| **Virchow**           | 2560           | `--patch_encoder virchow --patch_size 224 --mag 20`              | [paige-ai\u002FVirchow](https:\u002F\u002Fhuggingface.co\u002Fpaige-ai\u002FVirchow) |\n| **Virchow2**          | 2560           | `--patch_encoder virchow2 --patch_size 224 --mag 20`             | [paige-ai\u002FVirchow2](https:\u002F\u002Fhuggingface.co\u002Fpaige-ai\u002FVirchow2) |\n| **Phikon**            | 768            | `--patch_encoder phikon --patch_size 224 --mag 20`               | [owkin\u002Fphikon](https:\u002F\u002Fhuggingface.co\u002Fowkin\u002Fphikon) |\n| **Phikon-v2**         | 1024           | `--patch_encoder phikon_v2 --patch_size 224 --mag 20`            | [owkin\u002Fphikon-v2](https:\u002F\u002Fhuggingface.co\u002Fowkin\u002Fphikon-v2\u002F) |\n| **Prov-Gigapath**     | 1536           | `--patch_encoder gigapath --patch_size 256 --mag 20`             | [prov-gigapath](https:\u002F\u002Fhuggingface.co\u002Fprov-gigapath\u002Fprov-gigapath) |\n| **H-Optimus-0**       | 1536           | `--patch_encoder hoptimus0 --patch_size 224 --mag 20`            | [bioptimus\u002FH-optimus-0](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH-optimus-0) |\n| **H-Optimus-1**       | 1536           | `--patch_encoder hoptimus1 --patch_size 224 --mag 20`            | [bioptimus\u002FH-optimus-1](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH-optimus-1) |\n| **H0-mini**           | 768\u002F1536       | `--patch_encoder h0-mini --patch_size 224 --mag 20`              | [bioptimus\u002FH0-mini](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH0-mini) |\n| **MUSK**              | 1024           | `--patch_encoder musk --patch_size 384 --mag 20`                 | [xiangjx\u002Fmusk](https:\u002F\u002Fhuggingface.co\u002Fxiangjx\u002Fmusk) |\n| **Midnight-12k**      | 3072           | `--patch_encoder midnight12k --patch_size 224 --mag 20`          | [kaiko-ai\u002Fmidnight](https:\u002F\u002Fhuggingface.co\u002Fkaiko-ai\u002Fmidnight) |\n| **OpenMidnight**      | 1536           | `--patch_encoder openmidnight --patch_size 224 --mag 20`         | [SophontAI\u002FOpenMidnight](https:\u002F\u002Fhuggingface.co\u002FSophontAI\u002FOpenMidnight) |\n| **GPFM**              | 1024           | `--patch_encoder gpfm --patch_size 224 --mag 20`                 | [majiabo\u002FGPFM](https:\u002F\u002Fhuggingface.co\u002Fmajiabo\u002FGPFM) |\n| **GenBio-PathFM**     | 4608           | `--patch_encoder genbio-pathfm --patch_size 224 --mag 20`        | [genbio-ai\u002Fgenbio-pathfm](https:\u002F\u002Fhuggingface.co\u002Fgenbio-ai\u002Fgenbio-pathfm) |\n| **Kaiko**             | 384\u002F768\u002F1024   | `--patch_encoder {kaiko-vits8, kaiko-vits16, kaiko-vitb8, kaiko-vitb16, kaiko-vitl14} --patch_size 256 --mag 20` | [1aurent\u002Fkaikoai-models-66636c99d8e1e34bc6dcf795](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002F1aurent\u002Fkaikoai-models-66636c99d8e1e34bc6dcf795) |\n| **Lunit**             | 384            | `--patch_encoder lunit-vits8 --patch_size 224 --mag 20`          | [1aurent\u002Fvit_small_patch8_224.lunit_dino](https:\u002F\u002Fhuggingface.co\u002F1aurent\u002Fvit_small_patch8_224.lunit_dino) |\n| **Hibou**             | 1024           | `--patch_encoder hibou_l --patch_size 224 --mag 20`              | [histai\u002Fhibou-L](https:\u002F\u002Fhuggingface.co\u002Fhistai\u002Fhibou-L) |\n| **CTransPath-CHIEF**  | 768            | `--patch_encoder ctranspath --patch_size 256 --mag 10`           | — |\n| **ResNet50**          | 1024           | `--patch_encoder resnet50 --patch_size 256 --mag 20`             | — |\n\n**Step 3b: Slide Feature Extraction:** Extracts slide embeddings using a slide encoder. Will also automatically extract the right patch embeddings. \n - **Command**:\n   ```bash\n   python run_batch_of_slides.py --task feat --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --slide_encoder titan --mag 20 --patch_size 512 \n   ```\n   - `--task feat`: Specifies that you want to do feature extraction.\n   - `--wsi_dir wsis`: Path to the dir containing WSIs.\n   - `--job_dir .\u002Ftrident_processed`: Output dir for processed results.\n   - `--slide_encoder titan`: Uses the `Titan` slide encoder. See below for supported models.\n   - `--mag 20`: Features are extracted from patches at 20x magnification.\n   - `--patch_size 512`: Patches are 512x512 pixels in size.\n - **Outputs**: \n   - Features are saved as h5 files in `.\u002Ftrident_processed\u002F20x_256px\u002Fslide_features_titan`. (Shape: `(feature_dim)`)\n\nTrident supports 5 slide encoders, loaded via a slide-level [`encoder_factory`](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Fblob\u002Fmain\u002Ftrident\u002Fslide_encoder_models\u002Fload.py#L14). Models requiring specific installations will return error messages with additional instructions. Gated models on HuggingFace require access requests.\n\n| Slide Encoder | Patch Encoder | Args | Link |\n|---------------|----------------|------|------|\n| **Threads** | conch_v15 | `--slide_encoder threads --patch_size 512 --mag 20` | *(Coming Soon!)* |\n| **Titan** | conch_v15 | `--slide_encoder titan --patch_size 512 --mag 20` | [MahmoodLab\u002FTITAN](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FTITAN) |\n| **PRISM** | virchow | `--slide_encoder prism --patch_size 224 --mag 20` | [paige-ai\u002FPrism](https:\u002F\u002Fhuggingface.co\u002Fpaige-ai\u002FPrism) |\n| **CHIEF** | ctranspath | `--slide_encoder chief --patch_size 256 --mag 10` | [CHIEF](https:\u002F\u002Fgithub.com\u002Fhms-dbmi\u002FCHIEF) |\n| **GigaPath** | gigapath | `--slide_encoder gigapath --patch_size 256 --mag 20` | [prov-gigapath](https:\u002F\u002Fhuggingface.co\u002Fprov-gigapath\u002Fprov-gigapath) |\n| **Madeleine** | conch_v1 | `--slide_encoder madeleine --patch_size 256 --mag 10` | [MahmoodLab\u002Fmadeleine](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002Fmadeleine) |\n| **Feather** | conch_v15 | `--slide_encoder feather --patch_size 512 --mag 20` | [MahmoodLab\u002FFEATHER](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002Fabmil.base.conch_v15.pc108-24k) |\n\n> [!NOTE]\n> If your task includes multiple slides per patient, you can generate patient-level embeddings by: (1) processing each slide independently and taking their average slide embedding (late fusion) or (2) pooling all patches together and processing that as a single \"pseudo-slide\" (early fusion). For an implementation of both fusion strategies, please check out our sister repository [Patho-Bench](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FPatho-Bench).\n\nPlease see our [tutorials](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Ftree\u002Fmain\u002Ftutorials) for more support as well as a [detailed readme](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Fblob\u002Fmain\u002FDETAILS.md) for additional features.\n\n### 🙋 FAQ\n- **Q**: How do I extract patch embeddings from legacy patch coordinates extracted with [CLAM](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FCLAM)?\n   - **A**:\n      ```bash\n      python run_batch_of_slides.py --task feat --wsi_dir ..wsis --job_dir legacy_dir --patch_encoder uni_v1 --mag 20 --patch_size 256 --coords_dir extracted_mag20x_patch256_fp\u002F\n      ```\n- **Q**: How do I keep patches corresponding to holes in the tissue?\n   - **A**: In `run_batch_of_slides`, this behavior is default. Set `--remove_holes` to exclude patches on top of holes.\n\n- **Q**: I see weird messages when building models using timm. What is happening?\n   - **A**: Make sure `timm==0.9.16` is installed. `timm==1.X.X` creates issues with most models. \n\n- **Q**: How can I use `run_single_slide.py` and `run_batch_of_slides.py` in other repos with minimal work?\n  - **A**: Make sure `trident` is installed using `pip install -e .`. Then, both scripts are exposed and can be integrated into any Python code, e.g., as\n\n```python\nimport sys \nfrom run_single_slide import main\n\nsys.argv = [\n    \"run_single_slide\",\n    '--slide_path', \"output\u002Fwsis\u002F394140.svs\",\n    \"--job_dir\", 'output\u002F',\n    \"--mag\", \"20\",\n    \"--patch_size\", '256'\n]\n\nmain()\n```\n\n- **Q**: I am not satisfied with the tissue vs background segmentation. What can I do?\n   - **A**: Trident uses GeoJSON to store and load segmentations. This format is natively supported by [QuPath](https:\u002F\u002Fqupath.github.io\u002F). You can load the Trident segmentation into QuPath, modify it using QuPath's annotation tools, and save the updated segmentation back to GeoJSON.\n   - **A**: You can try another segmentation model by specifying `--segmenter grandqc` ([Citation necessary](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y), [Non-commercial use](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-sa\u002F4.0\u002F), [Original repository](https:\u002F\u002Fgithub.com\u002Fcpath-ukk\u002Fgrandqc)) or `--segmenter otsu`.\n\n- **Q**: I want to process a custom list of WSIs. Can I do it? Also, most of my WSIs don't have the micron per pixel (mpp) stored. Can I pass it?\n   - **A**: Yes using the `--custom_list_of_wsis` argument. Provide a list of WSI names in a CSV (with slide extension, `wsi`). Optionally, provide the mpp (field `mpp`)\n \n - **Q**: Do I need to install any additional packages to use Trident?\n   - **A**: `pip install -e .` installs core dependencies. Some optional components still require extra installs. Use profiles (`.[patch-encoders]`, `.[slide-encoders]`, `.[convert]`, `.[omezarr]` or `.[full]`) and run `trident-doctor` for preflight checks.\n\n## License and Terms of Use\n\nⓒ Mahmood Lab. This repository is released under the [CC-BY-NC-ND 4.0](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-nd\u002F4.0\u002Fdeed.en) license and may only be used for non-commercial, academic research purposes with proper attribution. Any commercial use, sale, or other monetization of this repository is prohibited and requires prior approval. By downloading any pretrained encoder, you agree to follow the model's respective license.\n\n## Acknowledgements\n\nThe project was built on top of amazing repositories such as [Timm](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-image-models\u002F), [HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdatasets\u002Fen\u002Findex), and open-source contributions from the community. We thank the authors and developers for their contribution. \n\n## Issues\n\n- The preferred mode of communication is via GitHub issues.\n- If GitHub issues are inappropriate, email guillaume.jaume@unil.ch and andrewzh@mit.edu.\n- Immediate response to minor issues may not be available.\n\n## Funding\nThis work was funded by NIH NIGMS [R35GM138216](https:\u002F\u002Freporter.nih.gov\u002Fsearch\u002FsWDcU5IfAUCabqoThQ26GQ\u002Fproject-details\u002F10029418).\n\n## How to cite\n\nIf you find our work useful in your research or if you use parts of this code, please consider citing our papers:\n\n```\n@article{zhang2025standardizing,\n  title={Accelerating Data Processing and Benchmarking of AI Models for Pathology},\n  author={Zhang, Andrew and Jaume, Guillaume and Vaidya, Anurag and Ding, Tong and Mahmood, Faisal},\n  journal={arXiv preprint arXiv:2502.06750},\n  year={2025}\n}\n\n@article{vaidya2025molecular,\n  title={Molecular-driven Foundation Model for Oncologic Pathology},\n  author={Vaidya, Anurag and Zhang, Andrew and Jaume, Guillaume and Song, Andrew H and Ding, Tong and Wagner, Sophia J and Lu, Ming Y and Doucet, Paul and Robertson, Harry and Almagro-Perez, Cristina and others},\n  journal={arXiv preprint arXiv:2501.16652},\n  year={2025}\n}\n\n```\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmahmoodlab_TRIDENT_readme_09cdd3c28f62.png\"> \n","# 🔱   三叉戟\n\n [arXiv](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2502.06750) | [博客](https:\u002F\u002Fwww.linkedin.com\u002Fpulse\u002Fannouncing-new-open-source-tools-accelerate-ai-pathology-andrew-zhang-loape\u002F?trackingId=pDkifo54SRuJ2QeGiGcXpQ%3D%3D) | [引用](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident?tab=readme-ov-file#reference)\n| [文档](https:\u002F\u002Ftrident-docs.readthedocs.io\u002Fen\u002Flatest\u002F) | [许可证](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident?tab=License-1-ov-file)\n\nTrident 是一个用于大规模全切片图像处理的工具包。\n该项目由哈佛医学院和布莱根妇女医院的 [Mahmood 实验室](https:\u002F\u002Ffaisal.ai\u002F) 开发。本研究得到了美国国立卫生研究院 NIGMS R35GM138216 的资助。\n\n> [!注意]\n> 欢迎大家贡献！请报告任何问题。您也可以通过提交拉取请求来参与贡献。\n\n### 核心功能：\n\n\u003Cimg align=\"right\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmahmoodlab_TRIDENT_readme_a6ad76eba430.jpg\" width=\"250px\" \u002F>\n\n- **组织分割**：从背景中提取组织（H&E、IHC 等）。\n- **补丁提取**：提取任意大小和放大倍数的组织补丁。\n- **补丁特征提取**：从 20 多种基础模型中提取补丁嵌入，包括 [UNI](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41591-024-02857-3)、[Virchow](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41591-024-03141-0)、[H-Optimus-0](https:\u002F\u002Fgithub.com\u002Fbioptimus\u002Freleases\u002Ftree\u002Fmain\u002Fmodels\u002Fh-optimus\u002Fv0) 等等……\n- **切片特征提取**：从 5 种以上的切片基础模型中提取切片嵌入，包括 [Threads](https:\u002F\u002Farxiv.org\u002Fabs\u002F2501.16652)（即将推出！）、[Titan](https:\u002F\u002Farxiv.org\u002Fabs\u002F2411.19666) 和 [GigaPath](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41586-024-07441-w)。\n\n### 更新：\n- 07.25：支持 [Feather](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FMIL-Lab) 模型。\n- 05.25：新增基于批次的 WSI 缓存功能，以便在有限的 SSD 空间上进行可扩展处理 + 嵌套式 WSI 搜索（`--search_nested`）。\n- 04.25：原生支持 PIL.Image 和 CuCIM（使用 `wsi = load_wsi(xxx.svs)`）。无需互联网即可进行组织分割和补丁编码。\n- 04.25：通过 `--remove_artifacts` 和 `--remove_penmarks` 从组织分割结果中去除伪影和笔迹。\n- 02.25：新增从 `czi`、`png` 等格式到 `tiff` 的图像转换器。\n- 02.25：支持 GrandQC（[需要引用](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y)，[非商业用途](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-sa\u002F4.0\u002F)，[原始仓库](https:\u002F\u002Fgithub.com\u002Fcpath-ukk\u002Fgrandqc)）的组织与背景分割。\n- 02.25：支持 [Madeleine](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FMADELEINE\u002Ftree\u002Fmain)、[Hibou](https:\u002F\u002Fgithub.com\u002FHistAI\u002Fhibou)、[Lunit](https:\u002F\u002Fhuggingface.co\u002F1aurent\u002Fvit_small_patch8_224.lunit_dino)、[Kaiko](https:\u002F\u002Fhuggingface.co\u002Fhistai\u002Fhibou-L) 和 [H-Optimus-1](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH-optimus-1) 模型。\n\n> [!注意]\n> GrandQC 已根据 CC BY-NC-SA 4.0 许可证集成到 Trident 中。如果您使用 GrandQC，请引用其 [原始论文](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y)。\n\n### 🔨 1. **安装**：\n- 创建环境（Python 3.10 或 3.11）：`conda create -n \"trident\" python=3.10`，并激活它：`conda activate trident`。\n- 克隆：`git clone https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident.git && cd trident`。\n- 本地安装：`pip install -e .`。\n  - 这将安装共享的模型栈（`transformers`、`timm`、`safetensors` 等）。\n\n可选安装配置：\n- `pip install -e \".[patch-encoders]\"` 用于 CONCH\u002FMUSK\u002FCTransPath 相关的附加功能。\n- `pip install -e \".[slide-encoders]\"` 用于 PRISM\u002FGigaPath\u002FMadeleine 相关的附加功能。\n- `pip install -e \".[omezarr]\"` 用于支持 OME Zarr WSI 阅读器。\n- `pip install -e \".[convert]\"` 用于切片转换相关的依赖项。\n- `pip install -e \".[full]\"` 安装所有可通过 pip 安装的可选依赖项。\n\n在启动任务前运行检查：\n- `trident-doctor --profile base`\n- `trident-doctor --profile patch-encoders --check-gated`\n- `trident-doctor --profile slide-encoders`\n- `trident-doctor --profile convert`\n- `trident-doctor --profile full --check-gated`\n\n> [!注意]\n> 一些模型仍需手动设置（例如，在 `trident\u002Fslide_encoder_models\u002Flocal_ckpts.json` 中指定本地 CHIEF 仓库路径），或需要 HuggingFace 的访问权限批准。\n\n### 🔨 2. **运行 Trident**：\n\nCLI 选项（全部支持）：\n- `python run_batch_of_slides.py ...`（现有命令）\n- `python run_single_slide.py ...`（现有命令）\n- `trident batch ...`、`trident single ...`、`trident convert ...` 和 `trident doctor ...`（封装 CLI）\n\n**已经熟悉 WSI 处理？** 可以从一个包含 WSI 的目录中执行分割、补丁提取和 UNI 特征提取：\n\n```\npython run_batch_of_slides.py --task all --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n等效的封装 CLI：\n```\ntrident batch -- --task all --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n**想谨慎一点吗？**\n\n运行以下命令对 **单张** 切片执行所有处理步骤：\n```\npython run_single_slide.py --slide_path .\u002Fwsis\u002Fxxxx.svs --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n等效的封装 CLI：\n```\ntrident single -- --slide_path .\u002Fwsis\u002Fxxxx.svs --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n将图像\u002FWSI 转换为金字塔 TIFF：\n```\ntrident convert --input_dir .\u002Fwsis --mpp_csv .\u002Fwsis\u002Fto_process.csv --job_dir .\u002Fpyramidal_tiff --downscale_by 1 --num_workers 1\n```\n\n`--mpp_csv` 是必需的，必须包含 `wsi,mpp` 列。只有 CSV 中列出的文件会被转换。如果检测到切片中嵌入了 MPP 元数据，Trident 会将其与 CSV 中的值进行比较，并记录不匹配的情况。\n\n**或者按照逐步指南操作：**\n\n**步骤 1：组织分割**：从一组 WSI 中分割出组织与背景\n - **命令**：\n   ```bash\n   python run_batch_of_slides.py --task seg --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --gpu 0 --segmenter hest\n   ```\n   - `--task seg`：指定要进行组织分割。\n   - `--wsi_dir .\u002Fwsis`：您的 WSI 所在目录的路径。\n   - `--job_dir .\u002Ftrident_processed`：处理结果的输出目录。\n   - `--gpu 0`：使用索引为 0 的 GPU。\n  - `--segmenter`：分割模型。默认是 `hest`。可以使用 `grandqc`（[需要引用](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y)，[非商业用途](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-sa\u002F4.0\u002F)，[原始仓库](https:\u002F\u002Fgithub.com\u002Fcpath-ukk\u002Fgrandqc)）进行快速的 H&E 分割，或使用 `otsu` 作为经典的纯图像处理回退方案。添加选项 `--remove_artifacts` 可进一步清除伪影。\n - **输出**：\n   - 在 `.\u002Ftrident_processed\u002Fthumbnails` 中生成 WSI 缩略图。\n   - 在 `.\u002Ftrident_processed\u002Fcontours` 中生成带有组织轮廓的 WSI 缩略图。\n   - 在 `.\u002Ftrident_processed\u002Fcontours_geojson` 中生成包含组织轮廓的 GeoJSON 文件。如有必要，这些文件可以在 [QuPath](https:\u002F\u002Fqupath.github.io\u002F) 中打开进行编辑或质量控制。\n\n**步骤 2：组织切片补丁提取**：在特定放大倍数下，从分割后的组织区域中提取补丁。\n - **命令**：\n   ```bash\n   python run_batch_of_slides.py --task coords --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --mag 20 --patch_size 256 --overlap 0\n   ```\n   - `--task coords`：指定执行补丁提取操作。\n   - `--wsi_dir wsis`：WSI 文件所在的目录路径。\n   - `--job_dir .\u002Ftrident_processed`：处理结果的输出目录。\n   - `--mag 20`：以 20 倍放大倍数提取补丁。\n   - `--patch_size 256`：每个补丁的尺寸为 256×256 像素。\n   - `--overlap 0`：补丁之间无重叠（**始终**使用像素数表示，例如，对于 256×256 的补丁，若需 50% 重叠，则应设置为 `--overlap 128`）。\n - **输出**：\n   - 补丁坐标以 h5 文件形式保存在 `.\u002Ftrident_processed\u002F20x_256px\u002Fpatches` 目录中。\n   - 带有补丁边界的 WSI 缩略图保存在 `.\u002Ftrident_processed\u002F20x_256px\u002Fvisualization` 目录中。\n\n **步骤 3a：补丁特征提取**：使用指定的编码器从组织补丁中提取特征。\n - **命令**：\n   ```bash\n   python run_batch_of_slides.py --task feat --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256 \n   ```\n   - `--task feat`：指定执行特征提取操作。\n   - `--wsi_dir wsis`：WSI 文件所在的目录路径。\n   - `--job_dir .\u002Ftrident_processed`：处理结果的输出目录。\n   - `--patch_encoder uni_v1`：使用 UNI 补丁编码器。支持的模型列表见下文。\n   - `--mag 20`：在 20 倍放大倍数下从补丁中提取特征。\n   - `--patch_size 256`：补丁尺寸为 256×256 像素。\n - **输出**：\n   - 特征以 h5 文件形式保存在 `.\u002Ftrident_processed\u002F20x_256px\u002Ffeatures_uni_v1` 目录中。（形状：`(n_patches, feature_dim)`）\n\nTrident 支持 24 种补丁编码器，可通过补丁 [`encoder_factory`](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Fblob\u002Fmain\u002Ftrident\u002Fpatch_encoder_models\u002Fload.py#L14) 加载。需要特定安装的模型会返回包含额外说明的错误信息。HuggingFace 上的门控模型需要提交访问申请。\n\n| 补丁编码器         | 嵌入维度 | 参数                                                             | 链接 |\n|-----------------------|---------------:|------------------------------------------------------------------|------|\n| **UNI**               | 1024           | `--patch_encoder uni_v1 --patch_size 256 --mag 20`               | [MahmoodLab\u002FUNI](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FUNI) |\n| **UNI2-h**             | 1536           | `--patch_encoder uni_v2 --patch_size 256 --mag 20`               | [MahmoodLab\u002FUNI2-h](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FUNI2-h) |\n| **CONCH**             | 512            | `--patch_encoder conch_v1 --patch_size 512 --mag 20`             | [MahmoodLab\u002FCONCH](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FCONCH) |\n| **CONCHv1.5**         | 768            | `--patch_encoder conch_v15 --patch_size 512 --mag 20`            | [MahmoodLab\u002Fconchv1_5](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002Fconchv1_5) |\n| **Virchow**           | 2560           | `--patch_encoder virchow --patch_size 224 --mag 20`              | [paige-ai\u002FVirchow](https:\u002F\u002Fhuggingface.co\u002Fpaige-ai\u002FVirchow) |\n| **Virchow2**          | 2560           | `--patch_encoder virchow2 --patch_size 224 --mag 20`             | [paige-ai\u002FVirchow2](https:\u002F\u002Fhuggingface.co\u002Fpaige-ai\u002FVirchow2) |\n| **Phikon**            | 768            | `--patch_encoder phikon --patch_size 224 --mag 20`               | [owkin\u002Fphikon](https:\u002F\u002Fhuggingface.co\u002Fowkin\u002Fphikon) |\n| **Phikon-v2**         | 1024           | `--patch_encoder phikon_v2 --patch_size 224 --mag 20`            | [owkin\u002Fphikon-v2](https:\u002F\u002Fhuggingface.co\u002Fowkin\u002Fphikon-v2\u002F) |\n| **Prov-Gigapath**     | 1536           | `--patch_encoder gigapath --patch_size 256 --mag 20`             | [prov-gigapath](https:\u002F\u002Fhuggingface.co\u002Fprov-gigapath\u002Fprov-gigapath) |\n| **H-Optimus-0**       | 1536           | `--patch_encoder hoptimus0 --patch_size 224 --mag 20`            | [bioptimus\u002FH-optimus-0](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH-optimus-0) |\n| **H-Optimus-1**       | 1536           | `--patch_encoder hoptimus1 --patch_size 224 --mag 20`            | [bioptimus\u002FH-optimus-1](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH-optimus-1) |\n| **H0-mini**           | 768\u002F1536       | `--patch_encoder h0-mini --patch_size 224 --mag 20`              | [bioptimus\u002FH0-mini](https:\u002F\u002Fhuggingface.co\u002Fbioptimus\u002FH0-mini) |\n| **MUSK**              | 1024           | `--patch_encoder musk --patch_size 384 --mag 20`                 | [xiangjx\u002Fmusk](https:\u002F\u002Fhuggingface.co\u002Fxiangjx\u002Fmusk) |\n| **Midnight-12k**      | 3072           | `--patch_encoder midnight12k --patch_size 224 --mag 20`          | [kaiko-ai\u002Fmidnight](https:\u002F\u002Fhuggingface.co\u002Fkaiko-ai\u002Fmidnight) |\n| **OpenMidnight**      | 1536           | `--patch_encoder openmidnight --patch_size 224 --mag 20`         | [SophontAI\u002FOpenMidnight](https:\u002F\u002Fhuggingface.co\u002FSophontAI\u002FOpenMidnight) |\n| **GPFM**              | 1024           | `--patch_encoder gpfm --patch_size 224 --mag 20`                 | [majiabo\u002FGPFM](https:\u002F\u002Fhuggingface.co\u002Fmajiabo\u002FGPFM) |\n| **GenBio-PathFM**     | 4608           | `--patch_encoder genbio-pathfm --patch_size 224 --mag 20`        | [genbio-ai\u002Fgenbio-pathfm](https:\u002F\u002Fhuggingface.co\u002Fgenbio-ai\u002Fgenbio-pathfm) |\n| **Kaiko**             | 384\u002F768\u002F1024   | `--patch_encoder {kaiko-vits8, kaiko-vits16, kaiko-vitb8, kaiko-vitb16, kaiko-vitl14} --patch_size 256 --mag 20` | [1aurent\u002Fkaikoai-models-66636c99d8e1e34bc6dcf795](https:\u002F\u002Fhuggingface.co\u002Fcollections\u002F1aurent\u002Fkaikoai-models-66636c99d8e1e34bc6dcf795) |\n| **Lunit**             | 384            | `--patch_encoder lunit-vits8 --patch_size 224 --mag 20`          | [1aurent\u002Fvit_small_patch8_224.lunit_dino](https:\u002F\u002Fhuggingface.co\u002F1aurent\u002Fvit_small_patch8_224.lunit_dino) |\n| **Hibou**             | 1024           | `--patch_encoder hibou_l --patch_size 224 --mag 20`              | [histai\u002Fhibou-L](https:\u002F\u002Fhuggingface.co\u002Fhistai\u002Fhibou-L) |\n| **CTransPath-CHIEF**  | 768            | `--patch_encoder ctranspath --patch_size 256 --mag 10`           | — |\n| **ResNet50**          | 1024           | `--patch_encoder resnet50 --patch_size 256 --mag 20`             | — |\n\n**步骤 3b：幻灯片特征提取**：使用幻灯片编码器提取幻灯片嵌入。同时也会自动提取正确的补丁嵌入。\n - **命令**：\n   ```bash\n   python run_batch_of_slides.py --task feat --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --slide_encoder titan --mag 20 --patch_size 512 \n   ```\n   - `--task feat`：指定要进行特征提取。\n   - `--wsi_dir wsis`：包含WSI的目录路径。\n   - `--job_dir .\u002Ftrident_processed`：处理结果的输出目录。\n   - `--slide_encoder titan`：使用`Titan`幻灯片编码器。支持的模型见下文。\n   - `--mag 20`：在20倍放大倍率下从补丁中提取特征。\n   - `--patch_size 512`：补丁大小为512×512像素。\n - **输出**：\n   - 特征以h5文件格式保存在`.\u002Ftrident_processed\u002F20x_256px\u002Fslide_features_titan`中。（形状：`(feature_dim)`）\n\nTrident支持5种幻灯片编码器，通过幻灯片级别的[`encoder_factory`](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Fblob\u002Fmain\u002Ftrident\u002Fslide_encoder_models\u002Fload.py#L14)加载。需要特定安装的模型会返回带有额外说明的错误信息。HuggingFace上的门控模型需要申请访问权限。\n\n| 演示板编码器 | 补丁编码器 | 参数 | 链接 |\n|---------------|----------------|------|------|\n| **Threads** | conch_v15 | `--slide_encoder threads --patch_size 512 --mag 20` | *(即将推出！)* |\n| **Titan** | conch_v15 | `--slide_encoder titan --patch_size 512 --mag 20` | [MahmoodLab\u002FTITAN](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002FTITAN) |\n| **PRISM** | virchow | `--slide_encoder prism --patch_size 224 --mag 20` | [paige-ai\u002FPrism](https:\u002F\u002Fhuggingface.co\u002Fpaige-ai\u002FPrism) |\n| **CHIEF** | ctranspath | `--slide_encoder chief --patch_size 256 --mag 10` | [CHIEF](https:\u002F\u002Fgithub.com\u002Fhms-dbmi\u002FCHIEF) |\n| **GigaPath** | gigapath | `--slide_encoder gigapath --patch_size 256 --mag 20` | [prov-gigapath](https:\u002F\u002Fhuggingface.co\u002Fprov-gigapath\u002Fprov-gigapath) |\n| **Madeleine** | conch_v1 | `--slide_encoder madeleine --patch_size 256 --mag 10` | [MahmoodLab\u002Fmadeleine](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002Fmadeleine) |\n| **Feather** | conch_v15 | `--slide_encoder feather --patch_size 512 --mag 20` | [MahmoodLab\u002FFEATHER](https:\u002F\u002Fhuggingface.co\u002FMahmoodLab\u002Fabmil.base.conch_v15.pc108-24k) |\n\n> [!注意]\n> 如果您的任务涉及每位患者有多张幻灯片，您可以通过以下方式生成患者级别的嵌入：(1) 独立处理每张幻灯片并取其平均幻灯片嵌入（晚期融合），或 (2) 将所有补丁合并在一起，将其作为单个“伪幻灯片”进行处理（早期融合）。有关这两种融合策略的实现，请查看我们的姊妹仓库[Patho-Bench](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FPatho-Bench)。\n\n请参阅我们的[教程](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Ftree\u002Fmain\u002Ftutorials)以获取更多支持，以及[详细自述文件](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident\u002Fblob\u002Fmain\u002FDETAILS.md)以了解其他功能。\n\n\n\n### 🙋 常见问题解答\n- **问**：如何从使用[CLAM](https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FCLAM)提取的旧版补丁坐标中提取补丁嵌入？\n   - **答**：\n      ```bash\n      python run_batch_of_slides.py --task feat --wsi_dir ..wsis --job_dir legacy_dir --patch_encoder uni_v1 --mag 20 --patch_size 256 --coords_dir extracted_mag20x_patch256_fp\u002F\n      ```\n- **问**：如何保留对应于组织中孔洞的补丁？\n   - **答**：在`run_batch_of_slides`中，此行为是默认设置。将`--remove_holes`设置为排除位于孔洞上的补丁。\n\n- **问**：使用timm构建模型时，我看到一些奇怪的消息。这是怎么回事？\n   - **答**：请确保已安装`timm==0.9.16`。`timm==1.X.X`会导致大多数模型出现问题。\n\n- **问**：如何在其他仓库中以最少的工作量使用`run_single_slide.py`和`run_batch_of_slides.py`？\n  - **答**：确保已使用`pip install -e .`安装了`trident`。然后，这两个脚本将被公开，并可集成到任何Python代码中，例如：\n\n```python\nimport sys \nfrom run_single_slide import main\n\nsys.argv = [\n    \"run_single_slide\",\n    '--slide_path', \"output\u002Fwsis\u002F394140.svs\",\n    \"--job_dir\", 'output\u002F',\n    \"--mag\", \"20\",\n    \"--patch_size\", '256'\n]\n\nmain()\n```\n\n- **问**：我对组织与背景的分割效果不满意。该怎么办？\n   - **答**：Trident使用GeoJSON来存储和加载分割结果。这种格式由[QuPath](https:\u002F\u002Fqupath.github.io\u002F)原生支持。您可以将Trident的分割结果导入QuPath，使用QuPath的标注工具进行修改，然后将更新后的分割结果保存回GeoJSON。\n   - **答**：您也可以尝试使用其他分割模型，通过指定`--segmenter grandqc`（需注明引用来源[《自然通讯》](https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y)，仅限非商业用途[知识共享署名-非商业性-相同方式共享4.0国际许可协议](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-sa\u002F4.0\u002F)，原始仓库地址为[GitHub上的cpath-ukk\u002Fgrandqc](https:\u002F\u002Fgithub.com\u002Fcpath-ukk\u002Fgrandqc))或`--segmenter otsu`。\n\n- **问**：我想处理一个自定义的WSI列表。可以吗？另外，我的大部分WSI都没有存储每像素微米数（mpp）。我可以传递这个值吗？\n   - **答**：可以，使用`--custom_list_of_wsis`参数。提供一个包含WSI名称的CSV文件（带幻灯片扩展名，`wsi`）。可选地，提供mpp值（字段`mpp`）。\n\n - **问**：使用Trident是否需要安装任何额外的软件包？\n   - **答**：运行`pip install -e .`会安装核心依赖项。但某些可选组件仍需额外安装。请使用配置文件（`.[patch-encoders]`、`.[slide-encoders]`、`.[convert]`、`.[omezarr]`或`.[full]`）并运行`trident-doctor`进行飞行前检查。\n\n## 许可证与使用条款\n\nⓒ Mahmood Lab。本仓库根据[CC-BY-NC-ND 4.0](https:\u002F\u002Fcreativecommons.org\u002Flicenses\u002Fby-nc-nd\u002F4.0\u002Fdeed.en)许可证发布，仅可用于非商业性的学术研究目的，并需正确注明出处。任何商业用途、销售或其他盈利行为均被禁止，且须事先获得批准。下载任何预训练编码器即表示您同意遵守该模型各自的许可证。\n\n## 致谢\n\n该项目建立在许多优秀的开源项目之上，如[Timm](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fpytorch-image-models\u002F)、[HuggingFace](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Fdatasets\u002Fen\u002Findex)以及社区的开源贡献。我们感谢各位作者和开发人员的贡献。\n\n## 问题\n- 推荐的沟通方式是通过GitHub问题。\n- 如果GitHub问题不合适，请发送邮件至guillaume.jaume@unil.ch和andrewzh@mit.edu。\n- 对于小问题，可能无法立即得到回复。\n\n## 资助\n本工作由美国国立卫生研究院NIGMS资助，项目编号为[R35GM138216](https:\u002F\u002Freporter.nih.gov\u002Fsearch\u002FsWDcU5IfAUCabqoThQ26GQ\u002Fproject-details\u002F10029418)。\n\n## 如何引用\n\n如果您在研究中认为我们的工作有所帮助，或者使用了本代码的部分内容，请考虑引用我们的论文：\n\n```\n@article{zhang2025standardizing,\n  title={加速病理学人工智能模型的数据处理与基准测试},\n  author={Zhang, Andrew 和 Jaume, Guillaume 和 Vaidya, Anurag 和 Ding, Tong 和 Mahmood, Faisal},\n  journal={arXiv 预印本 arXiv:2502.06750},\n  year={2025}\n}\n\n@article{vaidya2025molecular,\n  title={面向肿瘤病理学的分子驱动型基础模型},\n  author={Vaidya, Anurag 和 Zhang, Andrew 和 Jaume, Guillaume 和 Song, Andrew H 和 Ding, Tong 和 Wagner, Sophia J 和 Lu, Ming Y 和 Doucet, Paul 和 Robertson, Harry 和 Almagro-Perez, Cristina 等},\n  journal={arXiv 预印本 arXiv:2501.16652},\n  year={2025}\n}\n\n```\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmahmoodlab_TRIDENT_readme_09cdd3c28f62.png\">","# TRIDENT 快速上手指南\n\nTRIDENT 是由哈佛医学院 Mahmood 实验室开发的大规模全切片图像（WSI）处理工具包，支持组织分割、图块提取及基于多种基础模型的特征提取。\n\n## 1. 环境准备\n\n- **操作系统**：Linux 推荐（Windows\u002FmacOS 需额外配置依赖）\n- **Python 版本**：3.10 或 3.11\n- **硬件要求**：\n  - 建议配备 NVIDIA GPU（用于加速分割和特征提取）\n  - 充足的磁盘空间用于存储 WSI 文件及处理结果\n- **前置依赖**：\n  - Conda（推荐用于环境管理）\n  - Git\n\n> 💡 **国内加速建议**：建议使用清华或中科大镜像源加速 Conda 和 Pip 包的下载。\n> - Conda 配置：`conda config --add channels https:\u002F\u002Fmirrors.tuna.tsinghua.edu.cn\u002Fanaconda\u002Fpkgs\u002Fmain\u002F`\n> - Pip 配置：`pip config set global.index-url https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`\n\n## 2. 安装步骤\n\n### 2.1 创建并激活虚拟环境\n```bash\nconda create -n \"trident\" python=3.10\nconda activate trident\n```\n\n### 2.2 克隆代码仓库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002Ftrident.git && cd trident\n```\n\n### 2.3 安装核心依赖\n安装基础版本（包含共享模型栈）：\n```bash\npip install -e .\n```\n\n如需使用特定功能，可选择以下可选安装配置：\n- **图块编码器**（如 CONCH, MUSK, CTransPath）：\n  ```bash\n  pip install -e \".[patch-encoders]\"\n  ```\n- **切片编码器**（如 PRISM, GigaPath, Madeleine）：\n  ```bash\n  pip install -e \".[slide-encoders]\"\n  ```\n- **OME Zarr 格式支持**：\n  ```bash\n  pip install -e \".[omezarr]\"\n  ```\n- **图像格式转换支持**：\n  ```bash\n  pip install -e \".[convert]\"\n  ```\n- **安装所有可选依赖**：\n  ```bash\n  pip install -e \".[full]\"\n  ```\n\n### 2.4 运行环境检查\n在开始任务前，建议运行诊断命令确保环境配置正确：\n```bash\ntrident-doctor --profile base\n# 若安装了额外组件，可分别检查\ntrident-doctor --profile patch-encoders --check-gated\ntrident-doctor --profile slide-encoders\n```\n\n> ⚠️ **注意**：部分模型（如 HuggingFace 上的受限模型）需要手动申请访问权限或在本地配置路径。\n\n## 3. 基本使用\n\nTRIDENT 提供命令行接口（CLI），支持单张幻灯片处理或批量处理。\n\n### 3.1 一键全流程处理（推荐）\n对目录下的所有 WSI 执行组织分割、图块提取及 UNI 模型特征提取：\n\n```bash\npython run_batch_of_slides.py --task all --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n或使用封装后的 CLI 命令：\n```bash\ntrident batch -- --task all --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n**参数说明**：\n- `--wsi_dir`: 输入 WSI 文件目录\n- `--job_dir`: 输出结果目录\n- `--patch_encoder`: 使用的预训练模型（如 `uni_v1`）\n- `--mag`: 提取倍率（如 20x）\n- `--patch_size`: 图块尺寸（像素）\n\n### 3.2 单张幻灯片测试\n初次使用建议先对单张幻灯片进行测试：\n\n```bash\npython run_single_slide.py --slide_path .\u002Fwsis\u002Fxxxx.svs --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256\n```\n\n### 3.3 分步执行（高级用法）\n\n若需单独控制流程，可按以下步骤操作：\n\n**步骤 1：组织分割**\n```bash\npython run_batch_of_slides.py --task seg --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --gpu 0 --segmenter hest\n```\n*输出：缩略图、组织轮廓 GeoJSON 文件（可用 QuPath 查看）。*\n\n**步骤 2：图块坐标提取**\n```bash\npython run_batch_of_slides.py --task coords --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --mag 20 --patch_size 256 --overlap 0\n```\n*输出：包含图块坐标的 h5 文件及可视化结果。*\n\n**步骤 3：特征提取**\n```bash\npython run_batch_of_slides.py --task feat --wsi_dir .\u002Fwsis --job_dir .\u002Ftrident_processed --patch_encoder uni_v1 --mag 20 --patch_size 256 \n```\n*输出：特征向量 h5 文件，形状为 `(n_patches, feature_dim)`。*\n\n### 3.4 图像格式转换\n将 CZI、PNG 等格式转换为金字塔 TIFF：\n```bash\ntrident convert --input_dir .\u002Fwsis --mpp_csv .\u002Fwsis\u002Fto_process.csv --job_dir .\u002Fpyramidal_tiff --downscale_by 1 --num_workers 1\n```\n*注意：`--mpp_csv` 文件必须包含 `wsi,mpp` 两列。*","某三甲医院病理科与 AI 实验室合作，试图构建一个覆盖万例全切片图像（WSI）的癌症预后预测模型，需从海量原始扫描数据中提取高质量特征。\n\n### 没有 TRIDENT 时\n- **格式混乱难统一**：不同扫描仪生成的 `.svs`、`.czi` 等私有格式互不兼容，研究人员需编写繁琐脚本手动转换，耗时且易出错。\n- **背景噪声干扰大**：切片中大量的空白背景和笔迹标记未被清除，直接导致后续模型训练收敛困难，准确率大幅波动。\n- **特征提取门槛高**：想要利用 UNI、Virchow 等前沿基础模型提取特征，需分别配置多个独立环境，依赖冲突频发，部署周期长达数周。\n- **内存溢出频繁**：处理超大尺寸切片时，传统方法常因显存或内存不足而中断，难以实现规模化批量处理。\n\n### 使用 TRIDENT 后\n- **一键格式标准化**：利用内置转换器将各类私有格式统一转为标准 `.tiff`，并支持嵌套目录自动搜索，数据预处理效率提升十倍。\n- **智能组织分割**：调用集成的 GrandQC 或原生分割算法，自动去除背景、伪影及笔迹，仅保留有效组织区域，显著净化输入数据。\n- **多模型无缝集成**：通过简单命令即可调用 20+ 种预训练基础模型（如 UNI、GigaPath）进行斑块或整图特征提取，无需反复配置环境。\n- **大规模缓存机制**：新增的批量 WSI 缓存功能优化了有限 SSD 空间下的读写策略，稳定支撑万起级切片的连续处理任务。\n\nTRIDENT 将原本碎片化、高门槛的病理图像处理流程整合为一站式解决方案，让研究人员能专注于算法创新而非数据清洗。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmahmoodlab_TRIDENT_e6f90380.png","mahmoodlab","Mahmood Lab @ Harvard\u002FMGB","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmahmoodlab_ca9d31b7.png","AI for Pathology Image Analysis Lab @ HMS \u002F BWH",null,"fmahmood@fas.harvard.edu","AI4Pathology","www.mahmoodlab.org","https:\u002F\u002Fgithub.com\u002Fmahmoodlab",[82,86],{"name":83,"color":84,"percentage":85},"Python","#3572A5",95.9,{"name":87,"color":88,"percentage":89},"Jupyter Notebook","#DA5B0B",4.1,522,113,"2026-04-08T09:24:39","NOASSERTION","未说明","可选但推荐（支持 --gpu 参数指定索引），具体型号和显存未说明，取决于所选基础模型（如 UNI, Virchow 等）的需求；部分模型可能需要 HuggingFace 访问权限","未说明（但在有限 SSD 空间下支持批量 WSI 缓存优化）",{"notes":98,"python":99,"dependencies":100},"建议使用 conda 创建环境。安装时可根据需求选择不同配置（如仅补丁编码器、全量安装等）。部分模型（如 GrandQC）仅限非商业用途且需引用原文。某些模型需要手动配置本地路径或申请 HuggingFace  gated 访问权限。支持多种 WSI 格式转换及嵌套目录搜索。","3.10 或 3.11",[101,102,103,104,105],"transformers","timm","safetensors","PIL (Pillow)","CuCIM (可选)",[14,15],[108,109,110,111,112,113],"deep-learning","foundation-model","histology","pathology","whole-slide-image","foundation-models-for-pathology","2026-03-27T02:49:30.150509","2026-04-09T01:25:09.811141",[117,122,127,132,137,141],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},25442,"如何处理因幻灯片编码问题导致的分割掩膜偏移（Shifted segmentation masks）？","这通常是因为幻灯片的编码方式导致 OpenSlide 无法正确读取或获取缩略图。解决方案是：使用 QuPath 打开该幻灯片，将其重新保存为 OME.TIFF 格式，然后重新运行 TRIDENT 进行处理。","https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fissues\u002F121",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},25443,"在分割大型 .svs 文件时进程被杀死（Killed）怎么办？","这是由于内存不足导致的。建议使用 `pyvips` 的流式功能来处理大文件，避免将整个图像加载到内存中。核心实现方式是使用 `pyvips.Image.new_from_file(..., access=\"sequential\")`。这种方法可以有效处理之前因过大而失败的 .svs 等 WSI 文件转换任务。","https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fissues\u002F157",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},25444,"由于网络限制无法连接 HuggingFace，如何在 TRIDENT 中使用本地下载的 TITAN 模型？","需要手动配置本地路径：\n1. 下载 CONCHv1.5 模型，并在 `trident\u002Fpatch_encoder_models\u002Flocal_ckpts.json` 第 21 行设置其路径。\n2. 下载 TITAN 模型的所有文件（.bin, config.json 等），修改 `trident\u002Fslide_encoder_models\u002Fload.py` 第 428 行，提供包含这些文件的本地目录路径。\n3. 此外，需将 `conch_tokenizer.py` 和 `conch_v1_5.py` 复制到 HuggingFace 缓存模块目录：\n   `mkdir -p \u002Froot\u002F.cache\u002Fhuggingface\u002Fmodules\u002Ftransformers_modules`\n   `cp .\u002FModel\u002FTITAN\u002Fconch_tokenizer.py \u002Froot\u002F.cache\u002Fhuggingface\u002Fmodules\u002Ftransformers_modules\u002F`\n   `cp .\u002FModel\u002FTITAN\u002Fconch_v1_5.py \u002Froot\u002F.cache\u002Fhuggingface\u002Fmodules\u002Ftransformers_modules\u002F`","https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fissues\u002F96",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},25445,"从 PNG 文件提取补丁特征时遇到 \"Decompressed data too large\" 错误如何解决？","请拉取最新版本的 TRIDENT (v0.1.0 或更高)，该版本已原生支持 PNG 文件。运行命令示例如下：\n`python run_batch_of_slides.py --task all --wsi_dir .\u002Fwsis\u002F --job_dir .\u002Ftrident_processed6 --patch_encoder uni_v1 --mag 20 --patch_size 256 --segmenter grandqc --custom_list_of_wsis to_process.csv`\n其中 `to_process.csv` 需定义图像的 MPP（例如 0.25um\u002Fpx 对应 40x），格式为：\n```\nwsi,mpp\nTCGA-AJ-A8CV-01Z-00-DX1_1.png,0.25\n```","https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fissues\u002F57",{"id":138,"question_zh":139,"answer_zh":140,"source_url":131},25446,"TRIDENT 处理结果中 contours 文件夹为空或 geojson 坐标异常的原因是什么？","这通常是因为输入列表文件（如 `--custom_list_of_wsis` 指定的 CSV）中的 MPP（每像素微米数）值设置错误，导致 TRIDENT 无法在正确的目录下输出结果或计算错误的坐标。请检查并修正 CSV 文件中的 MPP 数值以匹配实际图像的分辨率。",{"id":142,"question_zh":143,"answer_zh":144,"source_url":121},25447,"如何指定不同的分割器（segmenter）进行组织分割？","在运行脚本时通过 `--segmenter` 参数指定。例如，使用 HEST 分割器：\n`python run_batch_of_slides.py --task seg --wsi_dir \u003CWSI_DIR> --job_dir \u003CJOB_DIR> --gpu 0 --segmenter hest`\n或者使用 GrandQC 分割器：\n`python run_batch_of_slides.py --task seg --wsi_dir \u003CWSI_DIR> --job_dir \u003CJOB_DIR> --gpu 0 --segmenter grandqc`\n如果某种分割器对特定编码的幻灯片效果不佳，可尝试切换另一种分割器。",[146,151,156,161,166,171,176,181,186,191,196,201,206],{"id":147,"version":148,"summary_zh":149,"released_at":150},162763,"v0.2.5","## 变更内容\n* 更新 README，移除“Details”链接，由 @guillaumejaume 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F190 中完成\n* 功能：支持 h0-mini、openmidnight 和 gpfm，由 @guillaumejaume 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F191 中完成\n* 添加 GrandQC 的引用和许可证声明，由 @Superzlw 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F192 中完成\n* 添加 GenBio-PathFM 补丁编码器（ViT-Giant，4608 维，JEDI 训练）#196，由 @guillaumejaume 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F197 中完成\n* Gja\u002F速度\u002F补丁处理，由 @guillaumejaume 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F199 中完成\n* 新增 OME ZARR 图像读取器，由 @guillaumejaume 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F200 中完成\n* 功能：在补丁化坐标时添加导出补丁的选项，由 @guillaumejaume 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F201 中完成\n\n## 新贡献者\n* @Superzlw 在 https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fpull\u002F192 中完成了首次贡献\n\n**完整变更日志**：https:\u002F\u002Fgithub.com\u002Fmahmoodlab\u002FTRIDENT\u002Fcompare\u002Fv0.2.4...v0.2.5","2026-04-07T16:45:17",{"id":152,"version":153,"summary_zh":154,"released_at":155},162764,"v0.2.4","- 修复了复合扩展名文件的处理逻辑（如 .ome.tif \u002F .ome.tiff），改用 splitext() 方法，并将其应用到 WSI、Processor 和 Converter 模块中，以确保在派生伪影文件名时的一致性。\n- 增加了健壮的 WSI 生命周期管理功能，支持上下文管理器（enter\u002Fexit），并更新了 run_single_slide.py、Processor（使用 ExitStack）及相关测试中的用法。\n- 新增了一个仅用于图像处理的第三种分割算法——Otsu，实现于 trident\u002Fsegmentation_models\u002Fotsu.py 中，并通过 segmentation_model_factory 工厂函数、CLI 选项及模块导出进行集成。\n- 将 Otsu 分割的默认放大倍数设置为 1.25x，并优化了其运行路径，减少了内存分配开销，同时为 CLI 流程中的 Otsu 算法启用了 CPU 执行路径。\n- 为 Otsu 添加了单元测试（tests\u002Ftest_otsu_segmenter.py），并补充了先前的生命周期和文件扩展名相关测试（test_wsi_core_behaviors.py、test_processor_lifecycle.py）。\n- 改进了 pyproject.toml 文件中的依赖管理和安装体验，增加了对 scikit-image 的依赖以支持 Otsu 算法；同时扩充了 README.md 和 DETAILS.md 中的文档内容。\n- 扩展了 trident-doctor 工具的功能，包括转换配置检查和运行时库检查，并改进了输出格式，新增 FAIL\u002FWARN\u002FPASS 标识、摘要信息以及 JSON 输出模式。\n- 在保留旧有入口点的同时，统一了 CLI 包装层的行为（trident batch\u002Fsingle\u002Fconvert\u002Fdoctor），确保命令行接口的一致性。","2026-03-05T11:11:32",{"id":157,"version":158,"summary_zh":159,"released_at":160},162765,"v0.2.3","\r\n- 修复 bug：在进行重叠拼接时，第一个补丁不会用于重叠部分。现已通过修改 _colrow_to_xy 函数解决此问题。\n\n- 性能提升：GigaPath 和 Midnight12k 现在默认使用 float16 数据类型运行，以提高速度。\n\n- 修复 bug：允许从 pytorch_model.bin 或 model.safetensors 文件中恢复 ResNet50-IN 模型权重。\n\n- 在分割完成后清除组织掩码（gdf_contours）。采用惰性初始化方式恢复该掩码，从而避免在处理 4000 张以上 WSI 时 CPU 内存占用持续增加的问题。\n\n","2025-11-19T17:42:11",{"id":162,"version":163,"summary_zh":164,"released_at":165},162766,"v0.2.2","* 修复 bug：segment_tissue 的默认参数会抛出异常\n\n* 向 segment_tissue 添加 num_workers 参数\n\n* 修复 bug：当放大倍数为 None 时，在 patcher 可视化中显示 mpp\n\n* 默认不安装重量级库\n\n* 增加从 CLAM 类型坐标创建 WSIPatcher 的功能\n\n* 修复 from_legacy_coords\n\n* 向 from_legacy 添加 coords_only 参数\n\n* 向 from_legacy_coords 添加 pil 参数\n\n* 在 CuCIMWSI 和 ImageWSI 中将 slide_path 作为位置参数传递，并修复 WSIPatcher 中的 src_pixel_size 异常\n\n* 添加语义分割推理\n\n* 添加语义分割推理\n\n* 测试\n\n* 添加 forward_kwargs 并创建 save_coords_h5\n\n* 在提交 PR 之前进行代码清理\n\n* 修复从 ImageWSI 到 WSI 的参数传递问题\n\n* 在提交 PR 之前进行代码清理\n\n* 在 README 中添加换行符\n\n* 移除 forward_kwargs\n\n* 移除 get_channels\n\n* 修复：在处理器单元测试中设置正确的 WSI 路径","2025-08-05T20:12:24",{"id":167,"version":168,"summary_zh":169,"released_at":170},162767,"v0.2.1","- 添加 Feather 滑块编码器（ICLM'25）\n- 设置 Hugging Face 镜像\n- 修复教程 3 中的 bug\n- 在“运行单张切片”中公开分割参数","2025-07-16T13:00:30",{"id":172,"version":173,"summary_zh":174,"released_at":175},162768,"v0.2.0","- 使用递归搜索处理位于嵌套目录中的 WSI（--search_nested）\n \n- 新的缓存机制，用于处理超大规模的 WSI 批次。当处理 10 万张以上的 WSI 时，这些数据通常存储在速度较慢的 HDD 上。为此，可在高速 SSD 上启用本地缓存（--wsi_cache .\u002Fcache --cache_batch_size 32）。数据将按批次自动复制，并并行处理。支持自动清理。\n \n- 在 Processor 和 WSI 中新增 release() 函数，以确保释放 GPU 显存。\n \n- 版本号将自动从 `toml` 文件中推断得出。\n","2025-06-06T13:35:16",{"id":177,"version":178,"summary_zh":179,"released_at":180},162769,"v0.1.1","添加 Read the Docs 文档","2025-04-13T19:17:36",{"id":182,"version":183,"summary_zh":184,"released_at":185},162770,"v0.1.0","\r\n- 新增对 CuCIM 和 PIL 的原生支持。\r\n\r\n- 所有分割模型现均采用 Hugging Face，并支持本地检查点（不再使用 torch.hub）。\r\n\r\n- 所有补丁模型已迁移到 Hugging Face，且支持本地运行（Hibou 和 MUSK 除外）。\r\n\r\n- 改进了错误处理，并增强了文档字符串。\r\n\r\n","2025-04-10T00:27:29",{"id":187,"version":188,"summary_zh":189,"released_at":190},162771,"v0.0.5","全新的 AnyToTiffConverter。方便将无法被 OpenSlide 读取的文件转换为金字塔型 TIFF 格式。","2025-02-18T23:08:14",{"id":192,"version":193,"summary_zh":194,"released_at":195},162772,"v0.0.4","支持 7 个额外的补丁编码器：\n\n- hibou_l\n- kaiko-vits8\n- kaiko-vits16\n- kaiko-vitb8\n- kaiko-vitb16\n- kaiko-vitl14\n- lunit-vits8\n\n支持 1 个额外的滑块编码器：\n\n- madeleine（基于 conch_v1 补丁编码器，采用 256×256 分辨率、10 倍缩放的补丁）","2025-02-18T18:11:51",{"id":197,"version":198,"summary_zh":199,"released_at":200},162773,"v0.0.3","- Support for one additional tissue vs segmentation model based on GrandQC (Nat. Comm, 2024, https:\u002F\u002Fwww.nature.com\u002Farticles\u002Fs41467-024-54769-y). Much faster. Very good for H&E. Very bad for IHC and special stains. Can be used with `--segmenter grandqc`\r\n\r\n- Expose tissue confidence threshold. Default to 0.5 thresh. Reducing it to 0.4 in challenging cases seem to help. Tested in PDL-1 on 100 WSIs.\r\n\r\n","2025-02-18T17:05:57",{"id":202,"version":203,"summary_zh":204,"released_at":205},162774,"v0.0.2","- Better tutorials\r\n- Cleaner API\r\n- Heatmap viz","2025-02-15T00:30:18",{"id":207,"version":208,"summary_zh":209,"released_at":210},162775,"v0.0.1","Trident is up and running. Your new library for large-scale whole-slide image processing. Supports:\r\n\r\n- Batch processing with error handling\r\n- Tissue vs Background segmentation\r\n- Tissue patching\r\n- Patch encoding using one of 13 foundation models, including UNI, UNIv2, CONCH, Virchow, H-Optimus, GigaPath\r\n- Slide encoding using Titan, PRISM, CHIEF, GigaPath. \r\n\r\nStay Tuned for Updates! We're cooking!  ","2025-02-11T00:00:37"]