- MacOS12.1
- Python3.6
- 動作を保証しません。
- コードは初心者です。
- API の python モジュールを lambda-layer で管理するように修正
- WebApp は Create-react-app ベースで動くように修正
- 存在しなかった Inference.py を追加
- そのままでは動かない
- inference.py が存在しない
- マニュアルがわかりにくい
- React の依存関係が古い
- lambda Layer 展開(新規に作成) Pillow.numpy.chalice をこのレイヤーで管理する。AWS にデプロイを実行する
cd API-sls
./deploy.sh
- deployment.zip の作成
cd ../API
./zip.sh
- s3-Lambda にパッケージインストール
cd ../s3-Lambda
pip install -r requirements.txt -t .
- プロジェクトルートで deploy コマンドを実施する (react アプリがデプロイされる。メールアドレスにログイン情報が送信される)
./deploy [email protected]
-
最初に作成した lambda レイヤーを Lambda:APIhandler に紐付ける
-
アプリにログインし、「学習」を選び、「エンドポイントを作成」にチェックを付け「トレーニング開始」を実行する。 ・作成されたエンドポイントを「エンドポイント設定」に登録する
-
完了
This React based Web application lets you detect corrosion using Machine Learning models created with Amazon SageMaker.
This application consists of many components:
API
- Contains code for the Api. Uses the AWS chalice framework.DDB
- contains the CloudFormation template for creating DynamoDB tables.s3-Lambda
- contains code for Lambda functions which are configured as a S3 Trigger and Cloudformation template for creating these resources.StepFunctions
- contains source code for Lambda functions used in Step functions workflow. Also includes Cloudformation template to create step functions.WebApp
- contains React web application code.
- Install NodeJS version 10.20.1
- AWS CLI
- AWS SAM CLI
- Python 3.6
- AWS Chalice
- Create a new React App by referring the steps outlined at https://reactjs.org/docs/create-a-new-react-app.html and add the React source code found in the WebApp folder to the newly created React App.
In order to deploy the solution, clone this repo and run the following command in your terminal. The command takes an Email ID as a parameter. An email wil be set with Login credentials for the React Web Application.
./deploy.sh EMAIL_ID
Once the deployment is complete, copy the CloudFront URL displayed in your terminal and open it in a Browser.
Follow these steps to Train a new model
- Login to the Web App and navigate to the menu option Model Training
- In the JSON parameter payload displayed under SageMaker Training Parameters, provide a unique name for the Training Job by setting the TrainingJobName value.
- Click on Submit Training Job
- By default the Create Endpoint checkbox will remain checked. In this mode, once the training job completes and a new model gets created, the model gets automatically deployed to a SageMaker endpoint. Model deployment to a SageMaker endpoint can take between 5-10 minutes. Navigate to the SageMaker endpoints tab to see the status as shown.
If you have a SageMaker model which was created outside this App that you'd like to it deploy to a SageMaker endpoint, you can use the Create Endpoint function. In order to deploy the model to a new endpoint
- Copy the name of the SageMaker Training Job which was used to create the required model.
- Enter this name in the SageMaker Endpoint parameters JSON document as shown and click on Create Endpoint. It takes several minutes for the endpoint to be available.
Now that you've created a new SageMaker endpoint, you will need to configure the React Web App to make use of this new endpoint to use the machine learning model for performing an inference. To do this
- Copy the new endpoint name as listed under the SageMaker Endpoints tab.
- Paste the endpoint name in the New Endpoint text box and click on Promote Endpoint
If you'd like to detect corrosion found in a single image, navigate to the Home page and choose the Image file. Click on the Analyze corrosion button. This will use th new model endpoint to detect corrosion and will display the percentage of corrosion found.
If you have lots if images you can Analyze these in batches. Create a Zip file with these images and navigate to the Batch Analysis menu option. Choose the Zip file and click on Upload. This action triggers off a backend process to analyze each image for Corrosion and the results will be displayed in the App.
To remove the deployed solution from your AWS account, delete all the Cloudformation Stacks whose names have the prefix "corrosion-detection". You should also delete any SageMaker endpoints provisioned for inference.