-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add docs config * Fix mock * Add huggingface_hub to reqs for docs * Remove from mocks * Fix * Change theme * Fix * Fix * Update emoji * Table of content * Links in doc * Update content * Update examples * Update * Update * Add save load
- Loading branch information
Showing
11 changed files
with
150 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
🏔 Available Encoders | ||
🔍 Available Encoders | ||
===================== | ||
|
||
ResNet | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ Welcome to Segmentation Models's documentation! | |
encoders_timm | ||
losses | ||
metrics | ||
save_load | ||
insights | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
🔧 Insights | ||
💡 Insights | ||
=========== | ||
|
||
1. Models architecture | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
🛠 Installation | ||
⚙️ Installation | ||
=============== | ||
|
||
PyPI version: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
📈 Metrics | ||
📏 Metrics | ||
========== | ||
|
||
Functional metrics | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,68 @@ | ||
📦 Segmentation Models | ||
🕸️ Segmentation Models | ||
============================== | ||
|
||
|
||
.. contents:: | ||
:local: | ||
|
||
.. _unet: | ||
|
||
Unet | ||
~~~~ | ||
.. autoclass:: segmentation_models_pytorch.Unet | ||
|
||
|
||
.. _unetplusplus: | ||
|
||
Unet++ | ||
~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.UnetPlusPlus | ||
|
||
MAnet | ||
~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.MAnet | ||
|
||
Linknet | ||
~~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.Linknet | ||
.. _fpn: | ||
|
||
FPN | ||
~~~ | ||
.. autoclass:: segmentation_models_pytorch.FPN | ||
|
||
|
||
.. _pspnet: | ||
|
||
PSPNet | ||
~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.PSPNet | ||
|
||
PAN | ||
~~~ | ||
.. autoclass:: segmentation_models_pytorch.PAN | ||
|
||
.. _deeplabv3: | ||
|
||
DeepLabV3 | ||
~~~~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.DeepLabV3 | ||
|
||
|
||
.. _deeplabv3plus: | ||
|
||
DeepLabV3+ | ||
~~~~~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.DeepLabV3Plus | ||
|
||
|
||
.. _linknet: | ||
|
||
Linknet | ||
~~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.Linknet | ||
|
||
|
||
.. _manet: | ||
|
||
MAnet | ||
~~~~~~ | ||
.. autoclass:: segmentation_models_pytorch.MAnet | ||
|
||
|
||
.. _pan: | ||
|
||
PAN | ||
~~~ | ||
.. autoclass:: segmentation_models_pytorch.PAN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
faculty-sphinx-theme==0.2.2 | ||
sphinx<7 | ||
sphinx-book-theme==1.1.2 | ||
six==1.15.0 | ||
autodocsumm | ||
autodocsumm | ||
huggingface_hub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
📂 Saving and Loading | ||
===================== | ||
|
||
In this section, we will discuss how to save a trained model, push it to the Hugging Face Hub, and load it back for later use. | ||
|
||
Saving and Sharing a Model | ||
-------------------------- | ||
|
||
Once you have trained your model, you can save it using the `.save_pretrained` method. This method saves the model configuration and weights to a directory of your choice. | ||
And, optionally, you can push the model to the Hugging Face Hub by setting the `push_to_hub` parameter to `True`. | ||
|
||
For example: | ||
|
||
.. code:: python | ||
import segmentation_models_pytorch as smp | ||
model = smp.Unet('resnet34', encoder_weights='imagenet') | ||
# After training your model, save it to a directory | ||
model.save_pretrained('./my_model') | ||
# Or saved and pushed to the Hub simultaneously | ||
model.save_pretrained('username/my-model', push_to_hub=True) | ||
Loading Trained Model | ||
--------------------- | ||
|
||
Once your model is saved and pushed to the Hub, you can load it back using the `smp.from_pretrained` method. This method allows you to load the model weights and configuration from a directory or directly from the Hub. | ||
|
||
For example: | ||
|
||
.. code:: python | ||
import segmentation_models_pytorch as smp | ||
# Load the model from the local directory | ||
model = smp.from_pretrained('./my_model') | ||
# Alternatively, load the model directly from the Hugging Face Hub | ||
model = smp.from_pretrained('username/my-model') | ||
Saving model Metrics and Dataset Name | ||
------------------------------------- | ||
|
||
You can simply pass the `metrics` and `dataset` parameters to the `save_pretrained` method to save the model metrics and dataset name in Model Card along with the model configuration and weights. | ||
|
||
For example: | ||
|
||
.. code:: python | ||
import segmentation_models_pytorch as smp | ||
model = smp.Unet('resnet34', encoder_weights='imagenet') | ||
# After training your model, save it to a directory | ||
model.save_pretrained('./my_model', metrics={'accuracy': 0.95}, dataset='my_dataset') | ||
# Or saved and pushed to the Hub simultaneously | ||
model.save_pretrained('username/my-model', push_to_hub=True, metrics={'accuracy': 0.95}, dataset='my_dataset') | ||
Conclusion | ||
---------- | ||
|
||
By following these steps, you can easily save, share, and load your models, facilitating collaboration and reproducibility in your projects. Don't forget to replace the placeholders with your actual model paths and names. | ||
|
||
|colab-badge| | ||
|
||
.. |colab-badge| image:: https://colab.research.google.com/assets/colab-badge.svg | ||
:target: https://colab.research.google.com/github/qubvel/segmentation_models.pytorch/blob/master/examples/binary_segmentation_intro.ipynb | ||
:alt: Open In Colab | ||
|
||
|