Skip to content

docs: clarify ControlNet finetuning data prep (§4.3) + add data-prep …#39

Merged
zephyrie merged 8 commits into
NVIDIA-Medtech:mainfrom
Can-Zhao:docs/clarify-finetune-data-prep
Jun 12, 2026
Merged

docs: clarify ControlNet finetuning data prep (§4.3) + add data-prep …#39
zephyrie merged 8 commits into
NVIDIA-Medtech:mainfrom
Can-Zhao:docs/clarify-finetune-data-prep

Conversation

@Can-Zhao

Copy link
Copy Markdown
Contributor

…skill

Rewrite data/README.md §4.3 into clear steps and document how to derive the preprocessed files (image embedding, VISTA-3D pseudo labels, combined labels) from a user's own original image + mask. Add skills/finetune_data-prep.md covering the same flow, including remapping a new class onto any unclaimed label index (0-255). Fix two errors in the old text: the backwards fold comment (held-out fold = validation) and stale dataset paths (maisi/dataset -> datasets/).

Can-Zhao and others added 2 commits June 10, 2026 15:49
…skill

Rewrite data/README.md §4.3 into clear steps and document how to derive the
preprocessed files (image embedding, VISTA-3D pseudo labels, combined labels)
from a user's own original image + mask. Add skills/finetune_data-prep.md
covering the same flow, including remapping a new class onto any unclaimed
label index (0-255). Fix two errors in the old text: the backwards fold
comment (held-out fold = validation) and stale dataset paths (maisi/dataset
-> datasets/).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rename skills/finetune_data-prep.md -> controlnet_finetune_data-prep.md,
update the skill `name` field and the README link to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Can-Zhao Can-Zhao marked this pull request as ready for review June 10, 2026 22:56
@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR rewrites data/README.md §4.3 into structured sub-sections and adds a new skills/finetune_image-from-mask_data-prep.md skill file, together documenting the full pipeline for turning raw images + masks into the three preprocessed files the CT ControlNet training loop needs. It also fixes two pre-existing errors: the backwards fold comment (held-out fold = validation, not training) and stale maisi/dataset/ paths replaced with datasets/.

  • data/README.md gains a download block, a per-case file-layout diagram, a three-step derivation walkthrough (VAE embedding → NV-Segment pseudo labels → combined mask), and a corrected, annotated data-list JSON example.
  • skills/finetune_image-from-mask_data-prep.md (new) provides a self-contained step-by-step guide covering embeddings, body-envelope generation, label remapping onto any unclaimed index, fold splits, and weighted_loss_label configuration.

Confidence Score: 5/5

Documentation-only change with no impact on runnable code; safe to merge.

Both changed files are markdown documentation. The fold-semantics fix and path corrections are accurate and verified against the surrounding codebase. Cross-references to infer_image-from-mask.md resolve correctly. The one new finding is a // comment in a json fenced block that would break copy-paste into a config file, but it carries no runtime risk.

No files require special attention beyond the minor //-in-JSON note in skills/finetune_image-from-mask_data-prep.md.

Important Files Changed

Filename Overview
data/README.md Rewrites §4.3 into clear sub-sections: download, per-case layout, step-by-step derivation, and data-list JSON; fixes backwards fold comment and stale maisi/dataset → datasets/ paths. No functional code changes.
skills/finetune_image-from-mask_data-prep.md New skill doc covering end-to-end data prep for ControlNet finetuning; a // comment in a json fenced block is invalid JSON and will break config parsing if copy-pasted.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Original Image\n*.nii.gz] --> B[Step 1: VAE Encode\nscripts/diff_model_create_training_data.py\nautoencoder_v1.pt]
    A --> C[Step 2: NV-Segment\nexternal tool]
    B --> D[image_emb.nii.gz]
    C --> E[Organ labels only\nno body envelope]
    E --> F[add_body_envelope\nscripts.utils]
    F --> G[mask_pseudo_label.nii.gz\norgans + body 200]
    H[Original Mask\n*.nii.gz] --> I[Step 3a: remap_labels\nto MAISI indices]
    I --> J[remapped mask]
    G --> K[Step 3b: Overlay\nwrite remapped mask on top]
    J --> K
    K --> L[mask_combined_label.nii.gz]
    D --> M[JSON data list\nimage + label + spacing + fold]
    L --> M
    M --> N[scripts.train_controlnet\nControlNet finetuning]
Loading

Reviews (4): Last reviewed commit: "docs: fix markdownlint MD051/MD028 in fi..." | Re-trigger Greptile

Comment thread skills/finetune_image-from-mask_data-prep.md
Comment thread skills/finetune_image-from-mask_data-prep.md
Comment thread skills/finetune_image-from-mask_data-prep.md
Can-Zhao and others added 5 commits June 10, 2026 16:06
Document how to produce the body envelope (label 200): the segmenter never
emits it, so defer to Option A of infer_image-from-mask.md
(NV-Segment CT_BODY -> add_body_envelope) instead of duplicating it. Replace
all VISTA-3D references with NV-Segment in both the skill and README §4.3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The body-region one-hots are consumed only when include_body_region is true,
which is set in config_network_ddpm.json. rflow-ct (config_network_rflow.json)
sets it false and ignores the fields, so they can be omitted. Note this in the
JSON examples and field notes in both the skill and README §4.3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A new/unseen label is not mandatory — finetuning to a new site/dataset with
only existing MAISI classes follows the same pipeline. Reframe the skill intro,
description, and the weighted_loss section as new-class-only/optional.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
weighted_loss_label up-weights the L1 loss on any label index (e.g. a tumor),
new or existing — it is not required for adding a class and not new-class-only.
Decouple it from the label_dict.json rename in the skill and README §4.3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Can-Zhao

Can-Zhao commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@zephyrie Hi Michael, may I ask if you can help run the ci/cd test? I was removed from the maintainer...Thank you!!

@addsouza-nvidia

addsouza-nvidia commented Jun 11, 2026

Copy link
Copy Markdown

This update helps clarify creating data for fine-tuning the model. The original README missed critical information on how the embeddings, pseudo label and combined label is created from original dicom and label images

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zephyrie zephyrie merged commit ec8d146 into NVIDIA-Medtech:main Jun 12, 2026
1 check passed
@Can-Zhao Can-Zhao deleted the docs/clarify-finetune-data-prep branch June 12, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants