8. Downloadsο
Everything you need to follow this tutorial is collected here: the three Python scripts, links to the pretrained model weights, and a small sample dataset to test on. Arrange them in the project layout below, then set the path block at the top of each script.
8.1. Scriptsο
Right-click β Save link asβ¦, or just click to download.
File |
Purpose |
Chapter |
|---|---|---|
Ejection-fraction prediction |
||
LV segmentation (videos + |
||
Optional |
Put all three in a scripts/ folder and configure the path block at the top of
each one.
8.2. Pretrained weightsο
Both prediction scripts load a checkpoint into WEIGHTS. Each file is larger
than 100 MB, so it is not stored in this repository β download the two
checkpoints from the
ModelFLOWs-cardiac releases page and
save them into EchoNet-dynamic/stats/. The script WEIGHTS paths already use
the exact release file names, so no renaming is needed:
File |
Model |
Loaded by |
Source |
|---|---|---|---|
|
R(2+1)D-18 (EF regression) |
|
|
|
DeepLabV3-ResNet50 (segmentation) |
|
Donβt mix up the two checkpoints
The names already match what the scripts expect β just drop both into stats/.
Loading the EF checkpoint into the segmentation script (or vice-versa) raises a
state_dict size-mismatch error, because the two heads have different output
shapes.
8.3. Sample data (demo)ο
A small demo dataset is bundled so you can test the scripts end-to-end before switching to your own data.
File |
Contents |
|---|---|
An apical-4-chamber echo video in |
Unzip it into the project root so it becomes the demo/ folder, with two
sub-folders, one per input type:
EchoNet-dynamic/
βββ demo/
βββ video/ 0X243FDE8AE0A05B6F.avi # the echo video
βββ npy/ frame_0000.npy β¦ (138) # single-frame arrays
The default INPUT_DIR is demo/video/, so both prediction scripts run on the
video straight away. To process the .npy frames instead, change INPUT_DIR to
demo/npy/ in PredictSegmentation.py:
EF prediction β
demo/video/(default);PredictEF.pyreads the.avi.Segmentation β video β
demo/video/(default); processed by Module B.Segmentation β
.npyframes β setINPUT_DIRtodemo/npy/.
Point at a sub-folder, not at the demo root
Both scripts scan only the top level of INPUT_DIR β sub-folders are not
searched. Pointing INPUT_DIR at demo/ itself would find nothing, because
the files live one level down in video/ and npy/. That is also why the video
and the frames are two separate runs.
8.4. Ground-truth labels (for validation)ο
To check the scripts quantitatively (see Results & Troubleshooting), use the two EchoNet-Dynamic label files. Both ship with the EchoNet-Dynamic dataset:
File |
Contents |
|---|---|
Per-video true |
|
|
LV boundary tracings ( |
The demo video is already labelled
Both label files include the bundled demo videoβs row (0X243FDE8AE0A05B6F, true
EF 29.9 %), so once you have them you can validate the EF by the demo without
downloading all 10,030 videos.
8.5. After downloadingο
Arrange the files into the project layout β
scripts/,stats/anddemo/side by side inside oneEchoNet-dynamic/folder:EchoNet-dynamic/ βββ scripts/ PredictSegmentation.py Β· PredictEF.py Β· CalculateStats.py βββ stats/ deeplabv3_resnet50_random.pt Β· r2plus1d_18_32_2_pretrained.pt βββ demo/ video/ Β· npy/
Open each script and set its path block. To use your own data, point
INPUT_DIRat it; results land indemo_output\.Keep the default
MEAN/STDfor EchoNet-style data, or recompute them withCalculateStats.py(see Normalization Statistics).Run a script β full walkthroughs are in Segmentation and EF Prediction.
Need the environment first? See Installation & Setup.