Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update model file docs to be more accurate #2148

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Following are the steps to create a torch-model-archive (.mar) to execute an eag

* Pre-requisites to create a torch model archive (.mar) :
* serialized-file (.pt) : This file represents the `state_dict` in case of eager mode model.
* 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
* 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).
* 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.
* version : Model's version.
* handler : TorchServe default handler's name or path to custom inference handler(.py)
Expand Down
2 changes: 1 addition & 1 deletion examples/image_classifier/mnist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ https://github.com/pytorch/examples/tree/master/mnist

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

* 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).
* 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).
* 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.
* 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.
* Step - 4: Create a torch model archive using the torch-model-archiver utility to archive the above files.
Expand Down
5 changes: 4 additions & 1 deletion model-archiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ optional arguments:
Path to python file containing model architecture.
This parameter is mandatory for eager mode models.
The model architecture file must contain only one
class definition extended from torch.nn.modules.
class definition extended from torch.nn.Module.
--handler HANDLER TorchServe's default handler name or handler python
file path to handle custom TorchServe inference logic.
--extra-files EXTRA_FILES
Expand Down Expand Up @@ -132,6 +132,9 @@ A valid model name must begin with a letter of the alphabet and can only contain

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

This file should contain a single class that inherits from
[torch.nn.Module](https://pytorch.org/docs/stable/generated/torch.nn.Module.html).

### Serialized file

A serialized file (.pt or .pth) should be a checkpoint in case of torchscript and state_dict in case of eager mode.
Expand Down
2 changes: 1 addition & 1 deletion model-archiver/model_archiver/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def export_model_args_parser():
help="Path to python file containing model architecture.\n"
"This parameter is mandatory for eager mode models.\n"
"The model architecture file must contain only one\n"
"class definition extended from torch.nn.modules.",
"class definition extended from torch.nn.Module.",
)

parser_export.add_argument(
Expand Down