Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 87359c4

Browse files
tmcagunapal
andauthored
Update model file docs to be more accurate (#2148)
* Update model file docs to be more accurate * model-archiver: Improve docs --------- Co-authored-by: Ankith Gunapal <agunapal@meta.com>
1 parent 26089d4 commit 87359c4

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Following are the steps to create a torch-model-archive (.mar) to execute an eag
110110

111111
* Pre-requisites to create a torch model archive (.mar) :
112112
* serialized-file (.pt) : This file represents the `state_dict` in case of eager mode model.
113-
* model-file (.py) : This file contains model class extended from `torch nn`.modules representing the model architecture. This parameter is mandatory for eager mode models. This file must contain only one class definition extended from torch.nn.modules
113+
* model-file (.py) : This file contains model class extended from `torch nn`.modules representing the model architecture. This parameter is mandatory for eager mode models. This file must contain only one class definition extended from [torch.nn.Module](https://pytorch.org/docs/stable/generated/torch.nn.Module.html).
114114
* index_to_name.json : This file contains the mapping of predicted index to class. The default TorchServe handles returns the predicted index and probability. This file can be passed to model archiver using --extra-files parameter.
115115
* version : Model's version.
116116
* handler : TorchServe default handler's name or path to custom inference handler(.py)

examples/image_classifier/mnist/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ https://github.com/pytorch/examples/tree/master/mnist
1616

1717
Run the commands given in following steps from the parent directory of the root of the repository. For example, if you cloned the repository into /home/my_path/serve, run the steps from /home/my_path
1818

19-
* Step - 1: Create a new model architecture file which contains model class extended from torch.nn.modules. In this example we have created [mnist model file](mnist.py).
19+
* Step - 1: Create a new model architecture file which contains model class extended from [torch.nn.Module](https://pytorch.org/docs/stable/generated/torch.nn.Module.html). In this example we have created [mnist model file](mnist.py).
2020
* Step - 2: Train a MNIST digit recognition model using https://github.com/pytorch/examples/blob/master/mnist/main.py and save the state dict of model. We have added the pre-created [state dict](mnist_cnn.pt) of this model.
2121
* Step - 3: Write a custom handler to run the inference on your model. In this example, we have added a [custom_handler](mnist_handler.py) which runs the inference on the input grayscale images using the above model and recognizes the digit in the image.
2222
* Step - 4: Create a torch model archive using the torch-model-archiver utility to archive the above files.

model-archiver/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ optional arguments:
7878
Path to python file containing model architecture.
7979
This parameter is mandatory for eager mode models.
8080
The model architecture file must contain only one
81-
class definition extended from torch.nn.modules.
81+
class definition extended from torch.nn.Module.
8282
--handler HANDLER TorchServe's default handler name or handler python
8383
file path to handle custom TorchServe inference logic.
8484
--extra-files EXTRA_FILES
@@ -132,6 +132,9 @@ A valid model name must begin with a letter of the alphabet and can only contain
132132

133133
A model file should contain the model architecture. This file is mandatory in case of eager mode models.
134134

135+
This file should contain a single class that inherits from
136+
[torch.nn.Module](https://pytorch.org/docs/stable/generated/torch.nn.Module.html).
137+
135138
### Serialized file
136139

137140
A serialized file (.pt or .pth) should be a checkpoint in case of torchscript and state_dict in case of eager mode.

model-archiver/model_archiver/arg_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def export_model_args_parser():
5454
help="Path to python file containing model architecture.\n"
5555
"This parameter is mandatory for eager mode models.\n"
5656
"The model architecture file must contain only one\n"
57-
"class definition extended from torch.nn.modules.",
57+
"class definition extended from torch.nn.Module.",
5858
)
5959

6060
parser_export.add_argument(

0 commit comments

Comments
 (0)