[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-microsoft--BiomedParse":3,"tool-microsoft--BiomedParse":62},[4,18,26,35,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},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 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,2,"2026-04-10T11:39:34",[14,15,13],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":32,"last_commit_at":41,"category_tags":42,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[43,13,15,14],"插件",{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":10,"last_commit_at":50,"category_tags":51,"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",[52,15,13,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},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[14,15,13,61],"视频",{"id":63,"github_repo":64,"name":65,"description_en":66,"description_zh":67,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":77,"owner_email":78,"owner_twitter":79,"owner_website":80,"owner_url":81,"languages":82,"stars":103,"forks":104,"last_commit_at":105,"license":106,"difficulty_score":10,"env_os":107,"env_gpu":108,"env_ram":109,"env_deps":110,"category_tags":122,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":124,"updated_at":125,"faqs":126,"releases":162},8874,"microsoft\u002FBiomedParse","BiomedParse","BiomedParse: A Foundation Model for Joint Segmentation, Detection, and Recognition of Biomedical Objects Across Nine Modalities","BiomedParse 是一款专为生物医学图像分析打造的通用基础模型，能够跨九种成像模态（如 CT、MRI、病理切片等）统一执行分割、检测与识别任务。它有效解决了传统工具往往只能处理单一模态或特定任务的局限，帮助研究人员从复杂多样的医疗影像中高效提取关键信息，大幅降低多任务分析的门槛。\n\n该工具特别适合生物医学领域的研究人员、临床医生及 AI 开发者使用，尤其是那些需要处理大规模、多模态影像数据的专业团队。BiomedParse 的最新 v2 版本引入了独特的 BoltzFormer 架构，显著提升了微小目标的分割精度，并支持端到端的 3D 体积推理，在相关国际挑战赛中荣获榜首。此外，它还内置了对象存在性检测模块，能自动过滤误报，无需额外的后处理步骤。无论是进行科研探索还是开发辅助诊断应用，BiomedParse 都提供了一个灵活且强大的技术基座。","# **BiomedParse**\n\n[Notice] This is v2 of the [`BiomedParse`](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper) model, with improved code and model architecture using [`BoltzFormer`](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FCVPR2025\u002Fpapers\u002FZhao_Boltzmann_Attention_Sampling_for_Image_Analysis_with_Small_Objects_CVPR_2025_paper.pdf), supporting end-to-end 3D inference. Check [`v1`](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Ftree\u002Fmain) if you are looking for the original version.\n\n[[`Paper`](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper)] [[`Demo`](https:\u002F\u002Fmicrosoft.github.io\u002FBiomedParse\u002F)] [[`Model`](https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse)]  [[`Data`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FBiomedParseData)]  [[`BibTeX`](#Citation)]\n\nThis repository hosts the code and resources for **BiomedParse**, aka \"A Foundation Model for Joint Segmentation, Detection, and Recognition of Biomedical Objects Across Nine Modalities\" ([*Nature Methods*](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper)). **BiomedParse** is designed for comprehensive biomedical image analysis. It offers a unified approach to perform **segmentation**, **detection**, and **recognition** across diverse biomedical imaging modalities. By consolidating these tasks, BiomedParse provides an efficient and flexible tool tailored for researchers and practitioners, facilitating the interpretation and analysis of complex biomedical data.\n\n![Example Predictions](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_BiomedParse_readme_797ca515af59.png)\n\n## What's New in v2?\n\nSince the publication of BiomedParse, we've been continuously collecting feedbacks from the community and making progressive efforts to improve and expand its capability and usability. The v2 release provides:\n\n- Larger [`pretraining data`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM) at million scale covering [200+ anatomies](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse?tab=readme-ov-file#supported-tasks) across different modalities.\n- Improved segmentation performance for small objects using the [`BoltzFormer`](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FCVPR2025\u002Fpapers\u002FZhao_Boltzmann_Attention_Sampling_for_Image_Analysis_with_Small_Objects_CVPR_2025_paper.pdf) architecture.\n- SOTA 3D segmentation performance supporting end-to-end volumetric inference ([`CVPR Challenge`](https:\u002F\u002Fwww.codabench.org\u002Fcompetitions\u002F5651\u002F)).\n- Built-in object existence detection for false positives (no seperate mask checking required).\n\nShould I use v1 or v2?\n\nShort answer: v2 for the 3D modalities, and v1 for the rest.\n\n| Version | Image type | Modalities | # tasks | Existence detection |\n|-----|------|------|---------|---------|\n| v1 | 2D   | CT, MRI, Ultrasound, X-Ray, Pathology, Endoscopy, Dermoscopy, Fundus, OCT | 100+ | Post-inference K-S test |\n| v2 | 3D   | CT, MRI, Ultrasound, PET, 3D Microscopy (EM, lightsheet)   | [200+](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse?tab=readme-ov-file#supported-tasks) | Built-in ISD module |\n\n\n\n\n## News\n- Oct. 15, 2025: BiomedParse v2 release is complete with full support for inference and finetuning! \n- Jun. 11, 2025: BiomedParse is #1 in the [`CVPR 2025: Foundation Models for Text-guided 3D Biomedical Image Segmentation Challenge`](https:\u002F\u002Fwww.codabench.org\u002Fcompetitions\u002F5651\u002F)! We upgraded our model and finetuned on the challenge [`dataset`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM) with a wider and more comprehensive coverage for 3D biomedical imaging data. Checkout our model in containerized [[`docker image`](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1eUAY1qvEzM0Ut0PA9BGp6gexn5TiFWj8\u002Fview?usp=sharing)] for direct inference. Please acknowledge the original challenge if you use this version of the model.\n- Jan. 9, 2025: Refined all object recognition script and added notebook with examples.\n- Dec. 12, 2024: Uploaded extra datasets for finetuning on [[`Data`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FBiomedParseData)]. Added random rotation feature for training.\n- Dec. 5, 2024: The loading process of target_dist.json is optimized by automatic downloading from HuggingFace.\n- Dec. 3, 2024: We added inference notebook examples in inference_example_RGB.ipynb and inference_example_NIFTI.ipynb\n- Nov. 22, 2024: We added negative prediction p-value example in inference_example_DICOM.ipynb\n- Nov. 18, 2024: BiomedParse is officially online in [*Nature Methods*](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper)!\n\n## Installation\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse.git\n```\n\n### Conda Environment Setup\n```sh\nconda create -n biomedparse_v2 python=3.10.14\nconda activate biomedparse_v2\n```\n\nInstall dependencies\n```sh\npip install -r assets\u002Frequirements\u002Frequirements.txt \n\n# The above requirements file assumes your environment uses cuda12.4. Adjust accordingly for your system\u002Fenvironment\n\npip install azureml-automl-core\npip install opencv-python\npip install git+https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fdetectron2.git\n```\n\n\n\n## Model Weights\nWe provides model weights trained on the CVPR 2025 Text-guided 3D Segmentation Challenge [`dataset`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM). Please acknowledge the original challenge if you use this version of the model. We also refer to the original dataset for necessary image preprocessing.\n### Option 1: HuggingFace Hub\nYou can download the pretrained model weights directly from the HuggingFace Hub.\n\nFirst, install the required package:\n```bash\npip install huggingface_hub\n```\n\nThen, download the checkpoint file using the HuggingFace Hub API:\n```python\nfrom huggingface_hub import hf_hub_download\n\n# Download the checkpoint file\nfile_path = hf_hub_download(\n    repo_id=\"microsoft\u002FBiomedParse\",\n    filename=\"biomedparse_v2.ckpt\"\n)\n\nprint(\"Model weights downloaded to:\", file_path)\n```\n\n### Option 2: Direct Download via Command Line\nYou can also download the file directly using `wget` or `curl`:\n```bash\nwget https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse\u002Fresolve\u002Fmain\u002Fbiomedparse_v2.ckpt\n```\nor\n```bash\ncurl -L -o biomedparse_v2.ckpt https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse\u002Fresolve\u002Fmain\u002Fbiomedparse_v2.ckpt\n```\n\n> 💡 **Note:** If the repository is private, log in with your HuggingFace token using:\n> ```bash\n> huggingface-cli login\n> ```\n> before attempting to download.\n\n\nNow you should have the model weights ready for use!\n\n\n## Model Inference\nThe v2 of BiomedParse supports segmentation of 3D volumes in a slice-by-slice manner, with neighboring 3D context encoded around each slice in RGB format. \n\n### Inference 3D Examples\n```sh\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\nimport hydra\nfrom hydra import compose\nfrom hydra.core.global_hydra import GlobalHydra\nfrom utils import process_input, process_output, slice_nms\nfrom inference import postprocess, merge_multiclass_masks\nfrom skimage import segmentation\nfrom huggingface_hub import hf_hub_download\n\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\nprint(\"Using device:\", device)\n\nGlobalHydra.instance().clear()\nhydra.initialize(config_path=\"configs\u002Fmodel\", job_name=\"example_prediction\")\ncfg = compose(config_name=\"biomedparse_3D\")\nmodel = hydra.utils.instantiate(cfg, _convert_=\"object\")\nmodel.load_pretrained(hf_hub_download(\n  repo_id=\"microsoft\u002FBiomedParse\", filename=\"biomedparse_v2.ckpt\"))\nmodel = model.to(device).eval()\n\n# Example image and prompt\nfile_path = \"examples\u002Fimgs\u002FCT_AMOS_amos_0018.npz\"\n\nnpz_data = np.load(file_path, allow_pickle=True)\nimgs = npz_data[\"imgs\"]\ntext_prompts = npz_data[\"text_prompts\"].item()\n\nprint(\"Loaded image shape:\", imgs.shape)\nprint(\"Text prompts:\", text_prompts)\n\nids = [int(_) for _ in text_prompts.keys() if _ != \"instance_label\"]\nids.sort()\ntext = \"[SEP]\".join([text_prompts[str(i)] for i in ids])\n\nimgs, pad_width, padded_size, valid_axis = process_input(imgs, 512)\n\nimgs = imgs.to(device).int()\n\ninput_tensor = {\n    \"image\": imgs.unsqueeze(0),  # Add batch dimension\n    \"text\": [text],\n}\n\nwith torch.no_grad():\n    output = model(input_tensor, mode=\"eval\", slice_batch_size=4)\n\nmask_preds = output[\"predictions\"][\"pred_gmasks\"]\nmask_preds = F.interpolate(mask_preds, size=(512, 512), mode=\"bicubic\", align_corners=False, antialias=True)\n\nmask_preds = postprocess(mask_preds, output[\"predictions\"][\"object_existence\"])\nmask_preds = merge_multiclass_masks(mask_preds, ids)\nmask_preds = process_output(mask_preds, pad_width, padded_size, valid_axis)\nprint(\"Processed mask shape:\", mask_preds.shape)\n```\n\nPlease refer to the [inference notebook](inference_example_3D.ipynb) for more examples.\n\n## Evaluation\nYou need to prepare the public model checkpoint and evaluation data under ```\u003CYOUR MODEL AND DATA DIR>``` and put it in `evaluate_biomedparse.yaml` as\n```yaml\nmounts:\n  external: \u003CYOUR MODEL AND DATA DIR>\n```\nSave the model checkpoint under ```\u003CYOUR MODEL AND DATA DIR>```. Download the validation set of the CVPR 2025 Text-guided 3D Segmentation Challenge [`dataset`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM). Save the [`validation images`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM\u002Ftree\u002Fmain\u002F3D_val_npz)  to ```\u003CYOUR MODEL AND DATA DIR>\u002Fdata\u002Ftest```, and [`validation masks`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM\u002Ftree\u002Fmain\u002F3D_val_gt\u002F3D_val_gt_text)  to ```\u003CYOUR MODEL AND DATA DIR>\u002Fdata\u002Ftest_mask```. Run\n\n```bash\npython -m azureml.acft.image.components.olympus.app.main \\\n  --config-path \u003CYOUR ABSOLUTE CONFIG DIRECTORY PATH> \\\n  --config-name evaluate_biomedparse\n```\n\n## Fine-tuning\nWant to improve performance for your specific tasks? Here is a detailed instruction for end-to-end finetuning on your own data: [FINETUNING](assets\u002Freadmes\u002FFINETUNING.md)\n\n## Recommended Preprocessing (Important!)\nBiomedParse v2 training covered five commonly used 3D biomedical image modalities: CT, MR, PET, Ultrasound, and Microscopy. It is important to preprocess the inference images the same as in model training to achieve reasonable performance. Please process all images to npz format with an intensity range of [0, 255]. Specifically, for CT images, please normalize the Hounsfield units using typical window width and level values according to the site\u002Fanatomy: \n- soft tissues (W:400, L:40)\n- lung (W:1500, L:-160)\n- brain (W:80, L:40)\n- bone (W:1800, L:400).\n\nFor all other images, clip the intensity values in the range between the 0.5th and 99.5th percentiles. Finally, rescale the intensity values to the range of [0, 255]. If the original intensity range was already in [0, 255], no preprocessing needed.\n\n## Supported Tasks\n- **CT**: oncology\u002Fpathology (adrenocortical carcinoma, kidney lesions\u002Fcysts L\u002FR, liver tumors, lung lesions, pancreas tumors, head–neck cancer, colon cancer primaries, COVID-19, whole-body lesion, lymph nodes); thoracic (lungs L\u002FR, lobes LUL\u002FLLL\u002FRUL\u002FRML\u002FRLL, trachea, airway tree); abdomen\u002Fpelvis (spleen, liver, gallbladder, stomach, pancreas, duodenum, small bowel, colon, esophagus); GU\u002Fendocrine (kidneys L\u002FR, adrenal glands L\u002FR, bladder, prostate, uterus); vascular (aorta\u002Ftree, SVC, IVC, pulmonary vein, brachiocephalic trunk, subclavian\u002Fcarotid arteries L\u002FR, brachiocephalic veins L\u002FR, left atrial appendage, portal\u002Fsplenic vein, iliac arteries\u002Fveins L\u002FR); cardiac (heart); head\u002Fneck (carotids L\u002FR, submandibular\u002Fparotid\u002Flacrimal glands L\u002FR, thyroid, larynx glottic\u002Fsupraglottic, lips, buccal mucosa, oral cavity, cervical esophagus, cricopharyngeal inlet, arytenoids, eyeball segments ant\u002Fpost L\u002FR, optic chiasm, optic nerves L\u002FR, cochleae L\u002FR, pituitary, brainstem, spinal cord); neuro\u002Fcranial (brain, skull, Circle of Willis CTA); spine\u002FMSK (sacrum, vertebrae C1–S1, humeri\u002Fscapulae\u002Fclavicles\u002Ffemora\u002Fhips L\u002FR, gluteus maximus\u002Fmedius\u002Fminimus L\u002FR, autochthon L\u002FR, iliopsoas L\u002FR).\n- **MRI**: abdomen\u002Fpelvis (spleen, liver, gallbladder, stomach, pancreas, duodenum, small bowel, colon whole, esophagus, bladder, prostate, uterus); colon segments (cecum, appendix, ascending, transverse, descending, sigmoid, rectum); GU (prostate transition zone, prostate lesion); cardiac CMR (LV, RV, myocardium, LA, RA); thoracic (lungs L\u002FR); vascular (aorta, pulmonary artery, SVC, IVC, portal\u002Fsplenic vein, iliac arteries\u002Fveins L\u002FR, carotid arteries L\u002FR, jugular veins L\u002FR); neuro tumors\u002Fischemia (brain, brain tumor, stroke lesion, GTVp\u002FGTVn tumor, vestibular schwannoma intra\u002Fextra-meatal, cochleae L\u002FR); glioma components (non-enhancing tumor core, non-enhancing FLAIR hyperintensity, enhancing tissue, resection cavity); white matter disease (WM hyperintensities FLAIR\u002FT1); neurovascular (Circle of Willis MRA); spine\u002FMSK (sacrum, vertebrae regional, discs, spinal canal\u002Fcord, humeri\u002Ffemora\u002Fhips L\u002FR, gluteus maximus\u002Fmedius\u002Fminimus L\u002FR, autochthon L\u002FR, iliopsoas L\u002FR).\n- **Ultrasound**: cardiac (LV, myocardium, LA), neck (thyroid, carotid artery, jugular vein), neuro (brain tumor), calf MSK (soleus, gastrocnemius medialis\u002Flateralis).\n- **PET**: whole-body lesion.\n- **Electron Microscopy**: endolysosomes, mitochondria, nuclei, neuronal ultrastructure, synaptic clefts, axon.\n- **Lightsheet Microscopy**: brain neural activity, Alzheimer’s plaque, nuclei, vessel.\n\n\u003C!-- ## Dataset\nBiomedParseData was created from preprocessing publicly available biomedical image segmentation datasets. Check a subset of our processed datasets on HuggingFace: https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FBiomedParseData. For the source datasets, please check the details here: [BiomedParseData](assets\u002Freadmes\u002FDATASET.md). As a quick start, we've samples a tiny demo dataset at biomedparse_datasets\u002FBiomedParseData-Demo -->\n\n\u003C!-- ## Model Checkpoints\nWe host our model checkpoints on HuggingFace here: https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse. See example code below on model loading.\n\nPlease expect future updates of the model as we are making it more robust and powerful based on feedbacks from the community. We recomment using the latest version of the model.\n\n## Running Inference with BiomedParse\n\nWe’ve streamlined the process for running inference using BiomedParse. Below are details and resources to help you get started.\n\n### How to Run Inference\nTo perform inference with BiomedParse, use the provided example code and resources:\n\n- **Inference Code**: Use the example inference script in `example_prediction.py`.\n- **Sample Images**: Load and test with the provided example images located in the `examples` directory.\n- **Model Configuration**: The model settings are defined in `configs\u002Fbiomedparse_inference.yaml`.\n\n### Example Notebooks\n\nWe’ve included sample notebooks to guide you through running inference with BiomedParse:\n\n- **RGB Inference Example**: Check out the `inference_examples_RGB.ipynb` notebook for example using normal RGB images, including Pathology, X-ray, Ultrasound, Endoscopy, Dermoscopy, OCT, Fundus.\n- **DICOM Inference Example**: Check out the `inference_examples_DICOM.ipynb` notebook for example using DICOM images.\n- **NIFTI Inference Example**: Check out the `inference_examples_NIFTI.ipynb` notebook for example using NIFTI image slices.\n- You can also try a quick online demo: [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmicrosoft\u002FBiomedParse\u002Fblob\u002Fmain\u002Finference_colab_demo.ipynb)\n\n### Model Setup\n```sh\nfrom PIL import Image\nimport torch\nfrom modeling.BaseModel import BaseModel\nfrom modeling import build_model\nfrom utilities.distributed import init_distributed\nfrom utilities.arguments import load_opt_from_config_files\nfrom utilities.constants import BIOMED_CLASSES\nfrom inference_utils.inference import interactive_infer_image\nfrom inference_utils.output_processing import check_mask_stats\nimport numpy as np\n\n# Build model config\nopt = load_opt_from_config_files([\"configs\u002Fbiomedparse_inference.yaml\"])\nopt = init_distributed(opt)\n\n# Load model from pretrained weights\n#pretrained_pth = 'pretrained\u002Fbiomed_parse.pt'\npretrained_pth = 'hf_hub:microsoft\u002FBiomedParse'\n\nmodel = BaseModel(opt, build_model(opt)).from_pretrained(pretrained_pth).eval().cuda()\nwith torch.no_grad():\n    model.model.sem_seg_head.predictor.lang_encoder.get_text_embeddings(BIOMED_CLASSES + [\"background\"], is_eval=True)\n```\n\n### Segmentation On Example Images\n```sh\n# RGB image input of shape (H, W, 3). Currently only batch size 1 is supported.\nimage = Image.open('examples\u002FPart_1_516_pathology_breast.png', formats=['png'])\nimage = image.convert('RGB')\n# text prompts querying objects in the image. Multiple ones can be provided.\nprompts = ['neoplastic cells', 'inflammatory cells']\n\n# load ground truth mask\ngt_masks = []\nfor prompt in prompts:\n    gt_mask = Image.open(f\"examples\u002FPart_1_516_pathology_breast_{prompt.replace(' ', '+')}.png\", formats=['png'])\n    gt_mask = 1*(np.array(gt_mask.convert('RGB'))[:,:,0] > 0)\n    gt_masks.append(gt_mask)\n\npred_mask = interactive_infer_image(model, image, prompts)\n\n# prediction with ground truth mask\nfor i, pred in enumerate(pred_mask):\n    gt = gt_masks[i]\n    dice = (1*(pred>0.5) & gt).sum() * 2.0 \u002F (1*(pred>0.5).sum() + gt.sum())\n    print(f'Dice score for {prompts[i]}: {dice:.4f}')\n    check_mask_stats(image, pred_mask[i]*255, 'X-Ray-Chest', text_prompt[i])\n    print(f'p-value for {prompts[i]}: {p_value:.4f}')\n```\n\n\nDetection and recognition inference code are provided in `inference_utils\u002Foutput_processing.py`.\n\n- `check_mask_stats()`: Outputs p-value for model-predicted mask for detection. Check the `inference_examples_RGB.ipynb` notebook.\n- `combine_masks()`: Combines predictions for non-overlapping masks.\n\n## Finetune on Your Own Data\nWhile BiomedParse can take in arbitrary image and text prompt, it can only reasonably segment the targets that it has learned during pretraining! If you have a specific segmentation task that the latest checkpint doesn't do well, here is the instruction on how to finetune it on your own data.\n\n### Raw Image and Annotation\nBiomedParse expects images and ground truth masks in 1024x1024 PNG format. For each dataset, put the raw image and mask files in the following format\n```\n├── biomedparse_datasets\n    ├── YOUR_DATASET_NAME\n        ├── train\n        ├── train_mask\n        ├── test\n        └── test_mask\n```\nEach folder should contain .png files. The mask files should be binary images where pixels != 0 indicates the foreground region.\n\n### File Name Convention\nEach file name follows certain convention as\n\n[IMAGE-NAME]\\_[MODALITY]\\_[SITE].png\n\n[IMAGE-NAME] is any string that is unique for one image. The format can be anything.\n[MODALITY] is a string for the modality, such as \"X-Ray\"\n[SITE] is the anatomic site for the image, such as \"chest\"\n\nOne image can be associated with multiple masks corresponding to multiple targets in the image. The mask file name convention is\n\n[IMAGE-NAME]\\_[MODALITY]\\_[SITE]\\_[TARGET].png\n\n[IMAGE-NAME], [MODALITY], and [SITE] are the same with the image file name.\n[TARGET] is the name of the target with spaces replaced by '+'. E.g. \"tube\" or \"chest+tube\". Make sure \"_\" doesn't appear in [TARGET].\n\n### Get Final Data File with Text Prompts\nIn biomedparse_datasets\u002Fcreate-customer-datasets.py, specify YOUR_DATASET_NAME. Run the script with\n```\ncd biomedparse_datasets\npython create-customer-datasets.py\n```\nAfter that, the dataset folder should be of the following format\n```\n├── dataset_name\n        ├── train\n        ├── train_mask\n        ├── train.json\n        ├── test\n        ├── test_mask\n        └── test.json\n```\n\n### Register Your Dataset for Training and Evaluation\nIn datasets\u002Fregistration\u002Fregister_biomed_datasets.py, simply add YOUR_DATASET_NAME to the datasets list. Registered datasets are ready to be added to the training and evaluation config file configs\u002Fbiomed_seg_lang_v1.yaml. Your training dataset is registered as biomed_YOUR_DATASET_NAME_train, and your test dataset is biomed_YOUR_DATASET_NAME_test.\n\n\n## Train BiomedParse\nTo train the BiomedParse model, run:\n\n```sh\nbash assets\u002Fscripts\u002Ftrain.sh\n```\nThis will continue train the model using the training datasets you specified in configs\u002Fbiomed_seg_lang_v1.yaml\n\n## Evaluate BiomedParse\nTo evaluate the model, run:\n```sh\nbash assets\u002Fscripts\u002Feval.sh\n```\nThis will continue evaluate the model on the test datasets you specified in configs\u002Fbiomed_seg_lang_v1.yaml. We put BiomedParseData-Demo as the default. You can add any other datasets in the list. -->\n\n\n## Citation\n\nPlease cite our paper if you use the code, model, or data.\n\n```bibtex\n@article{zhao2025foundation,\n  title={A foundation model for joint segmentation, detection and recognition of biomedical objects across nine modalities},\n  author={Zhao, Theodore and Gu, Yu and Yang, Jianwei and Usuyama, Naoto and Lee, Ho Hin and Kiblawi, Sid and Naumann, Tristan and Gao, Jianfeng and Crabtree, Angela and Abel, Jacob and others},\n  journal={Nature methods},\n  volume={22},\n  number={1},\n  pages={166--176},\n  year={2025},\n  publisher={Nature Publishing Group US New York}\n}\n```\n\nIf you use the v2 code or model, please also cite the BoltzFormer paper:\n```bibtex\n@inproceedings{zhao2025boltzmann,\n  title={Boltzmann Attention Sampling for Image Analysis with Small Objects},\n  author={Zhao, Theodore and Kiblawi, Sid and Usuyama, Naoto and Lee, Ho Hin and Preston, Sam and Poon, Hoifung and Wei, Mu},\n  booktitle={Proceedings of the Computer Vision and Pattern Recognition Conference},\n  pages={25950--25959},\n  year={2025}\n}\n```\n\n## Usage and License Notices\nThe model described in this repository is provided for research and development use only. The model is not intended for use in clinical decision-making or for any other clinical use, and the performance of the model for clinical use has not been established. You bear sole responsibility for any use of this model, including incorporation into any product intended for clinical use.\n","# **BiomedParse**\n\n【通知】这是 [`BiomedParse`](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper) 模型的 v2 版本，采用了基于 [`BoltzFormer`](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FCVPR2025\u002Fpapers\u002FZhao_Boltzmann_Attention_Sampling_for_Image_Analysis_with_Small_Objects_CVPR_2025_paper.pdf) 的改进代码和模型架构，支持端到端的 3D 推理。如果您需要原始版本，请查看 [`v1`](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Ftree\u002Fmain)。\n\n[[`论文`](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper)] [[`演示`](https:\u002F\u002Fmicrosoft.github.io\u002FBiomedParse\u002F)] [[`模型`](https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse)]  [[`数据`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FBiomedParseData)]  [[`BibTeX`](#Citation)]\n\n本仓库托管了 **BiomedParse** 的代码与资源，即“用于跨九种模态的生物医学对象联合分割、检测与识别的基础模型”（[*Nature Methods*](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper)）。**BiomedParse** 专为全面的生物医学图像分析而设计。它提供了一种统一的方法，可在多种生物医学成像模态中执行 **分割**、**检测** 和 **识别** 任务。通过整合这些任务，BiomedParse 为研究人员和从业者提供了一款高效且灵活的工具，有助于解析和分析复杂的生物医学数据。\n\n![示例预测](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_BiomedParse_readme_797ca515af59.png)\n\n## v2 有哪些新特性？\n\n自 BiomedParse 发表以来，我们不断收集社区反馈，并持续努力提升其功能与易用性。v2 版本提供了：\n\n- 更大规模的 [`预训练数据`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM)，数量达百万级，涵盖不同模态下的 [200 多个解剖结构](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse?tab=readme-ov-file#supported-tasks)。\n- 使用 [`BoltzFormer`](https:\u002F\u002Fopenaccess.thecvf.com\u002Fcontent\u002FCVPR2025\u002Fpapers\u002FZhao_Boltzmann_Attention_Sampling_for_Image_Analysis_with_Small_Objects_CVPR_2025_paper.pdf) 架构，显著提升了小物体的分割性能。\n- 实现了 SOTA 级别的 3D 分割性能，支持端到端的体素级推理（[`CVPR 挑战赛`](https:\u002F\u002Fwww.codabench.org\u002Fcompetitions\u002F5651\u002F)）。\n- 内置目标存在性检测功能，可有效减少假阳性（无需额外的掩码检查）。\n\n我应该使用 v1 还是 v2？\n\n简短回答：对于 3D 模态请使用 v2，其他情况则使用 v1。\n\n| 版本 | 图像类型 | 模态 | 任务数量 | 存在性检测 |\n|-----|------|------|---------|---------|\n| v1 | 2D   | CT、MRI、超声、X 射线、病理学、内窥镜、皮肤镜、眼底照相、OCT | 100+ | 推理后 K-S 检验 |\n| v2 | 3D   | CT、MRI、超声、PET、3D 显微镜（EM、光片显微镜）   | [200+](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse?tab=readme-ov-file#supported-tasks) | 内置 ISD 模块 |\n\n\n\n\n## 最新动态\n- 2025 年 10 月 15 日：BiomedParse v2 正式发布，全面支持推理与微调！\n- 2025 年 6 月 11 日：BiomedParse 在 [`CVPR 2025: 文本引导的 3D 生物医学图像分割基础模型挑战赛`](https:\u002F\u002Fwww.codabench.org\u002Fcompetitions\u002F5651\u002F) 中荣获第一名！我们升级了模型，并基于该挑战赛的 [`数据集`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM) 进行了微调，覆盖范围更广、更全面的 3D 生物医学影像数据。您可以通过容器化的 [[`docker 镜像`](https:\u002F\u002Fdrive.google.com\u002Ffile\u002Fd\u002F1eUAY1qvEzM0Ut0PA9BGp6gexn5TiFWj8\u002Fview?usp=sharing)] 直接进行推理。使用此版本模型时，请务必注明原挑战赛来源。\n- 2025 年 1 月 9 日：优化了所有目标识别脚本，并新增包含示例的笔记本。\n- 2024 年 12 月 12 日：上传了用于微调的额外数据集至 [[`数据`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FBiomedParseData)]。增加了随机旋转增强功能。\n- 2024 年 12 月 5 日：优化了 target_dist.json 文件的加载流程，改为从 HuggingFace 自动下载。\n- 2024 年 12 月 3 日：新增了推理笔记本示例，分别位于 inference_example_RGB.ipynb 和 inference_example_NIFTI.ipynb。\n- 2024 年 11 月 22 日：在 inference_example_DICOM.ipynb 中添加了负预测 p 值示例。\n- 2024 年 11 月 18 日：BiomedParse 正式发表于 [*Nature Methods*](https:\u002F\u002Faka.ms\u002Fbiomedparse-paper)！\n\n## 安装说明\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse.git\n```\n\n### Conda 环境搭建\n```sh\nconda create -n biomedparse_v2 python=3.10.14\nconda activate biomedparse_v2\n```\n\n安装依赖项：\n```sh\npip install -r assets\u002Frequirements\u002Frequirements.txt \n\n# 上述要求文件假设您的环境使用 cuda12.4。请根据您的系统\u002F环境相应调整。\n\npip install azureml-automl-core\npip install opencv-python\npip install git+https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fdetectron2.git\n```\n\n\n\n## 模型权重\n我们提供了在 CVPR 2025 文本引导的 3D 分割挑战赛 [`数据集`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM) 上训练的模型权重。使用此版本模型时，请务必注明原挑战赛来源。此外，必要的图像预处理也参考了原始数据集。\n### 方法一：HuggingFace Hub\n您可以直接从 HuggingFace Hub 下载预训练模型权重。\n\n首先安装所需包：\n```bash\npip install huggingface_hub\n```\n\n然后使用 HuggingFace Hub API 下载检查点文件：\n```python\nfrom huggingface_hub import hf_hub_download\n\n# 下载检查点文件\nfile_path = hf_hub_download(\n    repo_id=\"microsoft\u002FBiomedParse\",\n    filename=\"biomedparse_v2.ckpt\"\n)\n\nprint(\"模型权重已下载至：\", file_path)\n```\n\n### 方法二：命令行直接下载\n您也可以使用 `wget` 或 `curl` 直接下载文件：\n```bash\nwget https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse\u002Fresolve\u002Fmain\u002Fbiomedparse_v2.ckpt\n```\n或\n```bash\ncurl -L -o biomedparse_v2.ckpt https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse\u002Fresolve\u002Fmain\u002Fbiomedparse_v2.ckpt\n```\n\n> 💡 **提示:** 如果仓库为私有，请先使用以下命令登录 HuggingFace 账号并获取令牌：\n> ```bash\n> huggingface-cli login\n> ```\n> 再尝试下载。\n\n\n现在您已经准备好使用模型权重了！\n\n\n## 模型推理\nBiomedParse v2 支持以逐层方式对 3D 体积进行分割，每层周围会编码相邻的 3D 上下文信息，并以 RGB 格式呈现。\n\n### 推理3D 示例\n```sh\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\nimport hydra\nfrom hydra import compose\nfrom hydra.core.global_hydra import GlobalHydra\nfrom utils import process_input, process_output, slice_nms\nfrom inference import postprocess, merge_multiclass_masks\nfrom skimage import segmentation\nfrom huggingface_hub import hf_hub_download\n\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\nprint(\"使用设备:\", device)\n\nGlobalHydra.instance().clear()\nhydra.initialize(config_path=\"configs\u002Fmodel\", job_name=\"example_prediction\")\ncfg = compose(config_name=\"biomedparse_3D\")\nmodel = hydra.utils.instantiate(cfg, _convert_=\"object\")\nmodel.load_pretrained(hf_hub_download(\n  repo_id=\"microsoft\u002FBiomedParse\", filename=\"biomedparse_v2.ckpt\"))\nmodel = model.to(device).eval()\n\n# 示例图像和提示\nfile_path = \"examples\u002Fimgs\u002FCT_AMOS_amos_0018.npz\"\n\nnpz_data = np.load(file_path, allow_pickle=True)\nimgs = npz_data[\"imgs\"]\ntext_prompts = npz_data[\"text_prompts\"].item()\n\nprint(\"加载的图像形状:\", imgs.shape)\nprint(\"文本提示:\", text_prompts)\n\nids = [int(_) for _ in text_prompts.keys() if _ != \"instance_label\"]\nids.sort()\ntext = \"[SEP]\".join([text_prompts[str(i)] for i in ids])\n\nimgs, pad_width, padded_size, valid_axis = process_input(imgs, 512)\n\nimgs = imgs.to(device).int()\n\ninput_tensor = {\n    \"image\": imgs.unsqueeze(0),  # 添加批次维度\n    \"text\": [text],\n}\n\nwith torch.no_grad():\n    output = model(input_tensor, mode=\"eval\", slice_batch_size=4)\n\nmask_preds = output[\"predictions\"][\"pred_gmasks\"]\nmask_preds = F.interpolate(mask_preds, size=(512, 512), mode=\"bicubic\", align_corners=False, antialias=True)\n\nmask_preds = postprocess(mask_preds, output[\"predictions\"][\"object_existence\"])\nmask_preds = merge_multiclass_masks(mask_preds, ids)\nmask_preds = process_output(mask_preds, pad_width, padded_size, valid_axis)\nprint(\"处理后的掩码形状:\", mask_preds.shape)\n```\n\n更多示例请参阅 [推理笔记本](inference_example_3D.ipynb)。\n\n## 评估\n您需要在 ```\u003CYOUR MODEL AND DATA DIR>``` 下准备公开模型检查点和评估数据，并将其放入 `evaluate_biomedparse.yaml` 中，如下所示：\n```yaml\nmounts:\n  external: \u003CYOUR MODEL AND DATA DIR>\n```\n将模型检查点保存在 ```\u003CYOUR MODEL AND DATA DIR>``` 下。下载 CVPR 2025 文本引导 3D 分割挑战赛的验证集 [`dataset`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM)。将 [`验证图像`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM\u002Ftree\u002Fmain\u002F3D_val_npz) 保存到 ```\u003CYOUR MODEL AND DATA DIR>\u002Fdata\u002Ftest``` 目录下，将 [`验证掩码`](https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fjunma\u002FCVPR-BiomedSegFM\u002Ftree\u002Fmain\u002F3D_val_gt\u002F3D_val_gt_text) 保存到 ```\u003CYOUR MODEL AND DATA DIR>\u002Fdata\u002Ftest_mask``` 目录下。然后运行以下命令：\n\n```bash\npython -m azureml.acft.image.components.olympus.app.main \\\n  --config-path \u003CYOUR ABSOLUTE CONFIG DIRECTORY PATH> \\\n  --config-name evaluate_biomedparse\n```\n\n## 微调\n想为您的特定任务提升性能吗？以下是关于在您自己的数据上进行端到端微调的详细说明：[FINETUNING](assets\u002Freadmes\u002FFINETUNING.md)\n\n## 推荐预处理（重要！）\nBiomedParse v2 的训练涵盖了五种常用的 3D 生物医学图像模态：CT、MR、PET、超声和显微镜。为了获得合理的性能，务必对推理图像进行与模型训练时相同的预处理。请将所有图像处理成 npz 格式，且强度范围为 [0, 255]。具体来说，对于 CT 图像，请根据部位\u002F解剖结构使用典型的窗宽和窗位值归一化 Hounsfield 单位：\n- 软组织（W:400, L:40）\n- 肺（W:1500, L:-160）\n- 脑（W:80, L:40）\n- 骨骼（W:1800, L:400）。\n\n对于其他所有图像，将强度值裁剪到第 0.5 百分位数和第 99.5 百分位数之间。最后，将强度值重新缩放到 [0, 255] 范围内。如果原始强度范围已在 [0, 255] 之内，则无需进行任何预处理。\n\n## 支持的任务\n- **CT**：肿瘤学\u002F病理学（肾上腺皮质癌、左右肾病变\u002F囊肿、肝脏肿瘤、肺部病变、胰腺肿瘤、头颈部癌症、结肠癌原发灶、COVID-19、全身性病变、淋巴结）；胸部（左右肺、左上叶\u002F左下叶\u002F右上叶\u002F右中叶\u002F右下叶、气管、气道树）；腹部\u002F盆腔（脾脏、肝脏、胆囊、胃、胰腺、十二指肠、小肠、结肠、食管）；泌尿生殖系统\u002F内分泌系统（左右肾、左右肾上腺、膀胱、前列腺、子宫）；血管系统（主动脉\u002F分支、上腔静脉、下腔静脉、肺静脉、头臂干、左右锁骨下动脉\u002F颈动脉、左右头臂静脉、左心耳、门静脉\u002F脾静脉、左右髂动脉\u002F静脉）；心脏（心脏）；头颈部（左右颈动脉、左右下颌下腺\u002F腮腺\u002F泪腺、甲状腺、喉部声门区\u002F声门上区、嘴唇、颊黏膜、口腔、颈段食管、环咽肌入口、杓状软骨、左右眼球前后节、视交叉、左右视神经、左右耳蜗、垂体、脑干、脊髓）；神经\u002F颅脑（大脑、颅骨、Willis环CTA）；脊柱\u002F肌肉骨骼系统（骶骨、C1–S1椎体、左右肱骨\u002F肩胛骨\u002F锁骨、左右股骨\u002F髋关节、左右臀大肌\u002F中肌\u002F小肌、左右固有肌、左右髂腰肌）。\n- **MRI**：腹部\u002F盆腔（脾脏、肝脏、胆囊、胃、胰腺、十二指肠、小肠全段、结肠全段、食管、膀胱、前列腺、子宫）；结肠各段（盲肠、阑尾、升结肠、横结肠、降结肠、乙状结肠、直肠）；泌尿生殖系统（前列腺移行带、前列腺病灶）；心脏CMR（左心室、右心室、心肌、左心房、右心房）；胸部（左右肺）；血管系统（主动脉、肺动脉、上腔静脉、下腔静脉、门静脉\u002F脾静脉、左右髂动脉\u002F静脉、左右颈动脉、左右颈内静脉）；神经肿瘤\u002F缺血（大脑、脑肿瘤、脑卒中病灶、GTVp\u002FGTVn肿瘤、鼓室内\u002F外的前庭神经鞘瘤、左右耳蜗）；胶质瘤成分（非增强肿瘤核心、FLAIR高信号非增强区域、增强组织、切除腔）；白质病变（FLAIR\u002FT1高信号白质病变）；神经血管（Willis环MRA）；脊柱\u002F肌肉骨骼系统（骶骨、局部椎体、椎间盘、椎管\u002F脊髓、左右肱骨\u002F股骨\u002F髋关节、左右臀大肌\u002F中肌\u002F小肌、左右固有肌、左右髂腰肌）。\n- **超声**：心脏（左心室、心肌、左心房）、颈部（甲状腺、颈动脉、颈内静脉）、神经（脑肿瘤）、小腿肌肉骨骼系统（比目鱼肌、腓肠肌内侧\u002F外侧）。\n- **PET**：全身性病变。\n- **电子显微镜**：内溶酶体、线粒体、细胞核、神经元超微结构、突触间隙、轴突。\n- **光片显微镜**：大脑神经活动、阿尔茨海默病斑块、细胞核、血管。\n\n\u003C!-- ## 数据集\nBiomedParseData 是通过对公开的生物医学图像分割数据集进行预处理而创建的。您可以在 HuggingFace 上查看我们处理过的部分数据集：https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fmicrosoft\u002FBiomedParseData。有关源数据集的详细信息，请参阅此处：[BiomedParseData](assets\u002Freadmes\u002FDATASET.md)。作为快速入门，我们在 biomedparse_datasets\u002FBiomedParseData-Demo 中提供了一个小型演示数据集 -->\n\n\u003C!-- ## 模型检查点\n我们在此处的 HuggingFace 上托管我们的模型检查点：https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse。下面提供了加载模型的示例代码。\n\n请期待模型的未来更新，因为我们正根据社区的反馈使其更加健壮和强大。我们建议使用最新版本的模型。\n\n## 使用 BiomedParse 进行推理\n\n我们简化了使用 BiomedParse 进行推理的流程。以下是帮助您入门的详细信息和资源。\n\n### 如何进行推理\n要使用 BiomedParse 进行推理，请使用提供的示例代码和资源：\n\n- **推理代码**：使用 `example_prediction.py` 中的示例推理脚本。\n- **示例图像**：加载并测试位于 `examples` 目录中的示例图像。\n- **模型配置**：模型设置在 `configs\u002Fbiomedparse_inference.yaml` 中定义。\n\n### 示例笔记本\n\n我们包含了一些示例笔记本，以指导您如何使用 BiomedParse 进行推理：\n\n- **RGB 推理示例**：请查看 `inference_examples_RGB.ipynb` 笔记本，其中包含使用普通 RGB 图像的示例，包括病理学、X 射线、超声、内窥镜、皮肤镜、OCT、眼底照相等。\n- **DICOM 推理示例**：请查看 `inference_examples_DICOM.ipynb` 笔记本，其中包含使用 DICOM 图像的示例。\n- **NIFTI 推理示例**：请查看 `inference_examples_NIFTI.ipynb` 笔记本，其中包含使用 NIFTI 图像切片的示例。\n- 您也可以尝试一个快速在线演示：[![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fmicrosoft\u002FBiomedParse\u002Fblob\u002Fmain\u002Finference_colab_demo.ipynb)\n\n### 模型设置\n```sh\nfrom PIL import Image\nimport torch\nfrom modeling.BaseModel import BaseModel\nfrom modeling import build_model\nfrom utilities.distributed import init_distributed\nfrom utilities.arguments import load_opt_from_config_files\nfrom utilities.constants import BIOMED_CLASSES\nfrom inference_utils.inference import interactive_infer_image\nfrom inference_utils.output_processing import check_mask_stats\nimport numpy as np\n\n# 构建模型配置\nopt = load_opt_from_config_files([\"configs\u002Fbiomedparse_inference.yaml\"])\nopt = init_distributed(opt)\n\n# 从预训练权重加载模型\n#pretrained_pth = 'pretrained\u002Fbiomed_parse.pt'\npretrained_pth = 'hf_hub:microsoft\u002FBiomedParse'\n\nmodel = BaseModel(opt, build_model(opt)).from_pretrained(pretrained_pth).eval().cuda()\nwith torch.no_grad():\n    model.model.sem_seg_head.predictor.lang_encoder.get_text_embeddings(BIOMED_CLASSES + [\"background\"], is_eval=True)\n```\n\n### 示例图像上的分割\n```sh\n# RGB 图像输入，形状为 (H, W, 3)。目前仅支持批量大小为 1。\nimage = Image.open('examples\u002FPart_1_516_pathology_breast.png', formats=['png'])\nimage = image.convert('RGB')\n# 文本提示，用于查询图像中的对象。可以提供多个提示。\nprompts = ['肿瘤细胞', '炎症细胞']\n\n# 加载真实标签掩码\ngt_masks = []\nfor prompt in prompts:\n    gt_mask = Image.open(f\"examples\u002FPart_1_516_pathology_breast_{prompt.replace(' ', '+')}.png\", formats=['png'])\n    gt_mask = 1*(np.array(gt_mask.convert('RGB'))[:,:,0] > 0)\n    gt_masks.append(gt_mask)\n\npred_mask = interactive_infer_image(model, image, prompts)\n\n# 预测与真实标签掩码对比\nfor i, pred in enumerate(pred_mask):\n    gt = gt_masks[i]\n    dice = (1*(pred>0.5) & gt).sum() * 2.0 \u002F (1*(pred>0.5).sum() + gt.sum())\n    print(f'{prompts[i]} 的 Dice 分数：{dice:.4f}')\n    check_mask_stats(image, pred_mask[i]*255, 'X-Ray-Chest', text_prompt[i])\n    print(f'{prompts[i]} 的 p 值：{p_value:.4f}')\n```\n\n\n检测和识别推理代码在 `inference_utils\u002Foutput_processing.py` 中提供。\n\n- `check_mask_stats()`：输出模型预测掩码的 p 值，用于检测。请参阅 `inference_examples_RGB.ipynb` 笔记本。\n- `combine_masks()`：将不重叠的预测结果合并。\n\n## 在您自己的数据上进行微调\n虽然 BiomedParse 可以接受任意图像和文本提示，但它只能合理地分割在预训练期间学过的对象！如果您有一个特定的分割任务，而最新检查点的表现不佳，以下是关于如何使用您自己的数据对其进行微调的说明。\n\n### 原始图像和标注\nBiomedParse 期望输入的图像和真实标签掩码为 1024x1024 的 PNG 格式。对于每个数据集，请按照以下格式存放原始图像和掩码文件：\n```\n├── biomedparse_datasets\n    ├── YOUR_DATASET_NAME\n        ├── train\n        ├── train_mask\n        ├── test\n        └── test_mask\n```\n每个文件夹应包含 .png 文件。掩码文件应为二值图像，其中像素值不为 0 表示前景区域。\n\n### 文件命名规范\n每个文件名都遵循一定的规范，格式如下：\n\n[IMAGE-NAME]\\_[MODALITY]\\_[SITE].png\n\n[IMAGE-NAME] 是针对单张图像的唯一字符串，格式不限。\n[MODALITY] 是模态名称，例如 “X-Ray”。\n[SITE] 是图像的解剖部位，例如 “chest”。\n\n一张图像可以关联多个掩码，分别对应图像中的多个目标。掩码文件的命名规范如下：\n\n[IMAGE-NAME]\\_[MODALITY]\\_[SITE]\\_[TARGET].png\n\n[IMAGE-NAME]、[MODALITY] 和 [SITE] 与图像文件名相同。\n[TARGET] 是目标名称，空格替换为 “+”。例如 “tube” 或 “chest+tube”。请确保 [TARGET] 中不出现下划线。\n\n### 生成包含文本提示的最终数据文件\n在 biomedparse_datasets\u002Fcreate-customer-datasets.py 中，指定 YOUR_DATASET_NAME。然后运行脚本：\n```\ncd biomedparse_datasets\npython create-customer-datasets.py\n```\n运行完成后，数据集文件夹应具有以下结构：\n```\n├── dataset_name\n        ├── train\n        ├── train_mask\n        ├── train.json\n        ├── test\n        ├── test_mask\n        └── test.json\n```\n\n### 注册您的数据集用于训练和评估\n在 datasets\u002Fregistration\u002Fregister_biomed_datasets.py 中，只需将 YOUR_DATASET_NAME 添加到数据集列表中即可。注册后的数据集即可添加到训练和评估配置文件 configs\u002Fbiomed_seg_lang_v1.yaml 中。您的训练数据集将被注册为 biomed_YOUR_DATASET_NAME_train，测试数据集则为 biomed_YOUR_DATASET_NAME_test。\n\n## 训练 BiomedParse\n要训练 BiomedParse 模型，请运行：\n\n```sh\nbash assets\u002Fscripts\u002Ftrain.sh\n```\n这将使用您在 configs\u002Fbiomed_seg_lang_v1.yaml 中指定的训练数据集继续训练模型。\n\n## 评估 BiomedParse\n要评估模型，请运行：\n```sh\nbash assets\u002Fscripts\u002Feval.sh\n```\n这将使用您在 configs\u002Fbiomed_seg_lang_v1.yaml 中指定的测试数据集继续评估模型。我们默认使用 BiomedParseData-Demo 数据集，您也可以在列表中添加其他数据集。\n\n\n## 引用\n如果您使用了代码、模型或数据，请引用我们的论文。\n\n```bibtex\n@article{zhao2025foundation,\n  title={A foundation model for joint segmentation, detection and recognition of biomedical objects across nine modalities},\n  author={Zhao, Theodore and Gu, Yu and Yang, Jianwei and Usuyama, Naoto and Lee, Ho Hin and Kiblawi, Sid and Naumann, Tristan and Gao, Jianfeng and Crabtree, Angela and Abel, Jacob and others},\n  journal={Nature methods},\n  volume={22},\n  number={1},\n  pages={166--176},\n  year={2025},\n  publisher={Nature Publishing Group US New York}\n}\n```\n\n如果您使用了 v2 版本的代码或模型，请同时引用 BoltzFormer 论文：\n```bibtex\n@inproceedings{zhao2025boltzmann,\n  title={Boltzmann Attention Sampling for Image Analysis with Small Objects},\n  author={Zhao, Theodore and Kiblawi, Sid and Usuyama, Naoto and Lee, Ho Hin and Preston, Sam and Poon, Hoifung and Wei, Mu},\n  booktitle={Proceedings of the Computer Vision and Pattern Recognition Conference},\n  pages={25950--25959},\n  year={2025}\n}\n```\n\n## 使用及许可声明\n本仓库中描述的模型仅供研究和开发使用。该模型并非用于临床决策或其他任何临床用途，其在临床应用中的性能尚未得到验证。您应对该模型的任何使用承担全部责任，包括将其集成到任何用于临床用途的产品中。","# BiomedParse v2 快速上手指南\n\nBiomedParse v2 是一个用于生物医学图像分析的通用基础模型，支持跨多种模态（CT、MRI、超声、PET、3D 显微镜等）的**分割**、**检测**和**识别**任务。v2 版本特别针对**3D 体积数据**进行了优化，采用 `BoltzFormer` 架构提升了小目标分割性能，并支持端到端的 3D 推理。\n\n> **注意**：如果您主要处理 2D 图像（如病理、眼底、皮肤镜等），建议使用 [v1 版本](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Ftree\u002Fmain)；若处理 3D 模态（CT, MRI, PET 等），请使用本指南介绍的 v2 版本。\n\n## 1. 环境准备\n\n### 系统要求\n- **操作系统**: Linux (推荐) 或 Windows\n- **Python**: 3.10.14\n- **GPU**: 支持 CUDA 的 NVIDIA 显卡（推荐 CUDA 12.4）\n- **内存**: 建议 16GB 以上，处理大体积 3D 数据时建议 32GB+\n\n### 前置依赖\n确保已安装 `conda` 或 `mamba`。国内用户推荐使用清华源或中科大源加速包下载。\n\n## 2. 安装步骤\n\n### 第一步：克隆仓库\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse.git\ncd BiomedParse\n```\n\n### 第二步：创建 Conda 环境\n```bash\nconda create -n biomedparse_v2 python=3.10.14\nconda activate biomedparse_v2\n```\n\n### 第三步：安装依赖库\n国内用户可先配置 pip 镜像源以加速安装：\n```bash\npip config set global.index-url https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n安装核心依赖（注意：原 requirements.txt 默认针对 cuda12.4，请根据实际环境调整）：\n```bash\npip install -r assets\u002Frequirements\u002Frequirements.txt\n\n# 安装额外必要组件\npip install azureml-automl-core\npip install opencv-python\npip install git+https:\u002F\u002Fgithub.com\u002Ffacebookresearch\u002Fdetectron2.git\n```\n\n> **提示**：如果 `detectron2` 编译失败，请确保已正确安装对应 CUDA 版本的 PyTorch 和 torchvision。\n\n### 第四步：下载模型权重\n您可以选择通过 Python API 或命令行下载预训练权重（`biomedparse_v2.ckpt`）。\n\n**方式 A：使用 Python 脚本下载（推荐）**\n```python\nfrom huggingface_hub import hf_hub_download\n\n# 下载检查点文件\nfile_path = hf_hub_download(\n    repo_id=\"microsoft\u002FBiomedParse\",\n    filename=\"biomedparse_v2.ckpt\"\n)\n\nprint(\"模型权重已下载至:\", file_path)\n```\n\n**方式 B：使用命令行直接下载**\n```bash\nwget https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse\u002Fresolve\u002Fmain\u002Fbiomedparse_v2.ckpt\n# 或者\ncurl -L -o biomedparse_v2.ckpt https:\u002F\u002Fhuggingface.co\u002Fmicrosoft\u002FBiomedParse\u002Fresolve\u002Fmain\u002Fbiomedparse_v2.ckpt\n```\n\n> **注意**：如果网络访问 HuggingFace 受限，请确保配置了代理或在代码中设置 `HF_ENDPOINT` 环境变量使用镜像站。若仓库为私有，需先运行 `huggingface-cli login`。\n\n## 3. 基本使用 (3D 推理示例)\n\nBiomedParse v2 以切片方式处理 3D 体积数据，并利用相邻切片上下文进行 RGB 编码推理。在使用前，请务必对图像进行**预处理**（见下文重要提示）。\n\n以下是一个完整的 3D CT 图像推理最小示例：\n\n```python\nimport numpy as np\nimport torch\nimport torch.nn.functional as F\nimport hydra\nfrom hydra import compose\nfrom hydra.core.global_hydra import GlobalHydra\n# 假设 utils 和 inference 模块已在路径中\nfrom utils import process_input, process_output, slice_nms\nfrom inference import postprocess, merge_multiclass_masks\nfrom huggingface_hub import hf_hub_download\n\n# 1. 设置设备\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\nprint(\"Using device:\", device)\n\n# 2. 初始化模型\nGlobalHydra.instance().clear()\nhydra.initialize(config_path=\"configs\u002Fmodel\", job_name=\"example_prediction\")\ncfg = compose(config_name=\"biomedparse_3D\")\nmodel = hydra.utils.instantiate(cfg, _convert_=\"object\")\n\n# 加载预训练权重\nmodel.load_pretrained(hf_hub_download(\n  repo_id=\"microsoft\u002FBiomedParse\", filename=\"biomedparse_v2.ckpt\"))\nmodel = model.to(device).eval()\n\n# 3. 准备输入数据 (示例使用 .npz 格式)\n# 请替换为您自己的预处理后的数据路径\nfile_path = \"examples\u002Fimgs\u002FCT_AMOS_amos_0018.npz\"\nnpz_data = np.load(file_path, allow_pickle=True)\nimgs = npz_data[\"imgs\"]\ntext_prompts = npz_data[\"text_prompts\"].item()\n\n# 构建文本提示 (例如: \"liver[SEP]kidney\")\nids = [int(_) for _ in text_prompts.keys() if _ != \"instance_label\"]\nids.sort()\ntext = \"[SEP]\".join([text_prompts[str(i)] for i in ids])\n\n# 预处理输入张量\nimgs, pad_width, padded_size, valid_axis = process_input(imgs, 512)\nimgs = imgs.to(device).int()\n\ninput_tensor = {\n    \"image\": imgs.unsqueeze(0),  # 增加 batch 维度\n    \"text\": [text],\n}\n\n# 4. 执行推理\nwith torch.no_grad():\n    output = model(input_tensor, mode=\"eval\", slice_batch_size=4)\n\n# 5. 后处理\nmask_preds = output[\"predictions\"][\"pred_gmasks\"]\n# 插值回原始分辨率\nmask_preds = F.interpolate(mask_preds, size=(512, 512), mode=\"bicubic\", align_corners=False, antialias=True)\n\n# 应用存在性检测和掩码合并\nmask_preds = postprocess(mask_preds, output[\"predictions\"][\"object_existence\"])\nmask_preds = merge_multiclass_masks(mask_preds, ids)\nmask_preds = process_output(mask_preds, pad_width, padded_size, valid_axis)\n\nprint(\"最终掩码形状:\", mask_preds.shape)\n```\n\n### ⚠️ 重要：数据预处理规范\n为了获得最佳效果，推理数据的预处理必须与训练时保持一致：\n1. **格式转换**：将所有图像转换为 `.npz` 格式。\n2. **强度归一化**：\n   - **CT 图像**：必须根据解剖部位使用特定的窗宽（Window Width）和窗位（Level）将 Hounsfield Units (HU) 归一化到 `[0, 255]`。\n     - 软组织: W:400, L:40\n     - 肺部: W:1500, L:-160\n     - 脑部: W:80, L:40\n     - 骨骼: W:1800, L:400\n   - **其他模态 (MRI, PET, 超声等)**：截取强度值的 0.5% 到 99.5% 分位数，然后线性重缩放到 `[0, 255]`。\n   - 若原始数据已在 `[0, 255]` 范围内，则无需此步骤。\n3. **尺寸调整**：代码中的 `process_input` 会自动处理填充和调整，但输入数据应保留原始的 3D 空间信息。\n\n更多详细示例请参考项目中的 `inference_example_3D.ipynb`。","某三甲医院影像科团队正致力于构建一套自动化系统，用于从海量 3D CT 和 MRI 扫描数据中精准定位并识别微小肿瘤病灶及周围解剖结构。\n\n### 没有 BiomedParse 时\n- **多模型堆砌繁琐**：研究人员需分别训练分割、检测和分类三个独立模型，代码维护复杂且推理流程冗长。\n- **微小病灶漏检率高**：传统架构难以捕捉 3D 体积数据中的细微特征，导致早期微小结节经常被忽略或误判。\n- **假阳性过滤困难**：模型常将正常组织误识别为病灶，后续必须编写额外的脚本进行统计检验（如 K-S 检验）来剔除假阳性结果。\n- **3D 推理效率低下**：缺乏端到端的体积推断能力，往往需要将 3D 数据切片处理后再重组，不仅耗时还容易丢失空间上下文信息。\n\n### 使用 BiomedParse 后\n- **统一架构高效集成**：BiomedParse 单个模型即可同时完成分割、检测和识别任务，大幅简化了部署流程并提升了开发效率。\n- **小目标检测显著提升**：得益于内置的 BoltzFormer 架构，BiomedParse 能精准捕捉微小病灶，显著降低了漏检率。\n- **内置假阳性抑制**：利用其独有的 ISD 模块，BiomedParse 在推理阶段自动判断物体是否存在，无需额外后处理即可有效过滤误报。\n- **原生 3D 端到端推断**：BiomedParse 支持直接对 3D  volumetric 数据进行推理，完整保留空间结构信息，将分析速度提升至秒级。\n\nBiomedParse 通过统一的 foundation model 架构，彻底解决了多模态 3D  biomedical 图像分析中流程割裂、小目标难识别及假阳性高的核心痛点。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmicrosoft_BiomedParse_797ca515.png","microsoft","Microsoft","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmicrosoft_4900709c.png","Open source projects and samples from Microsoft",null,"opensource@microsoft.com","OpenAtMicrosoft","https:\u002F\u002Fopensource.microsoft.com","https:\u002F\u002Fgithub.com\u002Fmicrosoft",[83,87,91,95,99],{"name":84,"color":85,"percentage":86},"Python","#3572A5",59.5,{"name":88,"color":89,"percentage":90},"Jupyter Notebook","#DA5B0B",30.5,{"name":92,"color":93,"percentage":94},"Cuda","#3A4E3A",8.9,{"name":96,"color":97,"percentage":98},"C++","#f34b7d",1,{"name":100,"color":101,"percentage":102},"Shell","#89e051",0.1,652,98,"2026-04-17T22:32:19","Apache-2.0","Linux","需要 NVIDIA GPU (CUDA 12.4)，支持端到端 3D 推理，显存需求未明确说明（建议大显存以处理 3D 体积数据）","未说明",{"notes":111,"python":112,"dependencies":113},"1. 该工具主要针对 3D 生物医学图像（CT, MRI, PET 等），v2 版本专为 3D 模态设计。\n2. 安装 detectron2 需要从 GitHub 源码安装。\n3. 推理前必须对图像进行特定的预处理：转换为 npz 格式并将强度范围归一化到 [0, 255]；CT 图像需根据解剖部位使用特定的窗宽窗位（如软组织 W:400, L:40）进行归一化。\n4. 模型权重可通过 HuggingFace Hub 下载或直接 wget 获取。\n5. 代码示例显示使用 hydra 进行配置管理，且依赖 azureml 相关组件进行评估。","3.10.14",[114,115,116,117,118,119,120,121],"torch","detectron2","opencv-python","azureml-automl-core","huggingface_hub","hydra-core","scikit-image","numpy",[15,123],"其他","2026-03-27T02:49:30.150509","2026-04-18T14:13:35.728899",[127,132,137,142,147,152,157],{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},39798,"运行 example_prediction.py 时遇到 mpi4py 导入错误或脚本卡住无输出，如何解决？","这个问题通常与 mpi4py 的安装或版本冲突有关。建议不要直接使用 requirements.txt 中的 mpi 依赖，而是按以下顺序手动安装：\n1. 先单独安装 mpi4py：`pip install mpi4py`\n2. 安装 PyTorch（根据 CUDA 版本选择）：`pip3 install torch torchvision`\n3. 最后安装其余依赖：`pip install -r assets\u002Frequirements\u002Frequirements.txt`\n如果仍然卡住，请检查 mpi4py 的版本（推荐 4.1.1），并确保没有混用不同来源的 MPI 库。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Fissues\u002F93",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},39799,"安装依赖时出现 'Failed to build installable wheels for mpi4py, detectron2' 错误怎么办？","detectron2 安装失败通常是因为 CUDA 版本与 PyTorch 版本不匹配。请尝试以下步骤：\n1. 确认你的 CUDA 版本（使用 `nvidia-smi`）。\n2. 根据 CUDA 版本重新安装 PyTorch，例如对于 CUDA 12.6 或 11.8：\n   `pip3 install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu126`\n   或\n   `pip3 install torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118`\n3. 确保 gcc\u002Fg++ 版本兼容（如 8.5.0）。\n4. 如果仍失败，尝试从头创建一个新的 conda 环境并按顺序安装所有依赖。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Fissues\u002F34",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},39800,"如何微调模型以检测新的对象类型（如病理图像中的损伤区域）？","要微调模型以支持新对象类型，需执行以下步骤：\n1. 在 `create-customer-datasets.py` 中设置 `targetpath = 'YOUR_DATASET_NAME'`。\n2. 在 `register_biomed_datasets.py` 中注册数据集：`datasets = ['YOUR_DATASET_NAME']` 和 `splits = ['train','test']`。\n3. 在配置文件 `biomed_seg_lang_v1.yaml` 中指定训练和测试集：`TRAIN: ['biomed_YOUR_DATASET_NAME_train']` 和 `TEST: ['biomed_YOUR_DATASET_NAME_test']`。\n4. 对于新对象类型，需在 `label_base.json` 文件中将新目标作为子类添加到现有类别下。\n5. 确保 JSON 文件格式正确，若克隆仓库后文件损坏，可参考 HuggingFace 上的示例数据集进行修复。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Fissues\u002F29",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},39801,"PanNuke 数据集中的掩码标签 ID 具体代表什么？该数据集是完整版还是部分版？","仓库中提供的 PanNuke 数据集是基于 Kaggle 版本处理后的完整数据集（processed version of all the data）。关于具体的标签 ID 对应关系，通常需要在数据集的文档或代码中的常量定义里查找，但维护者确认这是经过预处理的全量数据，而非子集。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Fissues\u002F35",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},39802,"inference_utils 目录下的 target_dist.json 文件有什么作用？其内容结构是怎样的？","target_dist.json 用于存储和分析预测结果的分布情况，特别是在评估无效掩码和有效掩码的 p-value 分布时。维护者说明：\n1. 该文件混合了不同模态的数据集。\n2. 无效掩码和有效掩码的数量不一定相等。\n3. 实验中并未针对特定对象类型优化固定的 p-value 阈值，而是展示了 p-value 的分布以及精度 - 召回曲线。\n如果你希望优化阈值，可以使用训练集或验证集来选择最佳阈值。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Fissues\u002F49",{"id":153,"question_zh":154,"answer_zh":155,"source_url":156},39803,"是否支持在实例分割数据上进行微调？还是仅支持语义分割？","BiomedParse 支持在实例分割数据上进行微调。用户只需按照自定义数据集注册流程，准备好包含实例分割标注的数据集，并在配置文件中正确注册即可。模型架构本身能够处理实例分割任务，无需额外添加适配器。如果遇到具体问题，建议参考官方文档中关于“注册数据集进行训练和评估”的部分。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Fissues\u002F20",{"id":158,"question_zh":159,"answer_zh":160,"source_url":161},39804,"运行 example_prediction.py 时应该使用什么命令？直接运行 python 脚本可以吗？","是的，可以直接使用 `python example_prediction.py` 运行。之前文档中可能提到了 mpiexec 或其他分布式命令，但现在加载逻辑已优化，不再强制依赖 git 或复杂的 MPI 启动命令。如果遇到问题，请确保已按正确顺序安装了 mpi4py 和 torch，并且没有使用过时的启动方式。维护者已将相关说明更新至 README 中。","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBiomedParse\u002Fissues\u002F32",[]]