File tree Expand file tree Collapse file tree 3 files changed +30
-1472
lines changed Expand file tree Collapse file tree 3 files changed +30
-1472
lines changed Original file line number Diff line number Diff line change 1
1
[project ]
2
- name = " aws-hf-model-deployment"
2
+ name = " aws-sagemaker- hf-model-deployment"
3
3
version = " 0.1.0"
4
- description = " Add your description here "
4
+ description = " AWS SageMaker Hugging Face Model Deployment "
5
5
readme = " README.md"
6
6
requires-python = " >=3.12"
7
- dependencies = [
8
- " huggingface-hub[cli]>=0.27.1" ,
9
- " humanize>=4.11.0" ,
10
- " transformers[torch]>=4.48.0" ,
11
- ]
12
-
13
- [dependency-groups ]
14
- dev = [
15
- " boto3>=1.35.97" ,
16
- " pytest>=8.3.4" ,
17
- " sagemaker-huggingface-inference-toolkit>=2.4.1" ,
18
- ]
7
+ dependencies = [" boto3>=1.35.97" ]
19
8
20
9
[tool .mypy ]
21
10
disallow_untyped_calls = true
Original file line number Diff line number Diff line change 3
3
import boto3
4
4
5
5
AWS_REGION = "us-east-1"
6
- ENDPOINT_NAME = "dev -multilingual-sentiment-analysis-endpoint"
6
+ ENDPOINT_NAME = "test -multilingual-sentiment-analysis-endpoint"
7
7
8
8
sagemaker_runtime = boto3 .client ("sagemaker-runtime" , region_name = AWS_REGION )
9
9
89
89
response = sagemaker_runtime .invoke_endpoint (
90
90
EndpointName = ENDPOINT_NAME ,
91
91
ContentType = "application/json" ,
92
- Body = json .dumps (texts ),
92
+ Body = json .dumps ({ "inputs" : texts } ),
93
93
)
94
94
95
95
96
- result = json .loads (response ["Body" ].read ().decode ())
97
- print ("Predicted sentiment:" , result )
96
+ result = json .loads (response ["Body" ].read ())
97
+
98
+ for text , sentiment in zip (texts , result ):
99
+ print (f"Text: { text } " )
100
+ print (f"Sentiment: { sentiment } " )
101
+ print ()
You can’t perform that action at this time.
0 commit comments