PartiNet_training / README.md
MihinP's picture
Add files using upload-large-folder tool
d59e731 verified
|
Raw History Blame Contribute Delete
9.89 kB
---
license: mit
pretty_name: PartiNet training data (denoised micrographs)
tags:
- cryo-em
- particle-picking
- object-detection
- yolo
- biology
size_categories:
- 1K<n<10K
---
# PartiNet training data: denoised micrographs with particle labels
This is the dataset used to train and evaluate the **PartiNet** cryo-EM particle picker. It holds 9,666 denoised micrographs and 2,704,505 particle boxes, in YOLO detection format with a single class, `particle`.
> **Citation:** manuscript in preparation; a reference will be added on publication.
## Splits
| Split | Micrographs | Particles | Size |
|---|---|---|---|
| train | 6,224 | 1,853,287 | 45 GB |
| val | 1,563 | 465,476 | 12 GB |
| test | 1,879 | 385,742 | 9.3 GB |
| **total** | **9,666** | **2,704,505** | **66 GB** |
- **train / val** is a random split, about 80/20, within each training source.
- **test** is 8 held-out sources. None of their micrographs appear in train or val, so test measures generalisation to unseen datasets.
## Layout
```
cryo_training.yaml YOLO dataset config (relative paths)
train.txt, val.txt, test.txt image lists, one ./images/<split>/<name>.png per line
images/{train,val,test}/<name>.png
labels/{train,val,test}/<name>.txt
```
Each image has a label file with the same stem. Micrograph filenames are the original names from each source dataset, with a `.png` extension.
### Images
- 8-bit greyscale PNG, at the full original micrograph size: between 3710 × 3838 and 7676 × 7420 px, depending on the detector.
- Each image is a motion-corrected micrograph that was denoised with PartiNet's own implementation of the CryoSegNet-style denoiser, then converted to 8 bit.
### Labels
Standard YOLO format, one particle per line:
```
<class> <x_center> <y_center> <width> <height>
0 0.385986328125 0.401611328125 0.0546875 0.0546875
```
The class is always `0` (`particle`). Coordinates are normalised to [0, 1] by the image width and height, with the origin at the top-left corner. Box sizes are fixed for each dataset and come from that dataset's particle diameter.
## Usage
### Download
```bash
pip install -U huggingface_hub
# everything (~66 GB)
hf download MihinP/PartiNet_training --repo-type dataset --local-dir PartiNet_training_data
# only the held-out test set
hf download MihinP/PartiNet_training --repo-type dataset \
--include "images/test/*" "labels/test/*" "test.txt" "cryo_training.yaml" \
--local-dir PartiNet_training_data
```
### Paths in `cryo_training.yaml`
The YOLOv7 loader in PartiNet does **not** read a `path:` key:
- `train`, `val` and `test` resolve against the directory you launch from.
- The `./images/...` entries inside each `.txt` list resolve against the folder that holds that list.
So either `cd` into the download folder before training (the shipped yaml then works as is), or edit the yaml to use absolute paths:
```yaml
train: /abs/path/to/PartiNet_training_data/train.txt
val: /abs/path/to/PartiNet_training_data/val.txt
test: /abs/path/to/PartiNet_training_data/test.txt
nc: 1
names: ["particle"]
```
Keep `images/` and `labels/` side by side. The loader finds each label by replacing `images/` with `labels/` in the image path.
## Training PartiNet
PartiNet is built on [DynamicDet](https://github.com/VDIGPKU/DynamicDet) and is trained in two steps:
1. **Step 1, detectors.** Trains the two cascaded YOLOv7 backbones and their detection heads.
2. **Step 2, adaptive router.** Starts from the step-1 checkpoint, freezes the detectors and trains only the router, which decides per micrograph whether the second, more expensive backbone is needed.
Install PartiNet first (see the [PartiNet repository](https://github.com/WEHI-ResearchComputing/PartiNet)), or use its container, for example `apptainer exec --nv -B /data oras://ghcr.io/wehi-researchcomputing/partinet:main-singularity partinet ...`. The commands below assume `partinet` is on your `PATH` and that you run them from the download folder.
```bash
cd PartiNet_training_data
```
### Step 1: detectors
```bash
partinet train step1 \
--backbone-detector yolov7-w6 \
--weight "" \
--data cryo_training.yaml \
--hyp scratch.p5 \
--epochs 100 \
--batch-size 16 \
--img-size 1280 1280 \
--workers 16 \
--device 0,1 \
--save_period 10 \
--project runs/step1 --name w6
```
- These are the settings used for the published step-1 models: YOLOv7-W6 backbone, 100 epochs, total batch 16 split across 2 GPUs, 1280 px input, `scratch.p5` hyperparameters.
- `--weight ""` trains from scratch. To fine-tune instead, pass a `.pt` checkpoint, for example the public PartiNet weights from [MihinP/PartiNet](https://huggingface.co/MihinP/PartiNet).
- `--batch-size` is the total across all GPUs. In our run, W6 at batch 16 on 2 GPUs reserved up to about 35 GB per GPU. Lower the batch size if you run out of GPU memory.
- Other backbones: `yolov7`, `yolov7x`, `yolov7-e6`, `yolov7-d6`, `yolov7-e6e`.
- The model is validated on `val` after every epoch. Outputs go to `runs/step1/w6/`: `weights/best.pt` (best on val), `weights/last.pt`, `results.txt` (per-epoch losses and val metrics), `opt.yaml` and `hyp.yaml`.
- To continue an interrupted run, use `--resume --resume-ckpt runs/step1/w6/weights/last.pt`.
### Step 2: adaptive router
```bash
partinet train step2 \
--backbone-detector yolov7-w6 \
--weight runs/step1/w6/weights/last.pt \
--data cryo_training.yaml \
--epochs 10 \
--batch-size 16 \
--img-size 1280 1280 \
--device 0,1 \
--project runs/step2 --name w6
```
- `--weight` must be a **step-1** checkpoint, and `--backbone-detector` must match the backbone used in step 1.
- The detector weights are frozen automatically, so only the router is trained. 10 epochs is the recommended setting.
- The final model is `runs/step2/w6/weights/last.pt`. Use it with `partinet detect`.
### Evaluate on the held-out test set
```bash
partinet test \
--backbone-detector yolov7-w6 \
--weight runs/step2/w6/weights/last.pt \
--data cryo_training.yaml \
--task test \
--img-size 1280 \
--conf-thres 0.001 --iou-thres 0.6 \
--device 0
```
`--task test` scores `test.txt`, the 8 held-out sources. Use `--task val` for the validation split. `--conf-thres 0.001 --iou-thres 0.6` gives standard mAP; the CLI defaults (0.3 / 0.5) are tuned for picking, not for mAP.
## Sources
Each row is a group of micrographs that share a filename pattern. The filename prefixes come from the original depositions.
### Train / val
| Filename prefix (example) | Train imgs | Train particles | Val imgs | Val particles | Size (px) |
|---|---|---|---|---|---|
| `FoilHole_*_Data_*_20191214_*-*` | 431 | 86,661 | 108 | 21,269 | 3838 × 3710 |
| `FoilHole_*_Data_*_20211215_*_EER` | 320 | 84,562 | 80 | 21,831 | 4096 × 4096 |
| `NNN` (e.g. `063`) | 240 | 21,058 | 60 | 5,333 | 4096 × 4096 |
| `20210903_*_patch_aligned_doseweighted` | 240 | 63,827 | 60 | 16,187 | 5760 × 4092 |
| `EMD-2984_*` | 240 | 28,196 | 60 | 7,022 | 7676 × 7420 |
| `INX6Ndelnano*` | 240 | 80,044 | 60 | 19,764 | 3710 × 3838 |
| `INX6hemiNano*` | 240 | 48,999 | 60 | 12,518 | 3710 × 3838 |
| `Px1Ndel2-20nano*` | 240 | 138,799 | 60 | 34,865 | 3710 × 3838 |
| `TAP_ICP47_*` | 240 | 36,682 | 60 | 8,681 | 7676 × 7420 |
| `ptsm0301_sub_*_DW` | 240 | 15,912 | 60 | 3,748 | 7676 × 7420 |
| `sb1_210512 pos *` | 240 | 25,557 | 60 | 6,362 | 4096 × 4096 |
| `16nov14y_16nov10d_*` | 240 | 184,978 | 60 | 46,373 | 3710 × 3838 |
| `18feb07c_b1g1_*` | 239 | 68,569 | 60 | 17,389 | 3838 × 3710 |
| `18jul30a_*-b-DW` | 239 | 80,806 | 60 | 20,972 | 3710 × 3838 |
| `FoilHole_*_Data_*_20140519_*_frames_SumCorr` | 239 | 10,137 | 60 | 2,545 | 4096 × 4096 |
| `PS0114.RAMP1-CGRP_*` | 238 | 55,367 | 60 | 13,645 | 5760 × 4092 |
| `17dec27a_aldolase_*` | 236 | 174,778 | 60 | 45,071 | 3838 × 3710 |
| `2021-10-03_*_210922_*` | 236 | 36,408 | 59 | 8,811 | 5760 × 4092 |
| `WTcomplex_GraFix_*_DW` | 236 | 50,073 | 60 | 12,420 | 3710 × 3838 |
| `atp_*_Apr13_*` | 236 | 46,400 | 60 | 12,331 | 5760 × 4092 |
| `Nuc197_scFv_*` | 236 | 60,320 | 59 | 14,900 | 7676 × 7420 |
| `20dec14b_Francesca_*` | 233 | 48,075 | 59 | 11,190 | 5760 × 4092 |
| `stack_*_2x_dfpt` | 232 | 152,395 | 59 | 38,003 | 3838 × 3710 |
| `20210209_262_*` | 227 | 206,384 | 53 | 48,280 | 5760 × 4092 |
| `JP_DJL_Rib_*` | 176 | 2,425 | 44 | 840 | 7676 × 7420 |
| `20210209_133-1_*` | 47 | 41,445 | 16 | 14,182 | 5760 × 4092 |
| `stack_*_2x_SumCorr` | 23 | 4,430 | 6 | 944 | 3838 × 3710 |
Groups that share a prefix but use slightly different filename templates are merged into one row above (`16nov14y_*`, `atp_*`, `Nuc197_*`, `20dec14b_Francesca_*`), so the table has 27 rows for 32 filename patterns.
### Test (held out)
| Filename prefix (example) | Images | Particles | Size (px) |
|---|---|---|---|
| `ja_*_May14_*` | 305 | 125,908 | 5760 × 4092 |
| `FoilHole_*_20200224_*_Fractions_patch_aligned` | 300 | 87,933 | 4096 × 4096 |
| `HCN1apo_*_2xaligned` | 300 | 39,352 | 3710 × 3838 |
| `18jam15a_*_ali_DW` | 295 | 15,894 | 3838 × 3710 |
| `stack_101016-2_*_2x_SumCorr_DW` | 295 | 56,394 | 3838 × 3710 |
| `Urease_*_Jan11_*` | 164 | 6,994 | 3838 × 3710 |
| `UreaseSingle_*_Jan13_*` | 136 | 3,876 | 3838 × 3710 |
| `Falcon_2012_06_12-*` | 84 | 49,391 | 4096 × 4096 |
## Notes
- The `train.cache` / `val.cache` files from the original training run are not included. YOLO rebuilds them on first use.
- The labels for the `18jam15a` test source look unreliable: every backbone we evaluated scores close to 0 on it. We kept it in the test set so the reported results are reproducible.
- The raw (non-denoised) micrographs are not included. They are available from the original public depositions.
## Related
- Benchmark cryo-EM maps: [MihinP/PartiNet_aux_maps](https://huggingface.co/datasets/MihinP/PartiNet_aux_maps)