docs: add README + license for fcn_resnet50 (#1130)
Browse files
README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: bsd-3-clause
|
| 3 |
+
tags:
|
| 4 |
+
- vision
|
| 5 |
+
- pytorch
|
| 6 |
+
- torchvision
|
| 7 |
+
- ferrotorch
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# `ferrotorch/fcn_resnet50`
|
| 11 |
+
|
| 12 |
+
FCN with ResNet-50 backbone, pretrained on a COCO subset with Pascal VOC labels (21 classes). Re-keyed from torchvision 0.21 `fcn_resnet50` (`FCN_ResNet50_Weights.COCO_WITH_VOC_LABELS_V1`).
|
| 13 |
+
|
| 14 |
+
## Provenance
|
| 15 |
+
|
| 16 |
+
* Upstream factory: `torchvision.models.fcn_resnet50`
|
| 17 |
+
with `weights="COCO_WITH_VOC_LABELS_V1"` (torchvision 0.21).
|
| 18 |
+
* Conversion script: [`ferrotorch/scripts/pin_pretrained_weights.py`](https://github.com/dollspace/ferrotorch/blob/main/scripts/pin_pretrained_weights.py).
|
| 19 |
+
* Ferrotorch issue: <https://github.com/dollspace/ferrotorch/issues/1130>.
|
| 20 |
+
* Number of trainable parameters in upstream torchvision model: **35,322,218**.
|
| 21 |
+
* SHA-256 of `model.safetensors` (this file is pinned in
|
| 22 |
+
`ferrotorch-hub/src/registry.rs`): `8419d91ad57f4156e3a6add39abd43caf0a3761083743fe0a5dddf470ffdabf7`.
|
| 23 |
+
|
| 24 |
+
## How to load
|
| 25 |
+
|
| 26 |
+
```rust
|
| 27 |
+
use ferrotorch_vision::models::registry::get_model;
|
| 28 |
+
let model = get_model("fcn_resnet50", /* pretrained = */ true, /* num_classes = */ 21).unwrap();
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
The loader downloads this file, verifies SHA-256, then calls
|
| 32 |
+
`Module::load_state_dict(state_dict, strict=false)`. `strict=false`
|
| 33 |
+
is required because ferrotorch's `Module::named_parameters()` does
|
| 34 |
+
not yet expose `BatchNorm2d` running statistics
|
| 35 |
+
(`running_mean` / `running_var`), so those keys in this safetensors
|
| 36 |
+
file are intentionally ignored at load time until ferrotorch
|
| 37 |
+
issue #995 closes. They are still included here so re-uploading
|
| 38 |
+
is unnecessary once that work lands.
|
| 39 |
+
|
| 40 |
+
## Conversion notes
|
| 41 |
+
|
| 42 |
+
The following upstream torchvision keys are intentionally dropped because the ferrotorch architecture does not have a corresponding parameter slot:
|
| 43 |
+
|
| 44 |
+
* `aux_classifier.0.weight`
|
| 45 |
+
* `aux_classifier.1.bias`
|
| 46 |
+
* `aux_classifier.1.num_batches_tracked`
|
| 47 |
+
* `aux_classifier.1.running_mean`
|
| 48 |
+
* `aux_classifier.1.running_var`
|
| 49 |
+
* `aux_classifier.1.weight`
|
| 50 |
+
* `aux_classifier.4.bias`
|
| 51 |
+
* `aux_classifier.4.weight`
|
| 52 |
+
|
| 53 |
+
For FPN bias drops this is a known mismatch between torchvision's `nn.Conv2d(..., bias=True)` FPN convolutions and ferrotorch's `bias=False` FPN convolutions. For `aux_classifier.*` drops the ferrotorch DeepLabV3 / FCN implementations do not expose an aux head.
|
| 54 |
+
|
| 55 |
+
## Upstream license (verbatim, torchvision 0.21 `LICENSE`)
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
BSD 3-Clause License
|
| 59 |
+
|
| 60 |
+
Copyright (c) Soumith Chintala 2016,
|
| 61 |
+
All rights reserved.
|
| 62 |
+
|
| 63 |
+
Redistribution and use in source and binary forms, with or without
|
| 64 |
+
modification, are permitted provided that the following conditions are met:
|
| 65 |
+
|
| 66 |
+
* Redistributions of source code must retain the above copyright notice, this
|
| 67 |
+
list of conditions and the following disclaimer.
|
| 68 |
+
|
| 69 |
+
* Redistributions in binary form must reproduce the above copyright notice,
|
| 70 |
+
this list of conditions and the following disclaimer in the documentation
|
| 71 |
+
and/or other materials provided with the distribution.
|
| 72 |
+
|
| 73 |
+
* Neither the name of the copyright holder nor the names of its
|
| 74 |
+
contributors may be used to endorse or promote products derived from
|
| 75 |
+
this software without specific prior written permission.
|
| 76 |
+
|
| 77 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 78 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 79 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 80 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 81 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 82 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 83 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 84 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 85 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 86 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 87 |
+
|
| 88 |
+
```
|