Skip to content

Commit 29defdc

Browse files
v0.8
1 parent d52c83c commit 29defdc

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

HF-only/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ The high level approach to use any of the 🤗 pipelines for a desired [*task*](
141141

142142
* Decide a name (variable `$modelName` below) for the task (variable `$task` below) supported by a 🤗 model that supports the task (its repo link as variable `$repoUrl` below), then run the below commands to download the models and create the `.mar` file:
143143
```
144-
$modelName="vitxxsmall"
145-
$task="image-classification"
146-
$repoUrl="https://huggingface.co/apple/mobilevit-xx-small/tree/main"
144+
modelName="vitxxsmall"
145+
task="image-classification"
146+
repoUrl="https://huggingface.co/apple/mobilevit-xx-small"
147147
148+
chmod +x prepare_mar_from_hf.sh
148149
./prepare_mar_from_hf.sh -t $task -n $modelName -u $repoUrl
149150
```
150151

HF-only/prepare_mar_from_hf.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ for arg in "$@"
55
do
66
case $arg in
77
-t|--task)
8-
sed -i "s/task=\".*/task=\"$2\"/g" HF-only/scripts/torchserve_vitxxsmall_handler.py
9-
shift
8+
sed -i "s/task=\".*/task=\"$2\"/g" scripts/torchserve_vitxxsmall_handler.py
9+
shift 2
1010
;;
1111
-n|--model-name)
1212
MODEL_NAME="$2"
13-
shift
13+
echo "MODEL_NAME is $MODEL_NAME"
14+
shift 2
1415
;;
1516
-u|--hf-hub-link)
1617
HF_REPO_URL="$2"
@@ -23,7 +24,7 @@ do
2324
touch dummy_file.pth
2425
torch-model-archiver --model-name $MODEL_NAME --serialized-file dummy_file.pth --version 1.0 --handler scripts/torchserve_vitxxsmall_handler.py --export-path model-store -r requirements.txt
2526
rm -f dummy_file.pth
26-
shift
27+
shift 2
2728
;;
2829
esac
2930
done

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This repository contains an example to deploy models with third-party dependenci
44

55
For the context of this repository, we would deploy the models on an AWS [`t2.micro`](https://aws.amazon.com/ec2/instance-types/) instance which can be used for free (for 750 hours) on a new AWS account. We work with a 🤗 MobileViT Transformer [model](https://huggingface.co/apple/mobilevit-xx-small) for the task of image classification by using its [`pipeline`](https://huggingface.co/docs/transformers/main_classes/pipelines) feature, the handler code in `scripts` can also be used as a simplistic template to deploy an 🤗 `pipeline`.
66

7+
This work can also be [extended to deploy *any* 🤗 `pipeline` for *any* supported task with Torchserve](https://github.com/tripathiarpan20/HF-torchserve-pipeline/tree/main/HF-only#instructions-to-use-any--model-from-the-hub-for-any-task-supported-by-the--pipeline).
8+
79
This work *may* also be extended to deploy the Torchserve Docker containers with HF models at scale with [AWS Cloudformation](https://github.com/pytorch/serve/tree/master/examples/cloudformation) & [AWS EKS](https://github.com/pytorch/serve/tree/master/kubernetes/EKS) as explained in the official Torchserve repo & [AWS Sagemaker](https://github.com/tescal2/TorchServeOnAWS/tree/master/3_torchserve_byoc_with_amazon_sagemaker), incorporating utilities like AWS ELB & Cloudwatch.
810

911
We would also benchmark the REST API calls in time units and compare the model performances for the following approaches:
@@ -12,7 +14,7 @@ We would also benchmark the REST API calls in time units and compare the model p
1214

1315

1416
## Todo
15-
- [ ] Verify HF pipeline functionality with AWS EC2 `t2.micro`
17+
- [X] Verify HF pipeline functionality with AWS EC2 `t2.micro`
1618
- [ ] Add [AB Testing](https://github.com/pytorch/serve/tree/master/benchmarks) experiments with Torchserve Benchmarking utilities.
1719
- [ ] Add dynamic batching explanation
1820
- [ ] Add Torchscripted model code

0 commit comments

Comments
 (0)