Spaces:
Sleeping
Sleeping
Commit
·
f468cfb
1
Parent(s):
5e04242
Improve texts
Browse files- app.py +13 -7
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -7,14 +7,9 @@ import requests
|
|
| 7 |
import SimpleITK as sitk # noqa: N813
|
| 8 |
import spaces
|
| 9 |
import torch
|
| 10 |
-
from huggingface_hub import hf_hub_download
|
| 11 |
-
from monai.transforms import Compose, ScaleIntensityd, SpatialPadd
|
| 12 |
-
from tqdm import tqdm
|
| 13 |
-
|
| 14 |
from cinema import CineMA, ConvUNetR, ConvViT, heatmap_soft_argmax
|
| 15 |
from cinema.examples.cine_cmr import plot_cmr_views
|
| 16 |
from cinema.examples.inference.landmark_heatmap import (
|
| 17 |
-
plot_heatmaps,
|
| 18 |
plot_landmarks,
|
| 19 |
plot_lv,
|
| 20 |
)
|
|
@@ -34,6 +29,9 @@ from cinema.examples.inference.segmentation_sax import (
|
|
| 34 |
from cinema.examples.inference.segmentation_sax import (
|
| 35 |
plot_volume_changes as plot_volume_changes_sax,
|
| 36 |
)
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# cache directories
|
| 39 |
cache_dir = Path("/tmp/.cinema")
|
|
@@ -231,6 +229,8 @@ def mae_tab():
|
|
| 231 |
gr.Markdown(
|
| 232 |
"""
|
| 233 |
This page demonstrates the masking and reconstruction process of the masked autoencoder. The model was trained with a mask ratio of 0.75 over 74,000 studies.
|
|
|
|
|
|
|
| 234 |
"""
|
| 235 |
)
|
| 236 |
with gr.Row():
|
|
@@ -253,7 +253,7 @@ def mae_tab():
|
|
| 253 |
label="Mask ratio",
|
| 254 |
value=0.75,
|
| 255 |
)
|
| 256 |
-
run_button = gr.Button("Run
|
| 257 |
run_button.click(
|
| 258 |
fn=mae,
|
| 259 |
inputs=[image_id, mask_ratio],
|
|
@@ -345,6 +345,8 @@ def segmentation_sax_tab():
|
|
| 345 |
gr.Markdown(
|
| 346 |
"""
|
| 347 |
This page demonstrates the segmentation of cardiac structures in the short-axis (SAX) view.
|
|
|
|
|
|
|
| 348 |
"""
|
| 349 |
)
|
| 350 |
|
|
@@ -487,6 +489,8 @@ def segmentation_lax_tab():
|
|
| 487 |
gr.Markdown(
|
| 488 |
"""
|
| 489 |
This page demonstrates the segmentation of cardiac structures in the long-axis (LAX) four-chamber (4C) view.
|
|
|
|
|
|
|
| 490 |
"""
|
| 491 |
)
|
| 492 |
|
|
@@ -659,7 +663,9 @@ def landmark_tab():
|
|
| 659 |
with gr.Blocks() as landmark_interface:
|
| 660 |
gr.Markdown(
|
| 661 |
"""
|
| 662 |
-
This page demonstrates landmark localisation in the long-axis (LAX) two-chamber (2C) and four-chamber (4C) views
|
|
|
|
|
|
|
| 663 |
"""
|
| 664 |
)
|
| 665 |
|
|
|
|
| 7 |
import SimpleITK as sitk # noqa: N813
|
| 8 |
import spaces
|
| 9 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
from cinema import CineMA, ConvUNetR, ConvViT, heatmap_soft_argmax
|
| 11 |
from cinema.examples.cine_cmr import plot_cmr_views
|
| 12 |
from cinema.examples.inference.landmark_heatmap import (
|
|
|
|
| 13 |
plot_landmarks,
|
| 14 |
plot_lv,
|
| 15 |
)
|
|
|
|
| 29 |
from cinema.examples.inference.segmentation_sax import (
|
| 30 |
plot_volume_changes as plot_volume_changes_sax,
|
| 31 |
)
|
| 32 |
+
from huggingface_hub import hf_hub_download
|
| 33 |
+
from monai.transforms import Compose, ScaleIntensityd, SpatialPadd
|
| 34 |
+
from tqdm import tqdm
|
| 35 |
|
| 36 |
# cache directories
|
| 37 |
cache_dir = Path("/tmp/.cinema")
|
|
|
|
| 229 |
gr.Markdown(
|
| 230 |
"""
|
| 231 |
This page demonstrates the masking and reconstruction process of the masked autoencoder. The model was trained with a mask ratio of 0.75 over 74,000 studies.
|
| 232 |
+
|
| 233 |
+
Visualisation may take a few seconds as we download the model weights, process the data, and render the plots.
|
| 234 |
"""
|
| 235 |
)
|
| 236 |
with gr.Row():
|
|
|
|
| 253 |
label="Mask ratio",
|
| 254 |
value=0.75,
|
| 255 |
)
|
| 256 |
+
run_button = gr.Button("Run masked autoencoder", variant="primary")
|
| 257 |
run_button.click(
|
| 258 |
fn=mae,
|
| 259 |
inputs=[image_id, mask_ratio],
|
|
|
|
| 345 |
gr.Markdown(
|
| 346 |
"""
|
| 347 |
This page demonstrates the segmentation of cardiac structures in the short-axis (SAX) view.
|
| 348 |
+
|
| 349 |
+
Visualisation may take dozens of seconds to update as we download model checkpoints, process multiple time frames sequentially, and generate the final plots.
|
| 350 |
"""
|
| 351 |
)
|
| 352 |
|
|
|
|
| 489 |
gr.Markdown(
|
| 490 |
"""
|
| 491 |
This page demonstrates the segmentation of cardiac structures in the long-axis (LAX) four-chamber (4C) view.
|
| 492 |
+
|
| 493 |
+
Visualisation may take a few seconds to update as we download model checkpoints, process multiple time frames, and generate the final plots.
|
| 494 |
"""
|
| 495 |
)
|
| 496 |
|
|
|
|
| 663 |
with gr.Blocks() as landmark_interface:
|
| 664 |
gr.Markdown(
|
| 665 |
"""
|
| 666 |
+
This page demonstrates landmark localisation in the long-axis (LAX) two-chamber (2C) and four-chamber (4C) views.
|
| 667 |
+
|
| 668 |
+
Visualisation may take a few seconds to update as we download model checkpoints, process multiple time frames, and generate the final plots.
|
| 669 |
"""
|
| 670 |
)
|
| 671 |
|
requirements.txt
CHANGED
|
@@ -17,6 +17,6 @@ scikit-learn==1.6.1
|
|
| 17 |
scipy==1.15.2
|
| 18 |
spaces==0.36.0
|
| 19 |
timm==1.0.15
|
| 20 |
-
git+https://github.com/mathpluscode/CineMA@
|
| 21 |
--extra-index-url https://download.pytorch.org/whl/cu113
|
| 22 |
torch==2.5.1
|
|
|
|
| 17 |
scipy==1.15.2
|
| 18 |
spaces==0.36.0
|
| 19 |
timm==1.0.15
|
| 20 |
+
git+https://github.com/mathpluscode/CineMA@af1958f51e475d3d6658132c6a680d4fc4a10cac#egg=cinema
|
| 21 |
--extra-index-url https://download.pytorch.org/whl/cu113
|
| 22 |
torch==2.5.1
|