training/built-in-algorithms/Image-classification-transfer-learning-highlevel.ipynb (811 lines of code) (raw):

{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Image classification transfer learning demo (SageMaker SDK)\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook. \n", "\n", "![This us-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-west-2/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "1. [Introduction](#Introduction)\n", "2. [Prerequisites and Preprocessing](#Prequisites-and-Preprocessing)\n", "3. [Fine-tuning the Image classification model](#Fine-tuning-the-Image-classification-model)\n", " 1. [Training with SageMaker Training](#Training-with-sageMaker-training)\n", " 1. [Training parameters](#Training-parameters)\n", " 2. [Input data specification](#Input-data-specification)\n", " 3. [Start the training](#Start-the-training)\n", " 2. [Training with Automatic Model Tuning (HPO)](#Training-with-automatic-model-tuning-hpo)\n", "4. [Inference](#Inference)\n", " 1. [List of object categories](#List-of-object-categories)\n", " 2. [Download test image](#Download-test-image)\n", " 3. [Evaluation](#Evaluation)\n", " 4. [Clean up](#Clean-up)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "\n", "Welcome to our end-to-end example of distributed image classification algorithm in transfer learning mode. In this demo, we will use the Amazon sagemaker image classification algorithm in transfer learning mode to fine-tune a pre-trained model (trained on imagenet data) to learn to classify a new dataset. In particular, the pre-trained model will be fine-tuned using [Caltech-256 dataset](https://paperswithcode.com/dataset/caltech-256). \n", "\n", "This notebook was tested in Amazon SageMaker Studio on ml.t3.medium instance with Python 3 (Data Science) kernel.\n", "\n", "To get started, we need to set up the environment with a few prerequisite steps, for permissions, configurations, and so on." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Prequisites and Preprocessing\n", "\n", "### Permissions and environment variables\n", "\n", "Here we set up the linkage and authentication to AWS services. There are three parts to this:\n", "\n", "* The roles used to give learning and hosting access to your data. This will automatically be obtained from the role used to start the notebook\n", "* The S3 bucket that you want to use for training and model data\n", "* The Amazon sagemaker image classification docker image which need not be changed" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "! pip install --upgrade sagemaker" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%time\n", "import boto3\n", "import sagemaker\n", "from sagemaker import get_execution_role\n", "\n", "role = get_execution_role()\n", "print(role)\n", "\n", "region = boto3.Session().region_name\n", "\n", "s3_client = boto3.client(\"s3\")\n", "\n", "sess = sagemaker.Session()\n", "data_bucket = f\"sagemaker-sample-files\"\n", "data_prefix = \"datasets/image/caltech-256/\"\n", "\n", "output_bucket = sess.default_bucket()\n", "output_prefix = \"ic-transfer-learning\"\n", "\n", "s3_client.download_file(\n", " data_bucket, data_prefix + \"caltech-256-60-train.rec\", \"caltech-256-60-train.rec\"\n", ")\n", "s3_client.download_file(\n", " data_bucket, data_prefix + \"caltech-256-60-val.rec\", \"caltech-256-60-val.rec\"\n", ")\n", "s3_client.upload_file(\n", " \"caltech-256-60-train.rec\", output_bucket, output_prefix + \"/train_rec/caltech-256-60-train.rec\"\n", ")\n", "s3_client.upload_file(\n", " \"caltech-256-60-train.rec\",\n", " output_bucket,\n", " output_prefix + \"/validation_rec/caltech-256-60-train.rec\",\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from sagemaker import image_uris\n", "\n", "training_image = image_uris.retrieve(region=sess.boto_region_name, framework=\"image-classification\")\n", "print(training_image)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fine-tuning the Image classification model\n", "\n", "The caltech 256 dataset [1] consist of images from 257 categories (the last one being a clutter category) and has 30k images with a minimum of 80 images and a maximum of about 800 images per category. \n", "\n", "The image classification algorithm can take two types of input formats. The first is a [recordio format](https://mxnet.incubator.apache.org/faq/recordio.html) and the other is a [lst format](https://mxnet.incubator.apache.org/faq/recordio.html?highlight=im2rec). Files for both these formats are available at http://data.dmlc.ml/mxnet/data/caltech-256/. In this example, we will use the recordio format for training and use the training/validation split [specified here](http://data.dmlc.ml/mxnet/data/caltech-256/). \n", "\n", "Data in this notebook was downloaded from [MXNet's caltech-256 training dataset](http://data.mxnet.io/data/caltech-256/caltech-256-60-train.rec) and [MXNet's caltech-256 validation dataset](http://data.mxnet.io/data/caltech-256/caltech-256-60-val.rec) and stored in the `data_bucket`.\n", "\n", ">[1] Griffin, G. Holub, AD. Perona, P. The Caltech 256. Caltech Technical Report." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import boto3\n", "\n", "# Four channels: train, validation, train_lst, and validation_lst\n", "s3train = f\"s3://{output_bucket}/{output_prefix}/train_rec/\"\n", "s3validation = f\"s3://{output_bucket}/{output_prefix}/validation_rec/\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once we have the data available in the correct format for training, the next step is to actually train the model using the data." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Training can be done by either calling SageMaker Training with a set of hyperparameters values to train with, or by leveraging SageMaker Automatic Model Tuning ([AMT](https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning.html)). AMT, also known as hyperparameter tuning (HPO), finds the best version of a model by running many training jobs on your dataset using the algorithm and ranges of hyperparameters that you specify. It then chooses the hyperparameter values that result in a model that performs the best, as measured by a metric that you choose.\n", "\n", "In this notebook, both methods are used for demonstration purposes, but the model that the HPO job creates is the one that is used as the base one for incremental training. You can instead choose to use the model created by the standalone training job by changing the below variable `deploy_amt_model` to False." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "deploy_amt_model = True" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Training with SageMaker Training\n", "\n", "To begin, let us create a ``sageMaker.estimator.Estimator`` object. This estimator will launch the training job.\n", "\n", "#### Training parameters\n", "There are two kinds of parameters that need to be set for training. The first one are the parameters for the training job. These include:\n", "\n", "* **Training instance count**: This is the number of instances on which to run the training. When the number of instances is greater than one, then the image classification algorithm will run in distributed settings. \n", "* **Training instance type**: This indicates the type of machine on which to run the training. Typically, we use GPU instances for these training \n", "* **Output path**: This the s3 folder in which the training output is stored" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s3_output_location = f\"s3://{output_bucket}/{output_prefix}/output\"\n", "\n", "ic = sagemaker.estimator.Estimator(\n", " training_image,\n", " role,\n", " instance_count=1,\n", " instance_type=\"ml.p3.2xlarge\",\n", " volume_size=50,\n", " max_run=360000,\n", " input_mode=\"File\",\n", " output_path=s3_output_location,\n", " sagemaker_session=sess,\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Apart from the above set of parameters, there are hyperparameters that are specific to the algorithm. These are:\n", "\n", "* **num_layers**: The number of layers (depth) for the network. We use 18 in this samples but other values such as 50, 152 can be used.\n", "* **use_pretrained_model**: Set to 1 to use pretrained model for transfer learning.\n", "* **image_shape**: The input image dimensions,'num_channels, height, width', for the network. It should be no larger than the actual image size. The number of channels should be same as the actual image.\n", "* **num_classes**: This is the number of output classes for the new dataset. Imagenet was trained with 1000 output classes but the number of output classes can be changed for fine-tuning. For caltech, we use 257 because it has 256 object categories + 1 clutter class.\n", "* **num_training_samples**: This is the total number of training samples. It is set to 15240 for caltech dataset with the current split.\n", "* **mini_batch_size**: The number of training samples used for each mini batch. In distributed training, the number of training samples used per batch will be N * mini_batch_size where N is the number of hosts on which training is run.\n", "* **epochs**: Number of training epochs.\n", "* **learning_rate**: Learning rate for training.\n", "* **precision_dtype**: Training datatype precision (default: float32). If set to 'float16', the training will be done in mixed_precision mode and will be faster than float32 mode\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "isConfigCell": true }, "outputs": [], "source": [ "ic.set_hyperparameters(\n", " num_layers=18,\n", " use_pretrained_model=1,\n", " image_shape=\"3,224,224\",\n", " num_classes=257,\n", " num_training_samples=15420,\n", " mini_batch_size=128,\n", " epochs=2,\n", " learning_rate=0.01,\n", " precision_dtype=\"float32\",\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Input data specification\n", "Set the data type and channels used for training" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "train_data = sagemaker.inputs.TrainingInput(\n", " s3train,\n", " distribution=\"FullyReplicated\",\n", " content_type=\"application/x-recordio\",\n", " s3_data_type=\"S3Prefix\",\n", ")\n", "validation_data = sagemaker.inputs.TrainingInput(\n", " s3validation,\n", " distribution=\"FullyReplicated\",\n", " content_type=\"application/x-recordio\",\n", " s3_data_type=\"S3Prefix\",\n", ")\n", "\n", "data_channels = {\"train\": train_data, \"validation\": validation_data}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Start the training\n", "Start training by calling the fit method in the estimator" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ic.fit(inputs=data_channels, logs=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Training with Automatic Model Tuning ([HPO](https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning.html)) <a id='AMT'></a>\n", "***\n", "As mentioned above, instead of manually configuring our hyper parameter values and training with SageMaker Training, we'll use Amazon SageMaker Automatic Model Tuning. \n", " \n", "The code sample below shows you how to use the HyperParameterTuner. For recommended default hyparameter ranges, check the [Amazon SageMaker Image Classification HPs documentation](https://docs.aws.amazon.com/sagemaker/latest/dg/IC-Hyperparameter.html). \n", "\n", "The tuning job will take 15 to 20 minutes to complete.\n", "***" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import time\n", "from sagemaker.tuner import IntegerParameter, ContinuousParameter\n", "from sagemaker.tuner import HyperparameterTuner\n", "\n", "job_name = \"DEMO-ic-tl-\" + time.strftime(\"%Y-%m-%d-%H-%M-%S\", time.gmtime())\n", "print(\"Tuning job name: \", job_name)\n", "\n", "# Image Classification tunable hyper parameters can be found here https://docs.aws.amazon.com/sagemaker/latest/dg/IC-tuning.html\n", "hyperparameter_ranges = {\n", " \"beta_1\": ContinuousParameter(1e-6, 0.999, scaling_type=\"Auto\"),\n", " \"beta_2\": ContinuousParameter(1e-6, 0.999, scaling_type=\"Auto\"),\n", " \"eps\": ContinuousParameter(1e-8, 1.0, scaling_type=\"Auto\"),\n", " \"gamma\": ContinuousParameter(1e-8, 0.999, scaling_type=\"Auto\"),\n", " \"learning_rate\": ContinuousParameter(1e-6, 0.5, scaling_type=\"Auto\"),\n", " \"mini_batch_size\": IntegerParameter(8, 64, scaling_type=\"Auto\"),\n", " \"momentum\": ContinuousParameter(0.0, 0.999, scaling_type=\"Auto\"),\n", " \"weight_decay\": ContinuousParameter(0.0, 0.999, scaling_type=\"Auto\"),\n", "}\n", "\n", "# Increase the total number of training jobs run by AMT, for increased accuracy (and training time).\n", "max_jobs = 6\n", "# Change parallel training jobs run by AMT to reduce total training time, constrained by your account limits.\n", "# if max_jobs=max_parallel_jobs then Bayesian search turns to Random.\n", "max_parallel_jobs = 2\n", "\n", "\n", "hp_tuner = HyperparameterTuner(\n", " ic,\n", " \"validation:accuracy\",\n", " hyperparameter_ranges,\n", " max_jobs=max_jobs,\n", " max_parallel_jobs=max_parallel_jobs,\n", " objective_type=\"Maximize\",\n", ")\n", "\n", "\n", "# Launch a SageMaker Tuning job to search for the best hyperparameters\n", "hp_tuner.fit(inputs=data_channels, job_name=job_name)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Inference\n", "\n", "***\n", "\n", "A trained model does nothing on its own. We now want to use the model to perform inference. For this example, that means predicting the class of the image. You can deploy the created model by using the deploy method in the estimator" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ic_classifier = (hp_tuner if deploy_amt_model else ic).deploy(\n", " initial_instance_count=1, instance_type=\"ml.m4.xlarge\"\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### List of object categories" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "object_categories = [\n", " \"ak47\",\n", " \"american-flag\",\n", " \"backpack\",\n", " \"baseball-bat\",\n", " \"baseball-glove\",\n", " \"basketball-hoop\",\n", " \"bat\",\n", " \"bathtub\",\n", " \"bear\",\n", " \"beer-mug\",\n", " \"billiards\",\n", " \"binoculars\",\n", " \"birdbath\",\n", " \"blimp\",\n", " \"bonsai-101\",\n", " \"boom-box\",\n", " \"bowling-ball\",\n", " \"bowling-pin\",\n", " \"boxing-glove\",\n", " \"brain-101\",\n", " \"breadmaker\",\n", " \"buddha-101\",\n", " \"bulldozer\",\n", " \"butterfly\",\n", " \"cactus\",\n", " \"cake\",\n", " \"calculator\",\n", " \"camel\",\n", " \"cannon\",\n", " \"canoe\",\n", " \"car-tire\",\n", " \"cartman\",\n", " \"cd\",\n", " \"centipede\",\n", " \"cereal-box\",\n", " \"chandelier-101\",\n", " \"chess-board\",\n", " \"chimp\",\n", " \"chopsticks\",\n", " \"cockroach\",\n", " \"coffee-mug\",\n", " \"coffin\",\n", " \"coin\",\n", " \"comet\",\n", " \"computer-keyboard\",\n", " \"computer-monitor\",\n", " \"computer-mouse\",\n", " \"conch\",\n", " \"cormorant\",\n", " \"covered-wagon\",\n", " \"cowboy-hat\",\n", " \"crab-101\",\n", " \"desk-globe\",\n", " \"diamond-ring\",\n", " \"dice\",\n", " \"dog\",\n", " \"dolphin-101\",\n", " \"doorknob\",\n", " \"drinking-straw\",\n", " \"duck\",\n", " \"dumb-bell\",\n", " \"eiffel-tower\",\n", " \"electric-guitar-101\",\n", " \"elephant-101\",\n", " \"elk\",\n", " \"ewer-101\",\n", " \"eyeglasses\",\n", " \"fern\",\n", " \"fighter-jet\",\n", " \"fire-extinguisher\",\n", " \"fire-hydrant\",\n", " \"fire-truck\",\n", " \"fireworks\",\n", " \"flashlight\",\n", " \"floppy-disk\",\n", " \"football-helmet\",\n", " \"french-horn\",\n", " \"fried-egg\",\n", " \"frisbee\",\n", " \"frog\",\n", " \"frying-pan\",\n", " \"galaxy\",\n", " \"gas-pump\",\n", " \"giraffe\",\n", " \"goat\",\n", " \"golden-gate-bridge\",\n", " \"goldfish\",\n", " \"golf-ball\",\n", " \"goose\",\n", " \"gorilla\",\n", " \"grand-piano-101\",\n", " \"grapes\",\n", " \"grasshopper\",\n", " \"guitar-pick\",\n", " \"hamburger\",\n", " \"hammock\",\n", " \"harmonica\",\n", " \"harp\",\n", " \"harpsichord\",\n", " \"hawksbill-101\",\n", " \"head-phones\",\n", " \"helicopter-101\",\n", " \"hibiscus\",\n", " \"homer-simpson\",\n", " \"horse\",\n", " \"horseshoe-crab\",\n", " \"hot-air-balloon\",\n", " \"hot-dog\",\n", " \"hot-tub\",\n", " \"hourglass\",\n", " \"house-fly\",\n", " \"human-skeleton\",\n", " \"hummingbird\",\n", " \"ibis-101\",\n", " \"ice-cream-cone\",\n", " \"iguana\",\n", " \"ipod\",\n", " \"iris\",\n", " \"jesus-christ\",\n", " \"joy-stick\",\n", " \"kangaroo-101\",\n", " \"kayak\",\n", " \"ketch-101\",\n", " \"killer-whale\",\n", " \"knife\",\n", " \"ladder\",\n", " \"laptop-101\",\n", " \"lathe\",\n", " \"leopards-101\",\n", " \"license-plate\",\n", " \"lightbulb\",\n", " \"light-house\",\n", " \"lightning\",\n", " \"llama-101\",\n", " \"mailbox\",\n", " \"mandolin\",\n", " \"mars\",\n", " \"mattress\",\n", " \"megaphone\",\n", " \"menorah-101\",\n", " \"microscope\",\n", " \"microwave\",\n", " \"minaret\",\n", " \"minotaur\",\n", " \"motorbikes-101\",\n", " \"mountain-bike\",\n", " \"mushroom\",\n", " \"mussels\",\n", " \"necktie\",\n", " \"octopus\",\n", " \"ostrich\",\n", " \"owl\",\n", " \"palm-pilot\",\n", " \"palm-tree\",\n", " \"paperclip\",\n", " \"paper-shredder\",\n", " \"pci-card\",\n", " \"penguin\",\n", " \"people\",\n", " \"pez-dispenser\",\n", " \"photocopier\",\n", " \"picnic-table\",\n", " \"playing-card\",\n", " \"porcupine\",\n", " \"pram\",\n", " \"praying-mantis\",\n", " \"pyramid\",\n", " \"raccoon\",\n", " \"radio-telescope\",\n", " \"rainbow\",\n", " \"refrigerator\",\n", " \"revolver-101\",\n", " \"rifle\",\n", " \"rotary-phone\",\n", " \"roulette-wheel\",\n", " \"saddle\",\n", " \"saturn\",\n", " \"school-bus\",\n", " \"scorpion-101\",\n", " \"screwdriver\",\n", " \"segway\",\n", " \"self-propelled-lawn-mower\",\n", " \"sextant\",\n", " \"sheet-music\",\n", " \"skateboard\",\n", " \"skunk\",\n", " \"skyscraper\",\n", " \"smokestack\",\n", " \"snail\",\n", " \"snake\",\n", " \"sneaker\",\n", " \"snowmobile\",\n", " \"soccer-ball\",\n", " \"socks\",\n", " \"soda-can\",\n", " \"spaghetti\",\n", " \"speed-boat\",\n", " \"spider\",\n", " \"spoon\",\n", " \"stained-glass\",\n", " \"starfish-101\",\n", " \"steering-wheel\",\n", " \"stirrups\",\n", " \"sunflower-101\",\n", " \"superman\",\n", " \"sushi\",\n", " \"swan\",\n", " \"swiss-army-knife\",\n", " \"sword\",\n", " \"syringe\",\n", " \"tambourine\",\n", " \"teapot\",\n", " \"teddy-bear\",\n", " \"teepee\",\n", " \"telephone-box\",\n", " \"tennis-ball\",\n", " \"tennis-court\",\n", " \"tennis-racket\",\n", " \"theodolite\",\n", " \"toaster\",\n", " \"tomato\",\n", " \"tombstone\",\n", " \"top-hat\",\n", " \"touring-bike\",\n", " \"tower-pisa\",\n", " \"traffic-light\",\n", " \"treadmill\",\n", " \"triceratops\",\n", " \"tricycle\",\n", " \"trilobite-101\",\n", " \"tripod\",\n", " \"t-shirt\",\n", " \"tuning-fork\",\n", " \"tweezer\",\n", " \"umbrella-101\",\n", " \"unicorn\",\n", " \"vcr\",\n", " \"video-projector\",\n", " \"washing-machine\",\n", " \"watch-101\",\n", " \"waterfall\",\n", " \"watermelon\",\n", " \"welding-mask\",\n", " \"wheelbarrow\",\n", " \"windmill\",\n", " \"wine-bottle\",\n", " \"xylophone\",\n", " \"yarmulke\",\n", " \"yo-yo\",\n", " \"zebra\",\n", " \"airplanes-101\",\n", " \"car-side-101\",\n", " \"faces-easy-101\",\n", " \"greyhound\",\n", " \"tennis-shoes\",\n", " \"toad\",\n", " \"clutter\",\n", "]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Download test image" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# test image\n", "file_name = \"/tmp/test.jpg\"\n", "s3_client.download_file(\n", " \"sagemaker-sample-files\",\n", " \"datasets/image/caltech-256/256_ObjectCategories/008.bathtub/008_0007.jpg\",\n", " file_name,\n", ")\n", "\n", "from IPython.display import Image\n", "\n", "Image(file_name)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Evaluation\n", "\n", "Evaluate the image through the network for inteference. The network outputs class probabilities and typically, one selects the class with the maximum probability as the final class output.\n", "\n", "**Note:** The output class detected by the network may not be accurate in this example. To limit the time taken and cost of training, we have trained the model only for a couple of epochs. If the network is trained for more epochs (say 20), then the output class will be more accurate." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import json\n", "import numpy as np\n", "\n", "with open(file_name, \"rb\") as f:\n", " payload = f.read()\n", " payload = bytearray(payload)\n", "\n", "# Invoke the deployed model to compute prediction\n", "prediction = ic_classifier.predict(payload, initial_args={\"ContentType\": \"application/x-image\"})\n", "\n", "# prediction is a JSON string. Load it into a Python object.\n", "probabilities = json.loads(prediction)\n", "\n", "# find the class with maximum probability and print the class index\n", "predicted_category_index = np.argmax(probabilities)\n", "predicted_category_name = object_categories[predicted_category_index]\n", "confidence = probabilities[predicted_category_index]\n", "\n", "print(f\"Result: label - {predicted_category_name}, probability - {confidence}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Clean up\n", "\n", "When we're done with the endpoint, we can just delete it and the backing instances will be released. Run the following cell to delete the endpoint." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ic_classifier.delete_endpoint()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Notebook CI Test Results\n", "\n", "This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.\n", "\n", "![This us-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-east-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This us-east-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-east-2/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This us-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-west-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This ca-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ca-central-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This sa-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/sa-east-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This eu-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-west-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This eu-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-west-2/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This eu-west-3 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-west-3/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This eu-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-central-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This eu-north-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-north-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This ap-southeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-southeast-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This ap-southeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-southeast-2/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This ap-northeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-northeast-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This ap-northeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-northeast-2/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n", "\n", "![This ap-south-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-south-1/introduction_to_amazon_algorithms|imageclassification_caltech|Image-classification-transfer-learning-highlevel.ipynb)\n" ] } ], "metadata": { "instance_type": "ml.t3.medium", "kernelspec": { "display_name": "Python 3 (Data Science)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/datascience-1.0" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.10" }, "notice": "Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." }, "nbformat": 4, "nbformat_minor": 4 }