Create README_Brain-Tumor_MedThinkSeg.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125# Brain-Tumor (Kaggle “Brain Tumor Image DataSet : Semantic Segmentation”) — packaged in `saiteja33/MedThink-Seg/Brain-Tumor`
This README documents:1) **The original Kaggle Brain Tumor Image DataSet : Semantic Segmentation** (what it contains, size, and original structure), and 2) **How it is organized inside this Hugging Face repo** (`saiteja33/MedThink-Seg`, under the `Brain-Tumor/` directory).
---
## 1) Original dataset (source)
**Original Kaggle dataset:** https://www.kaggle.com/datasets/pkdarabi/brain-tumor-image-dataset-semantic-segmentation
**Creator (as cited in dataset cards mirroring the Kaggle release):** Peyman Darabi (Aug 2023)
### What kind of images are included?- **Modality:** Brain **MRI** images for tumor region analysis.- **Image format & size (commonly reported for this Kaggle release):** - **JPEG** images - **640 × 640** resolution- **Classes:** 2 classes: - **Tumor** - **Non-tumor / Normal**
### Dataset size and countsA widely-used mirror of this Kaggle dataset reports:- **Total images:** **2,146**- **Splits:** - **Train:** 1,502 - **Validation:** 429 - **Test:** 215
> Note: The original Kaggle page is sometimes hard to scrape automatically; the counts above match publicly available mirrors of the Kaggle dataset.
### Labels and annotations (original)The original release is commonly distributed as **COCO-style annotations**, including:- **Bounding boxes** (`bbox`)- **Polygon segmentation coordinates** (`segmentation`)
Some downstream analyses report that many “segmentations” are effectively **rectangular polygons** (i.e., bounding boxes), so this dataset may behave more like a detection dataset unless masks are rasterized carefully.
### Original naming convention (examples)Mirrors of the dataset show filenames like:- `2256_jpg.rf.<hash>.jpg`
(Your copy may preserve these names.)
---
## 2) Organization inside this Hugging Face repo (`saiteja33/MedThink-Seg`)
**HF path:** `Brain-Tumor/` **Repo UI size (shown in HF browser):** ~**466 MB**
This packaging contains **only images and masks** (no separate `normal/` folder).
### Directory structure (this repo)```Brain-Tumor/├─ images/ # MRI images└─ masks/ # segmentation masks (paired with images/)```
### Pairing rule- Each file in `Brain-Tumor/images/` has a corresponding mask in `Brain-Tumor/masks/`.- **Filename matching:** mask filename matches the image filename (same base name). Example (conceptual): - `images/<name>.jpg` ↔ `masks/<name>.png` (or same extension if you kept it consistent)
### Mask format (practical note)- If masks were rasterized from COCO polygons, they are typically **binary** masks: - background = 0 - tumor = 1 (or 255)- Verify a few masks to confirm pixel values before training.
---
## How to download / use (recommended)
### A) Download only `Brain-Tumor/` from this HF repo```pythonfrom huggingface_hub import snapshot_download
local_dir = snapshot_download( repo_id="saiteja33/MedThink-Seg", repo_type="dataset", allow_patterns=["Brain-Tumor/**"], # only pull Brain-Tumor subdir)print(local_dir)```
### B) Create (image, mask) pairs```pythonfrom pathlib import Path
root = Path(local_dir) / "Brain-Tumor"img_dir = root / "images"msk_dir = root / "masks"
images = sorted(list(img_dir.glob("*")))pairs = [(p, msk_dir / p.name) for p in images]
missing = [p.name for p, m in pairs if not m.exists()]print("num_images:", len(images))print("missing_masks:", len(missing))print("example_pair:", pairs[0] if pairs else None)```
### C) Load with 🤗 Datasets (images only)```pythonfrom datasets import load_dataset
ds_imgs = load_dataset("imagefolder", data_dir=str(img_dir))print(ds_imgs)```
(For segmentation training, most pipelines keep pairs via the folder structure as in **B**.)
---
## CitationIf you use this dataset, cite the Kaggle record:
- Peyman Darabi. *Brain Tumor Image DataSet : Semantic Segmentation.* Kaggle Dataset. https://www.kaggle.com/datasets/pkdarabi/brain-tumor-image-dataset-semantic-segmentationBrain-Tumor/README_Brain-Tumor_MedThinkSeg.mdAdded+125