VBoussot commited on
Commit
0d472a8
·
1 Parent(s): dbda56b

Move input normalization to models and make layer selection part of forward()

Browse files

The C++ wrapper inspects the TorchScript forward() schema and builds the
argument list accordingly, ensuring backward compatibility with legacy models
(forward(input) or forward(input, layers)) while supporting the new extended
signature:

forward(input, layersCount, imageStats, imageDirection)

This view is limited to 50 files because it contains too many changes.   See raw diff
Anatomix/Anatomix.pt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:82163de6a24f574e6f131ceb7c3de42e06efe355513c366f96f213f6efa70de9
3
- size 23736761
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:444a54b4a6c8a676a6678698208c7da88b90c101fd4ac9d79080f84155fca71e
3
+ size 23739789
DinoV2/Small_1_Layers.pt → Dino/DinoV2_Small.pt RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e4184f7e5bbfeaecef1a6f6758a27cc6e85b83db882e45e337e8e9779607c337
3
- size 88571783
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19d8135cd3f80b0f89c2c4362cd3f00efc522f74478cec48658b2ad4f3f94cb4
3
+ size 88553081
TS/M291_3_Layers.pt → MIND/R1D1_2D.pt RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b9a08d69bf172473b12e3196ea2228be68a5699217db76949c9f938b30fad8dc
3
- size 3467627
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:417dce1196e50984ab04010a239b0b163b843866ce19f1b1b3a1f7980d38a35b
3
+ size 10435
MIND/{R2D2.pt → R1D1_3D.pt} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3164793db0a86c3e49659ccd859776778dcdf9756b83d29bc4c22df092439fff
3
- size 13084
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b85de8a8d7ab854c327b271e44aaf7edc7bb4e2bc9bb3c7022fd7bad7c22966
3
+ size 12867
MIND/{R1D1.pt → R1D2_2D.pt} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ed0b9267572f30acb2c870a1d473053c55ff9811cb899c9eb353bfec2a396128
3
- size 12710
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0647e94dddb0d621a800721245c450c667d006cff4edc10de74bbea295ddb1f
3
+ size 12561
MIND/{R1D2.pt → R1D2_3D.pt} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5c1a372427d8c77be0724198f51daca5cb98984910632c75497386e158dc90cf
3
- size 13078
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fac746b8d5a29591ccf49da8a91cb860fcfc12fb1f83d7c629caaf5c4a2399e8
3
+ size 15057
MIND/{R2D1.pt → R2D1_2D.pt} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1b17e6edbc65dff3a08de7ec244a13110c62c49c7025352c01b5ec03c0c269ca
3
- size 13084
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ee575def3565ece4ef91ab84ebb10d0f32047aee03dfeba811ff9d45ec27615
3
+ size 12589
MIND/R2D1_3D.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5397fc4fac505027032320833a0cbe9643415f9914d3c1d7dbbe62f70d4748be
3
+ size 14893
MIND/R2D2_2D.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:220e29c10b739f1cb5e1ffe95792542f7aa1ef3a9432223d91a13fd98bacab0a
3
+ size 11527
MIND/R2D2_3D.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:521ab3054daa2676947586760136118f708de16b6ecabc207f03adf62e077dce
3
+ size 13895
MRSeg/MRSeg.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b9f8a861ce845d749288501eecabbd99207eb070d163a1ce5b00abd208f3b2e
3
+ size 123253637
MRSeg/MRSeg_1_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:1f820151c47c7b100ced1034f5cc8bd07685087369b32012cbaa4332b6f72847
3
- size 129818
 
 
 
 
MRSeg/MRSeg_2_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:137dacac901be2799f54c934099e2a71ea24cdf570f1212bff81f24beee2f456
3
- size 804916
 
 
 
 
MRSeg/MRSeg_3_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:431763727cf7fb15b593b87f777b0aae7856f536e9d7cc048afc18d4caa1b250
3
- size 3472016
 
 
 
 
MRSeg/MRSeg_4_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:203dd7752a1420f56f6b43581e4d2464defeb38fc0cbeb69cda93ab07b25fc37
3
- size 14104882
 
 
 
 
MRSeg/MRSeg_5_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0d0aad9e583ead9a834447dfcb569344f9639cd45e45cbf35c14459d961c8cc1
3
- size 34029078
 
 
 
 
MRSeg/MRSeg_6_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:170074826847d313f51056b0fdced6f685c3a3204eb19935e33d325f314e174d
3
- size 56160378
 
 
 
 
MRSeg/MRSeg_7_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9caf85fb9a8b1183037cf323962b31cebc15988f5a3890074cc0ef82838d20d4
3
- size 123250358
 
 
 
 
MRSeg/MRSeg_8_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:434aed551ee2854bd7284d3f620af329b3f57499cb5988574d1dfea65a92d0f3
3
- size 123260342
 
 
 
 
README.md CHANGED
@@ -31,11 +31,12 @@ This repository also includes example parameter maps, TorchScript model handling
31
  The TorchScript models provided in this repository were exported from publicly available pretrained networks. These include:
32
 
33
  - **TotalSegmentator (TS)** — U-Net models trained for full-body anatomical segmentation
 
34
  - **Segment Anything 2.1 (SAM2.1)** — Foundation model for segmentation on natural images
35
  - **DINOv2** — Self-supervised vision transformer trained on diverse datasets
36
  - **Anatomix** — Transformer-based model with anatomical priors for medical images
37
 
38
- Each model provides multiple feature extraction layers, which can be selected independently using the corresponding model l_Layers. This can be configured through the LayerMask parameter in the IMPACT configuration.
39
 
40
  In addition, the repository also includes:
41
 
@@ -44,20 +45,11 @@ In addition, the repository also includes:
44
 
45
  | Model | Specialization | Paper / Reference | Field of View | License | Preprocessing |
46
  |----------------|---------------------------------------|-------------------------------------------------------------|------------------------|--------------|---------------|
47
- | **MIND** | Handcrafted descriptor | [Heinrich et al., 2012](https://doi.org/10.1016/j.media.2012.05.008) | `2*r*d + 1` (r: radius, d: dilation) | Apache 2.0 | None |
48
  | **SAM2.1** | General segmentation (natural images) | [Ravi et al., 2023](https://arxiv.org/abs/2408.00714) | 29 | Apache 2.0 | Normalize intensities to [0, 1], then standardize with mean 0.485 and std 0.229 |
49
- | **TS Models** | CT/MRI segmentation | [Wasserthal et al., 2022](https://arxiv.org/abs/2208.05868) | `2^l + 3` (l: layer number) | Apache 2.0 | Canonical orientation for all models. For MRI models (e.g., TS/M730–M733), standardize intensities to zero mean and unit variance. For CT models (e.g., TS/M258, TS/M291), clip intensities to [-1024, 276] HU, then normalize by centering at -370 HU and scaling by 436.6.|
 
50
  | **Anatomix** | Anatomy-aware transformer encoder | [Dey et al., 2024](https://arxiv.org/abs/2411.02372) | Global(Static mode) | MIT | Normalize intensities to [0, 1] |
51
  | **DINOv2** | Self-supervised vision transformer | [Oquab et al., 2023](https://arxiv.org/abs/2304.07193) | 14 | Apache 2.0 | Normalize intensities to [0, 1], then standardize with mean 0.485 and std 0.229 |
52
 
53
-
54
- ---
55
-
56
- ### 🔍 TS Model Variants
57
-
58
- **TS Models** refer to the following TotalSegmentator-derived TorchScript models:
59
- `M258, M291, M293, M294, M295, M297, M298, M730, M731, M732, M733, M850, M851`
60
-
61
- Each model is specialized for a specific anatomical structure or resolution (e.g., 3mm / 6mm) and shares the same encoder-decoder architecture.
62
-
63
  ---
 
31
  The TorchScript models provided in this repository were exported from publicly available pretrained networks. These include:
32
 
33
  - **TotalSegmentator (TS)** — U-Net models trained for full-body anatomical segmentation
34
+ - **MRSegmentator (MRSeg)** — U-Net models trained for full-body anatomical segmentation in MRI and CT
35
  - **Segment Anything 2.1 (SAM2.1)** — Foundation model for segmentation on natural images
36
  - **DINOv2** — Self-supervised vision transformer trained on diverse datasets
37
  - **Anatomix** — Transformer-based model with anatomical priors for medical images
38
 
39
+ Each model provides multiple feature extraction layers. This can be configured through the LayerMask parameter in the IMPACT configuration.
40
 
41
  In addition, the repository also includes:
42
 
 
45
 
46
  | Model | Specialization | Paper / Reference | Field of View | License | Preprocessing |
47
  |----------------|---------------------------------------|-------------------------------------------------------------|------------------------|--------------|---------------|
48
+ | **MIND** | Handcrafted descriptor | [Heinrich et al., 2012](https://doi.org/10.1016/j.media.2012.05.008) | `2*r*d + 1` (r: radius, d: dilation) | Apache 2.0 | Normalize intensities to [0, 1] |
49
  | **SAM2.1** | General segmentation (natural images) | [Ravi et al., 2023](https://arxiv.org/abs/2408.00714) | 29 | Apache 2.0 | Normalize intensities to [0, 1], then standardize with mean 0.485 and std 0.229 |
50
+ | **TS Models** | CT/MRI segmentation | [Wasserthal et al., 2022](https://arxiv.org/abs/2208.05868) | `2^l + 3` (l: layer number) | Apache 2.0 | Canonical orientation for all models. For MRI models (e.g., TS/M730–M733-M850–M853), standardize intensities to zero mean and unit variance. For CT models (e.g., TS/M258, TS/M291), clip intensities + normalize model dependant |
51
+ | **MRSegmentator** | CT/MRI segmentation | [Häntze et al., 2024](https://arxiv.org/abs/2405.06463) | `2^l + 3` (l: layer number) | Apache 2.0 | Standardize intensities to zero mean and unit variance.|
52
  | **Anatomix** | Anatomy-aware transformer encoder | [Dey et al., 2024](https://arxiv.org/abs/2411.02372) | Global(Static mode) | MIT | Normalize intensities to [0, 1] |
53
  | **DINOv2** | Self-supervised vision transformer | [Oquab et al., 2023](https://arxiv.org/abs/2304.07193) | 14 | Apache 2.0 | Normalize intensities to [0, 1], then standardize with mean 0.485 and std 0.229 |
54
 
 
 
 
 
 
 
 
 
 
 
55
  ---
SAM2.1/SAM2.1_Small.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c32287f87b945c24f078d1919cb1c392b9bfad2bd4ff435f7cdba7fbdfffb6f
3
+ size 135968194
SAM2.1/SAM2.1_Tiny.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd01ddd957c89fd78c73d930eadd64d2339bcbad6c265a76e236f584cd801b3f
3
+ size 107558543
SAM2.1/Small_1_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c388816a1b741008e429696714f62fdf3e5d66fdffcddcb80156a9d8473db696
3
- size 136038294
 
 
 
 
SAM2.1/Small_2_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:723651617e221fb547049bb3c57f7200fa6be6521f84712e1ee33ff62e38c1bc
3
- size 136053276
 
 
 
 
SAM2.1/Small_3_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d35d8f5ca180a6ccb484895716dbca5f53e99ad2ec9bc855a66b93377506f8de
3
- size 136123944
 
 
 
 
SAM2.1/Small_4_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b6a0db477f0c1d4b5a8463eabdec53567e619f08b421200c4045ec212491963d
3
- size 136140014
 
 
 
 
SAM2.1/Small_5_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:94e855d9fa14a909ed1f6df1385184380be37249cfe0371f54da8a3a3864c562
3
- size 137652294
 
 
 
 
SAM2.1/Tiny_1_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5a5905a5f3ee16591def7b1106e69fd8cf4ac017efc9bfefb716df2d59b1b2c3
3
- size 107589734
 
 
 
 
SAM2.1/Tiny_2_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e34e6bbde0659714513b74d272c99572f58ad3b207cb860ee8abbd20ed575e31
3
- size 107604716
 
 
 
 
SAM2.1/Tiny_3_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8d226bcbcb00b7a9e7a1654ebe5e22fe51dc231329ff5d5c7d5e77cc661c706b
3
- size 107648440
 
 
 
 
SAM2.1/Tiny_4_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:08ce2f508e246b87b8234fb785cb1f34a14c837dbf1e68d7b56e124552c008d3
3
- size 107664382
 
 
 
 
SAM2.1/Tiny_5_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4ac7e0d98a5c3ecc810cb156dc6df4e064169d059aa4a029c58f7e2db1a505fa
3
- size 109175190
 
 
 
 
TS/M258.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9e65c94939d366ebc0f052232efe7649b0397785dd033adc7aba3edea073fe8
3
+ size 123253560
TS/M258_1_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8d31fa3351adeaca8c288a77dee06eeafac8637111b255a1329dd348f2e5733e
3
- size 128992
 
 
 
 
TS/M258_2_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b4dfaf2a8512b70ba67d78fc472c1b2b76d41dbb6cf8142983a29142906b258d
3
- size 801711
 
 
 
 
TS/M258_3_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b59c4cd0e23eb24ea6e61d54c792a09a002e0a7d93149d2661744c938e76ebdc
3
- size 3467627
 
 
 
 
TS/M258_4_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:a31e35021568c5bc7e1697d7cd09330fa5b31e0aad290930853eb77d9a64e03c
3
- size 14099181
 
 
 
 
TS/M258_5_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:588c4deb30cca58cc312cd1a84e986adcea6ece0b6cee6ba2d70e43c9fc96078
3
- size 34022193
 
 
 
 
TS/M258_6_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:65cdf4c7b8a7e2ace62101edc7cfbbcb352a8fd2af0e8df5ef8b90ea3f27f767
3
- size 56152861
 
 
 
 
TS/M258_7_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2b395ba2de514cc68de01367746f13408f2ec1fd08af30ef5416f99314cea844
3
- size 123238221
 
 
 
 
TS/M258_8_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:a56b77155502cf8e5b9a24f78ddb319fe9afbc788b857dc2a259bb1f182a85f6
3
- size 123242789
 
 
 
 
TS/M291.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:824db3ce44193755e0f86b4da668b7a9582f8b5b6f513232df0e255fabec1bc5
3
+ size 124897676
TS/M291_1_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2d28aea10e2c64acde1a6ffb1c8eaa1804dff0bec473bdbbe264f879e31ed7b4
3
- size 128992
 
 
 
 
TS/M291_2_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2395b7093a3cea8f75e27353e016dcc78eb812e97eff1bcf27093f6017f18eca
3
- size 801711
 
 
 
 
TS/M291_4_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d862f0ca75fd1d8a6ad306b45f013f08299e5bab435c219340022902b638fb39
3
- size 14099181
 
 
 
 
TS/M291_5_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0d034f7787aa65a1e49c240475976b0cd62a85230fc52f818d498646384a052f
3
- size 34022193
 
 
 
 
TS/M291_6_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:dd80a96497e16df13437b7a70a4e9b9966d95027738e31c978011d7046fa4d64
3
- size 56153749
 
 
 
 
TS/M291_7_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5bf94c21efcc98f4a3bec4fd65f71ec0f52cd6510e867f323e0ee024df439fa7
3
- size 124878761
 
 
 
 
TS/M291_8_Layers.pt DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:ae12c616b0ccc9f255837241479a3232b0fa0e7674174aecb1b5275252451c07
3
- size 124887097
 
 
 
 
TS/M292.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0be260f381d87b6dc443a71726eb92c77b79a11db12c9a3309102065c042a3e
3
+ size 124897932