This file contains hidden or 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
| from sagemaker.huggingface.model import HuggingFaceModel | |
| from sagemaker.serverless import ServerlessInferenceConfig | |
| from sagemaker.serializers import DataSerializer | |
| import sagemaker | |
| import boto3 | |
| try: | |
| role = sagemaker.get_execution_role() | |
| except ValueError: | |
| iam = boto3.client('iam') |
This file contains hidden or 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
| apiVersion: argoproj.io/v1alpha1 | |
| kind: Workflow | |
| metadata: | |
| generateName: xgboost-trainer- | |
| annotations: {pipelines.kubeflow.org/kfp_sdk_version: 1.8.12, pipelines.kubeflow.org/pipeline_compilation_time: '2022-04-19T13:58:21.551241', | |
| pipelines.kubeflow.org/pipeline_spec: '{"description": "A trainer that does end-to-end | |
| distributed training for XGBoost models.", "inputs": [{"default": "gs://{{kfp-default-bucket}}", | |
| "name": "output", "optional": true}, {"default": "{{kfp-project-id}}", "name": | |
| "project", "optional": true}, {"default": "HALT_ON_ERROR", "name": "diagnostic_mode", | |
| "optional": true}, {"default": "5", "name": "rounds", "optional": true}], "name": |
This file contains hidden or 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
| from sagemaker.huggingface import HuggingFaceModel | |
| from sagemaker.serializers import DataSerializer | |
| import sagemaker | |
| role = sagemaker.get_execution_role() | |
| # Hub Model configuration. https://huggingface.co/models | |
| hub = { | |
| 'HF_MODEL_ID':'facebook/wav2vec2-base-960h', | |
| 'HF_TASK':'automatic-speech-recognition' |
This file contains hidden or 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
| import time | |
| import boto3 | |
| import os | |
| import json | |
| from locust import User, task, between | |
| # How to use | |
| # 1. install locust & boto3 | |
| # pip install locust boto3 | |
| # 2. run benchmark via cli |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| from aws_cdk import core as cdk | |
| import os | |
| from pathlib import Path | |
| import shutil | |
| import subprocess | |
| from aws_cdk import ( | |
| aws_iam as iam, | |
| aws_sagemaker as sagemaker, |
This file contains hidden or 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
| from sagemaker.huggingface import HuggingFaceModel | |
| import sagemaker | |
| role = sagemaker.get_execution_role() | |
| hub = { 'HF_MODEL_ID':'bigscience/T0_3B','HF_TASK':'text2text-generation'} | |
| # create Hugging Face Model Class | |
| huggingface_model = HuggingFaceModel( | |
| transformers_version='4.6.1', | |
| pytorch_version='1.7.1', | |
| py_version='py36', |
This file contains hidden or 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
| import torch | |
| import os | |
| from transformers import Wav2Vec2Processor, HubertForCTC | |
| from transformers.pipelines.automatic_speech_recognition import ffmpeg_read | |
| def get_file_size(file_path): | |
| size = os.path.getsize(file_path) | |
| return f"{round(size / 1000 / 1000,2)} MB" |
This file contains hidden or 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
| import tarfile | |
| import os | |
| root = "./endpoint" | |
| def main(): | |
| cwd = os.getcwd() | |
| os.chdir(root) | |
| files = [os.path.join(path, name) for path, _, files in os.walk(".") for name in files] |
This file contains hidden or 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
| from argparse import ArgumentParser | |
| from asyncio import get_event_loop, gather | |
| from multiprocessing import Process | |
| from requests import post, Session | |
| from re import compile | |
| from datasets import load_dataset | |
| from elasticsearch import Elasticsearch |
This file contains hidden or 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
| const API_URL = "https:/{URL}/api/{TASK}" | |
| async function query(payload) { | |
| const body = JSON.stringify(payload) | |
| try { | |
| const response = await fetch(API_URL, { | |
| method: 'post', | |
| body | |
| }) | |
| return response.json(); |