Spaces:
Runtime error
Runtime error
Commit History
-
Name mask classes from the request, not the canonical label table
The legend showed "label 2" where hepatic tumor should be. The cause is worse than a missing name: the saved CT mask does not use canonical 132-class IDs at all. Upstream's filter_mask_with_organs (scripts/sample_mask.py:154) rewrites each requested organ to its 1-based position in the request: for i in range(len(anatomy_list)): combine_label[combine_label == anatomy_list[i]] = -(i + 1) So [liver, hepatic tumor, spleen, gallbladder] yields mask values 1..4 in that order. Naming those through label_dict.json happened to be right for liver and spleen and wrong for everything else -- "hepatic tumor" landed on dummy1 and rendered as a placeholder, while gallbladder was confidently displayed as "pancreas". Silent mislabelling is the real defect here; the placeholder is just the visible symptom. Every preset was affected: Full chest 5/5 wrong (all five lung lobes shown as liver/spleen/pancreas/kidney), Whole abdomen 9/10, Pelvis organs 3/3, Liver + lesion 2/4. GenerationResul…ca3f97e
-
Move CPU work off the GPU, and log phase timings
The logs showed a CT run writing its NIfTI output ~10-15s before the image appeared. That gap was the mask label scan (nibabel + np.unique over the whole volume) and the viewer's base64 encode of both the image and mask — neither of which touches CUDA, but both of which ran inside the @spaces.GPU function and so were billed against the ZeroGPU allocation. Split for all three models. The decorated function now does inference only and hands the result to a gr.State; a following .then() does the label scan and the viewer encode on CPU. CT additionally gains generate(scan_labels=False) so the label pass can be deferred, and resolve_anatomy_labels() to run it afterwards. Added utils/timing.py: a nesting phase() context manager and a Stopwatch, all output prefixed [nv-generate] so it greps cleanly out of Gradio/MONAI/tqdm noise. Instrumented startup (clone, per-model prefetch, mask extraction, UI build) and generation (inference, label scan, viewer encode with payload size). A run now read…261940d -
Open each workspace on a default quick preset
CT defaults to "Liver + lesion", MR to "T1 brain", MR-Brain to "T1 whole brain" (which already matched, now made explicit). Controls read their initial values from the preset dicts via a new by_label() helper rather than duplicating literals, so the on-load state and the preset button cannot drift apart. by_label raises on an unknown label, so renaming a preset fails at import instead of silently leaving a stale default. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>52a231e
-
Move Quick Presets to the top of the controls sidebar
Quick Presets sat just above the Generate button — the last thing users saw, after they'd already configured everything by hand. Move it to the top of the controls column on all three workspaces so it's the first thing visible, encouraging a preset-first flow. New order per workspace: CT : Quick presets → Conditioning → Geometry → Diffusion → Generate MR : Quick presets → Conditioning → Geometry → Diffusion → Generate MR Brain : Quick presets → Contrast → Geometry → Diffusion → Generate The click-handler bindings at the end of build() still reference `sample_btns` correctly — it's just defined earlier in the column now. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>7fb7cc3 -
Default MR CFG guidance to 10
Changes the MR workspace CFG slider default from 15.0 to 10.0, matching the MR-Brain workspace (already 10.0). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>407e4a9 -
Make the Seed input compact like the other number boxes
Seed is a standalone gr.Number, so it rendered a full-width, tall input (~173x38) while every other number box in the panel is a compact slider number box (~74-88 x 22). Gave the Seed gr.Number an elem_classes ("seed-field") in all three workspaces and constrained its input to max-width 88px / height 22px / 12px font — now 88x22, matching the steps and spacing boxes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>3188a6e -
Flat-matte Generate button, fix hover, FOV-based MR presets
1. Generate button — was a green gradient (#7fc003 -> var(--green)) with glossy inset highlights + a green glow shadow; in light mode var(--green) is the deeper #5d9400 so the gradient was pronounced. Now a flat solid #76b900 with no gradient and no shadow — matte, and pixel-identical in light and dark (fixed hex, not the theme token). 2. Hover was unreadable in dark. Root cause: every .primary-cta state rule used the descendant selector `.primary-cta button`, but Gradio puts the class on the <button> itself — so :hover/:active/:disabled never matched. On hover, `.controls button:hover` took over and set the background to var(--pill-hover-bg) = transparent in dark, revealing the navy panel behind the black text. Rewrote every state to `button.primary-cta`, and excluded .primary-cta from the `.controls button:hover` chip rule. Hover is now a flat brighter green (#84cc00) with readable dark text. 3. MR quick presets — replaced with the three highest-vol…e7c2ab6
-
UI polish: spec banner color, control alignment, presets, card hover
Five fixes from the post-review feedback; all surface-level, dark and light stay consistent. 1. Spec banner — the model-page spec keys (.ws-fact-k) were flat gray; now tinted with the page accent (CT green / MR blue / MR-Brain purple) and bumped to 600 weight so they read as structured data. 2. Controls left edge — text inputs, field labels and the checkbox sat ~12px right of the pill rows and section headers, because the Gradio per-field .block wrapper carries 12px horizontal padding. Zeroed .controls .block left/right padding so every control shares the panel's content-left edge. 3. Pill text centering — Gradio's ml-2 utility put an 8px margin-left on the pill label span, shoving body-region / voxel pill text off-centre (23px vs 15px). Added margin:0 to the pill span rule; now 15/15. 4. Quick presets — replaced the thin 1-2 organ CT presets with four meaningful ones: "Whole abdomen" (10 abdominal organs), "Full chest" (all 5 lung lobes), "Liver + les…95b6812 -
Add adaptive clinical dual-theme (light + dark)
Replaces the force-dark hack with a real adaptive dual-theme that follows the visitor's OS / HF Spaces preference. - Tokenize every color in the CSS block: ~25 existing vars kept, ~20 new semantic tokens added for previously-hardcoded literals. Accent-tinted fills now use color-mix() against an accent token, which resolves pixel-exact in dark (e.g. --green #76b900 == rgb(118,185,0)). - Define two token blocks mirroring Gradio's own selectors: :root carries the new light "clinical blue" palette; :root.dark, :root .dark carries the dark "MAISI Console" palette (values copied verbatim, so dark mode is unchanged). Gradio toggles the .dark class from the user preference. - The niivue viewer surface and its empty-state placeholder stay dark in both themes (radiology/PACS convention); their colors are not tokenized. - Modality dots (.ws-dot) in the three workspaces now use var(--ct/mr/mrb) so they pick up the deepened light-mode modality colors. - Remove _all_dark_theme(); us…2e66cee
-
Initial commit: NV-Generate Gradio showcase
A Hugging Face Spaces app that surfaces NVIDIA Medtech's three open-weight 3D medical image generators (CT, MR, MR Brain) under one console-style UI, all running the latest MAISI-v2 rectified-flow variants. Architecture ============ - app.py — Gradio Blocks entrypoint. Hero card landing → per-model workspace switched via gr.Group visibility. Auto-clones the NV-Generate-CTMR upstream repo on first run so the same flow works locally and on HF Spaces. - pipelines/ base.py — GenerationRequest / GenerationResult dataclasses. _runner.py — Shared driver: chdir into upstream, write modified configs into configs/_temp/, invoke scripts.diff_model_infer or scripts.inference, harvest the resulting NIfTI(s). ct.py — Paired image + 132-class mask (rflow-ct). mr.py — Multi-contrast MR image-only (rflow-mr). mr_brain.py — Brain MR multi-sequence (rflow-mr-brain). - viewer/ niivue_embed.py — Render…ab1db83