开始使用

脑肿瘤数据集

Open Brain Tumor Dataset In Colab

Ultralytics 脑肿瘤数据集是一个目标检测数据集,包含 1,115 张脑部 MRI 图像(994 张用于训练,121 张用于验证)和 1,180 个边界框,属于单一类别 tumor。每张图像包含 1 到 3 个肿瘤框。验证集包含 25 位已识别患者的图像,且没有任何已识别患者同时出现在两个数据集中。该数据集仅有 4.06 MB,体积小巧,适合用于学习和原型开发计算机视觉模型,以应用于医疗保健领域;但它并非经过临床验证的诊断资源。



观看: 使用 Ultralytics Platform 和 Ultralytics YOLO26 检测脑肿瘤 | 目标检测 🚀

数据集结构#

Ultralytics 脑肿瘤数据集包含 1,115 张脑部 MRI 图像和 1,180 个边界框,分为两个数据集划分,具体由 brain-tumor.yaml 配置定义:

划分图像边界框患者
训练9941,05795 位有 ID 的患者,另有 541 张没有患者 ID 的图像
验证12112325
总计1,1151,180

每张图像包含 1 到 3 个属于单一类别 tumor 的边界框,图像尺寸范围为 192x256 至 512x512 像素。该配置未定义单独的测试集。

验证集

验证集按患者划分。部分文件名以五位数患者 ID 开头:例如,00097_77.jpg 属于患者 00097。25 位此类患者的图像构成验证集,另外 95 位已识别患者的图像则属于训练集,因此没有任何已识别患者同时出现在两个数据集中。其余 541 张图像的文件名中没有患者 ID,且全部属于训练集。

首次训练时,数据集会自动从 Ultralytics GitHub 资源下载(4.06 MB),无需手动下载或准备。

更新较旧的本地副本

该数据集于 2026 年 11 月改为单一 tumor 类别。如果你的本地 brain-tumor/images/train 文件夹中有 893 张图像而非 994 张,请删除数据集目录中的 brain-tumor 文件夹(参见 yolo settings 中的 datasets_dir),并使用 pip install -U ultralytics 更新软件包。下一次训练时,系统会下载当前版本。

访问 Ultralytics Platform 上的脑肿瘤数据集,浏览带有标注叠加层的图像,在 Charts 选项卡中查看类别分布和边界框热力图,还可以克隆数据集,在云端训练自己的模型。

应用场景#

脑肿瘤检测模型可以定位脑部 MRI 图像中的肿瘤。Ultralytics 脑肿瘤数据集包含 1,115 张图像,下载大小为 4.06 MB,适用于:

  • 学习工作流程:在小型数据集上使用医学图像运行完整的训练、验证和预测流程。
  • 原型开发:在转向更大的临床数据集之前,构建并测试肿瘤定位流程。
  • 在已识别患者上评估:测量模型在 25 位验证集患者上的检测效果。由于 541 张训练图像没有患者 ID,因此无法排除这些图像与这些患者重叠的可能性。
  • 研究与教育:比较检测模型,并研究医学图像分析和放射学中的 AI。

使用此数据集训练的模型仅用于研究和教育,未经临床诊断验证。

数据集 YAML#

brain-tumor.yaml 配置定义了数据集路径、训练和验证图像文件夹、单一 tumor 类别以及下载 URL。标签采用 Ultralytics YOLO 格式。

ultralytics/cfg/datasets/brain-tumor.yaml
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license

# Brain-tumor dataset by Ultralytics
# Documentation: https://docs.ultralytics.com/datasets/detect/brain-tumor
# Example usage: yolo train data=brain-tumor.yaml
# parent
# ├── ultralytics
# └── datasets
#     └── brain-tumor ← downloads here (4.06 MB)

# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: brain-tumor # dataset root dir
train: images/train # train images (relative to 'path') 994 images
val: images/val # val images (relative to 'path') 121 images

# Classes
names:
  0: tumor

# Download script/URL (optional)
download: https://github.com/ultralytics/assets/releases/download/v0.0.0/brain-tumor.zip

用法#

如需在脑肿瘤数据集上以 640 的图像尺寸训练一个 YOLO26n 模型,训练 100 个周期,请使用下面的代码片段。

训练示例
from ultralytics import YOLO

# 加载模型
model = YOLO("yolo26n.pt")  # 加载预训练模型(推荐用于训练)

# 训练模型
results = model.train(data="brain-tumor.yaml", epochs=100, imgsz=640)
推理示例
from ultralytics import YOLO

# 加载模型
model = YOLO("path/to/best.pt")  # 加载经过脑肿瘤数据集微调的模型

# 使用模型进行推理
results = model.predict("https://ultralytics.com/assets/brain-tumor-sample.jpg")

示例图像和标注#

以下是 Ultralytics 脑肿瘤数据集中的示例图像及其标注:

Ultralytics 脑肿瘤数据集中带有肿瘤边界框标注的脑部 MRI 示例图像

  • 已标注图像:网格展示了 16 张训练图像,每张图像都用一个 tumor 边界框圈出病灶。数据集中肿瘤的大小、形状和位置各不相同,这有助于检测模型实现泛化。

引用与致谢#

该数据集采用 AGPL-3.0 许可证。

如果你在研究或开发工作中使用脑肿瘤数据集,请引用:

引用
@dataset{Ultralytics_Brain_Tumor_Dataset_2023,
    author = {Ultralytics},
    title = {Brain Tumor Detection Dataset},
    year = {2023},
    publisher = {Ultralytics},
    url = {https://docs.ultralytics.com/datasets/detect/brain-tumor}
}

常见问题#

  • Ultralytics 脑肿瘤数据集包含 1,115 张脑部 MRI 图像和 1 个类别 tumor:994 张训练图像及 1,057 个边界框,以及 121 张验证图像及 123 个边界框。每张图像都有 1 到 3 个边界框,且没有单独的测试集。有关数据集划分详情,请参阅数据集结构。

  • Ultralytics 脑肿瘤数据集包含脑部 MRI 图像,不包含 CT 扫描图像。图像尺寸范围为 192x256 至 512x512 像素,每张图像都采用 Ultralytics YOLO 格式标注了 1 到 3 个 tumor 边界框。

  • 不能。Ultralytics 脑肿瘤数据集不包含无肿瘤图像,也没有阴性类别。全部 1,115 张图像都包含 1 到 3 个 tumor 边界框,因此使用该数据集训练的模型学会的是肿瘤的位置,而不是扫描结果是否健康。使用此数据集训练的模型仅用于研究和教育,不用于临床诊断。

  • Ultralytics 脑肿瘤数据集按患者划分:121 张验证图像带有 25 位患者的 ID,且没有任何已识别患者同时出现在两个数据集中。患者通过文件名的五位数前缀识别,例如 00097_77.jpg。训练集包含另外 95 位已识别患者的图像,以及 541 张文件名中没有患者 ID 的图像。

  • 首次使用 data="brain-tumor.yaml" 训练时,Ultralytics 脑肿瘤数据集(4.06 MB)会自动从 Ultralytics GitHub 资源下载,无需手动下载。如果磁盘上已有包含 893 张训练图像的旧版本,请删除其中的 brain-tumor 文件夹,并先更新 ultralytics 软件包,以便下载当前的单类别版本。另一个小型医学影像数据集,请参阅医学药丸检测数据集。

  • 要在 Ultralytics 脑肿瘤数据集上训练 YOLO26,请将 data="brain-tumor.yaml" 传递给训练命令,数据集便会自动下载。以下示例以 640 的图像尺寸训练 YOLO26n 共 100 个 epoch:

    训练示例
    from ultralytics import YOLO
    
    # 加载模型
    model = YOLO("yolo26n.pt")  # 加载预训练模型(推荐用于训练)
    
    # 训练模型
    results = model.train(data="brain-tumor.yaml", epochs=100, imgsz=640)

    有关可用参数的详细列表,请参阅训练页面。

  • 要使用在 Ultralytics 脑肿瘤数据集上微调的 YOLO26 模型进行推理,请加载你的 best.pt 权重,并对脑部 MRI 图像调用predict。每个结果都包含带置信度分数的 tumor 边界框:

    推理示例
    from ultralytics import YOLO
    
    # 加载模型
    model = YOLO("path/to/best.pt")  # 加载经过脑肿瘤数据集微调的模型
    
    # 使用模型进行推理
    results = model.predict("https://ultralytics.com/assets/brain-tumor-sample.jpg")
  • Ultralytics 创建了 Ultralytics 脑肿瘤数据集,并根据 AGPL-3.0 许可证发布。

评论11

提出问题、分享结果,或帮助其他人。

    1. Paula DerrengerUltralytics(已编辑)

      Hey there! 😊 The easiest way is to train with data=brain-tumor.yaml, which downloads the dataset automatically the first time. To download it manually, use:

      wget https://github.com/ultralytics/assets/releases/download/v0.0.0/brain-tumor.zip
      unzip brain-tumor.zip -d path/to/destination

      Replace path/to/destination with the directory where you'd like the dataset stored. Once you have the dataset, you're all set to start training or inferencing with YOLO models on brain tumor images!

      Should you need further guidance, feel free to ask. Happy coding! 🚀

  1. G-qingqianGitHub

    Thank you for your reply. I noticed that in the original dataset, the images in the train folder do have ID prefixes, but the images in the val folder are all prefixed with val1_, making it impossible to distinguish which patient the data belongs to. Therefore, I cannot redivide the dataset. Could you please provide data with complete identifiers? ---- Replied Message ---- FromGlenn @.>Date1/18/2026 @.>@.>, @.>SubjectRe: [ultralytics/ultralytics] zh/datasets/detect/brain-tumor/ (Discussion #9988) The packaged brain-tumor dataset split is provided at the image-folder level and doesn’t ship patient IDs/metadata, so we can’t guarantee a patient-disjoint (no same patient in both train/val) split; if you need patient-wise separation, you’ll need to rebuild the split from patient identifiers and point a custom YAML to *.txt image lists (supported by Ultralytics YOLO), e.g. see the provided config in the Brain Tumor dataset docs and the brain-tumor.yaml in the repo.

    my-brain-tumor.yaml path: /data/brain-tumor train: splits/train.txt # one image path per line (ideally grouped by patient ID when you create it) val: splits/val.txt names: 0: negative 1: positive

    — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

    1. Glenn JocherUltralytics

      The packaged brain-tumor zip only includes image-level labels with anonymized filenames (no patient IDs/metadata), so we can’t provide “complete identifiers” or guarantee a patient-disjoint re-split; for patient-wise splitting you’ll need to rebuild from a source that includes patient IDs (e.g., your DICOM/NIfTI originals) and then generate train.txt/val.txt, and if you just need stronger evaluation without IDs you can use our K-Fold Cross Validation guide—please keep follow-ups here in the GitHub discussion (we can’t provide support over email/DM).

  2. G-qingqianGitHub

    Can your dataset ensure that the data are independently and identically distributed by patient? That is, there will be no data from the same patient in both the training set and the validation set.

    1. Glenn JocherUltralytics

      The packaged brain-tumor dataset split is provided at the image-folder level and doesn’t ship patient IDs/metadata, so we can’t guarantee a patient-disjoint (no same patient in both train/val) split; if you need patient-wise separation, you’ll need to rebuild the split from patient identifiers and point a custom YAML to *.txt image lists (supported by Ultralytics YOLO), e.g. see the provided config in the Brain Tumor dataset docs and the brain-tumor.yaml in the repo.

      # my-brain-tumor.yaml
      path: /data/brain-tumor
      train: splits/train.txt  # one image path per line (ideally grouped by patient ID when you create it)
      val: splits/val.txt
      names:
        0: negative
        1: positive
  3. pizzas17GitHub

    How could I download this dataset on COCO format or how could I convert it? (Since I wish to have an EDA on it

  4. xySun17GitHub

    How can i train the yoloV8 using this dataset without loading the pre-trained weights?

    1. Paula DerrengerUltralytics(已编辑)

      @xySun17 hello!

      To train YOLO26 without loading the pre-trained weights, you can initialize the model from scratch by specifying the model architecture file (e.g., yolo26n.yaml) instead of the pre-trained weights file. Here’s how you can do it:

      Python
      from ultralytics import YOLO
      
      # Load a model architecture without pre-trained weights
      model = YOLO("yolo26n.yaml")  # build a new model from YAML
      
      # Train the model
      results = model.train(data="brain-tumor.yaml", epochs=100, imgsz=640)
      CLI
      # Train from scratch using the model architecture file
      yolo detect train data=brain-tumor.yaml model=yolo26n.yaml epochs=100 imgsz=640

      This approach ensures that the model starts training with random weights rather than pre-trained ones. If you encounter any issues, please ensure you are using the latest version of the Ultralytics package and provide a minimum reproducible example if the problem persists. You can find more details on creating a reproducible example here.

      Feel free to reach out if you have any further questions. Happy training! 🚀

      1
    2. xySun17GitHub

      Thank you!! However, there is another problem, that is, why it says the path of dataset is not found? I already downloaded the dataset files and changed the path in "brain-tumor.yaml" file.

      The threw error was follows: "Dataset 'brain-tumor.yaml' images not found ⚠️, missing path '/valid/images' Note dataset download directory is '/home/ros/datasets'. You can update this in '/home/ros/.config/Ultralytics/settings.yaml'"

    3. Paula DerrengerUltralytics(已编辑)

      Hello @xySun17,

      Thank you for reaching out! It looks like the issue might be related to the dataset path configuration in your brain-tumor.yaml file. Here are a few steps to troubleshoot and resolve this:

      1. Verify Dataset Path: Ensure that the paths specified in your brain-tumor.yaml file correctly point to the locations of your dataset images. For example:

        path: /home/ros/datasets/brain-tumor
        train: images/train
        val: images/val
      2. Check Directory Structure: Confirm that the directory structure matches what is specified in the YAML file. The images/train and images/val directories should exist within /home/ros/datasets/brain-tumor.

      3. Update Configuration: If the dataset is located in a different directory, update the path in the YAML file accordingly. For instance, if your dataset is in /home/ros/my-datasets/brain-tumor, update the path to:

        path: /home/ros/my-datasets/brain-tumor
      4. Reproducible Example: If the issue persists, providing a minimum reproducible example can greatly help in diagnosing the problem. You can find guidance on creating a reproducible example here.

      5. Latest Version: Ensure you are using the latest version of the Ultralytics package. You can update it using:

        pip install --upgrade ultralytics

      Here’s an example of how your brain-tumor.yaml should look:

      # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
      # Brain-tumor dataset by Ultralytics
      # Documentation: https://docs.ultralytics.com/datasets/detect/brain-tumor/
      # Example usage: yolo train data=brain-tumor.yaml
      
      path: /home/ros/datasets/brain-tumor  # dataset root dir
      train: images/train  # train images (relative to 'path')
      val: images/val  # val images (relative to 'path')
      
      # Classes
      names:
        0: negative
        1: positive
      
      # Download script/URL (optional)
      download: https://github.com/ultralytics/assets/releases/download/v0.0.0/brain-tumor.zip

      If you follow these steps and still encounter issues, please share more details or any error messages you receive. This will help us assist you better.

      Best regards and happy coding! 🚀