Identify rooftop solar panels from satellite imagery using Amazon Rekognition Custom Labels

海外精选
海外精选的内容汇集了全球优质的亚马逊云科技相关技术内容。同时,内容中提到的“AWS” 是 “Amazon Web Services” 的缩写,在此网站不作为商标展示。
0
0
{"value":"Renewable resources like sunlight provide a sustainable and carbon neutral mechanism to generate power. Governments in many countries are providing incentives and subsidies to households to install solar panels as part of small-scale renewable energy schemes. This has created a huge demand for solar panels. Reaching out to potential customers at the right time, through the right channel, and with attractive offers is very crucial for solar and energy companies. They’re looking for cost-efficient approaches and tools to conduct targeted marketing to proactively reach out to potential customers. By identifying the suburbs that have low coverage of solar panel installation at scale, they can maximize their marketing initiatives to those places, so as to maximize the return on their marketing investment.\n\nIn this post, we discuss how you can identify solar panels on rooftops from satellite imagery using [Amazon Rekognition Custom Labels](https://aws.amazon.com/rekognition/custom-labels-features/).\n\n### **The problem**\n\nHigh-resolution satellite imagery of urban areas provides an aerial view of rooftops. You can use these images to identify solar panel installations. But it is a challenging task to automatically identify solar panels with high accuracy, low cost, and in a scalable way.\n\nWith rapid development in computer vision technology, several third-party tools use computer vision to analyze satellite images and identify objects (like solar panels) automatically. However, these tools are expensive and increase the overall cost of marketing. Many organizations have also successfully implemented state-of-the-art computer vision applications to identify the presence of solar panels on the rooftops from the satellite images.\n\nBut the reality is that you need to build your own data science teams that have the specific expertise and experience to build a production machine learning (ML) application for your specific use case. It generally takes months for teams to build a computer vision solution that they can use in production. This leads to an increased cost in building and maintaining such a system.\n\nIs there a simpler and cost-effective solution that helps solar companies quickly build effective computer vision models without building a dedicated data science team for that purpose? Yes, Rekognition Custom Labels is the answer to this question.\n\n\n### **Solution overview**\n\nRekognition Custom Labels is a feature of [Amazon Rekognition](https://aws.amazon.com/rekognition/) that takes care of the heavy lifting of computer vision model development for you, so no computer vision experience is required. You simply provide images with the appropriate labels, train the model, and deploy without having to build the model and fine-tune it. Rekognition Custom Labels has the capability to build highly accurate models with fewer labeled images. This takes away the heavy lifting of model development and helps you focus on developing value-added products and applications to your customers.\n\nIn this post, we show how to label, train, and build a computer vision model to detect rooftops and solar panels from satellite images. We use [Amazon Simple Storage Service](http://aws.amazon.com/s3) (Amazon S3) for storing satellite images, [Amazon SageMaker Ground Truth](https://aws.amazon.com/sagemaker/groundtruth/) for labeling the images with the appropriate labels of interest, and Rekognition Custom Labels for model training and hosting. To test the model output, we use a Jupyter notebook to run Python code to detect custom labels in a supplied image by calling Amazon Rekognition APIs.\n\nThe following diagram illustrates the architecture using AWS services to label the images, and train and host the ML model.\n\n![image.png](https://dev-media.amazoncloud.cn/eed6df67d5f5445daf5521c3a4ce173a_image.png)\n\nThe solution workflow is as follows:\n\n1. Store satellite imagery data in Amazon S3 as the input source.\n2. Use a Ground Truth labeling job to label the images.\n3. Use Amazon Rekognition to train the model with custom labels.\n4. Fine-tune the trained model.\n5. Start the model and analyze the image with the trained model using the Rekognition Custom Labels API.\n\n### **Store satellite imagery data in Amazon S3 as an input source**\n\nThe satellite images of rooftops with and without solar panels are captured from the satellite imagery data providers and stored in an S3 bucket. For our post, we use the images of New South Wales (NSW), Australia, provided by the [Spatial Services, Department of Customer Service NSW](https://portal.spatial.nsw.gov.au/portal/apps/sites/#/home). We have taken the screenshots of the rooftops from this portal and stored those images in the source S3 bucket. These images are labeled using a Ground Truth labeling job, as explained in the next step.\n\n### **Use a Ground Truth labeling job to label the images**\n\nGround Truth is a fully managed data labeling service that makes it easy to build highly accurate training datasets for ML tasks. It has three options:\n\n- [Amazon Mechanical Turk](https://www.mturk.com/), which uses a public workforce to label the data\n- Private, which allows you to create a private workforce from internal teams\n- Vendor, which uses third-party resources for the labeling task\n\nIn this example, we use a private workforce to perform the data labeling job. Refer to [Use Amazon SageMaker Ground Truth to Label Data](https://docs.aws.amazon.com/sagemaker/latest/dg/sms.html) for instructions on creating a private workforce and configuring Ground Truth for a labeling job with bounding boxes.\n\nThe following is an example image of the labeling job. The labeler can draw bounding boxes of the targets with the selected labels indicated by different colors. We used three labels on the images: rooftop, rooftop-panel, and panel to signify rooftops without solar panels, rooftops with solar panels, and just solar panels, respectively.\n\n![image.png](https://dev-media.amazoncloud.cn/287b39e6164c48f88d66abd56300f2cd_image.png)\n\nWhen the labeling job is complete, an output.manifest file is generated and stored in the S3 output location that you specified when creating the labeling job. The following code is an example of one image labeling output in the manifest file:\n\n```\n\n{\n\"source-ref\": \"s3://<your-bucket-name>/blog-images/source-image/03-09-2021/source-image-001.png\",\n“Rekognition-solar-panel-labeling”:{\n \"image_size\": [{\"width\":644,\"height\":560,\"depth\":3}],\n \"annotations\": [\n {\"class_id\":1,\"top\":51,\"left\":188,\"height\":175,\"width\":236},\n {\"class_id\":2,\"top\":58,\"left\":276,\"height\":32,\"width\":105},\n {\"class_id\":0,\"top\":332,\"left\":150,\"height\":192,\"width\":151},\n {\"class_id\":0,\"top\":271,\"left\":354,\"height\":79,\"width\":121}\n ]},\n\"Rekognition-solar-panel-labeling-metadata\": {\n \"objects\": [{\"confidence\":0},{\"confidence\":0},{\"confidence\":0},{\"confidence\":0}],\n \"class-map\":{\n \"1\":\"rooftop-panel\",\n \"2\":\"panel\",\n \"0\":\"rooftop\"},\n \"type\": \"groundtruth/object-detection\",\n \"human-annotated\": \"yes\",\n \"creation-date\": \"2021-09-14T11:30:41.125196\",\n \"job-name\": \"labeling-job/Rekognition-solar-panel-labeling\"\n }\n}\n\n```\n\nThe output manifest file is what we need for the Amazon Rekognition training job. In the next section, we provide step-by-step instructions to create a high-performance ML model to detect objects of interest.\n\n### **Use Amazon Rekognition to train the model with custom labels**\n\nWe now create a project for a custom object detection model, and provide the labeled images to Rekognition Custom Labels to train the model.\n\n1. On the Amazon Rekognition console, choose Use Custom Labels in the navigation pane.\n\n![image.png](https://dev-media.amazoncloud.cn/30c337462be74154866c17f643f0f254_image.png)\n\n2. In the navigation pane, choose **Projects**.\n3. Choose **Create project**.\n\n![image.png](https://dev-media.amazoncloud.cn/678399cbd7654a5184bc95a3e0d5a9f7_image.png)\n\n4. For Project name, enter a unique name.\n5. Choose Create project.\n\n![image.png](https://dev-media.amazoncloud.cn/16ebf743cebb41d99e41bc2150e5ac98_image.png)\n\nNext, we create a dataset for the training job.\n\n6. In the navigation pane, choose Datasets.\n7. Create a dataset based on the manifest file generated by the Ground Truth labeling job.\n\n![image.png](https://dev-media.amazoncloud.cn/99286d8aa37147fb887f1aa2c50adae8_image.png)\n\nWe’re now ready to train a new model.\n\n8. Select the project you created and choose Train new model.\n9. Choose the training dataset you created and choose the test dataset.\n10. Choose Train to start training the model.\n\nYou can create a new test dataset or split the training dataset to use 20% of the training data as the test dataset and the remaining 80% as the training dataset. However, if you split the training dataset, the training and test datasets are randomly selected from the whole dataset every time you train a new model. In this example, we create a separate test dataset to evaluate the trained models.\n\nWe collected an additional 50 satellite images and labeled them using Ground Truth. We then used the output manifest file of this labeling job to create the test dataset.\n\nThis allows us to compare the evaluation metrics of different versions of the model that are trained based on different input datasets. The first training dataset consists of 160 images; the test dataset has 50 images.\n\n![image.png](https://dev-media.amazoncloud.cn/666f7d5ecd964387b363f6d731b52fe3_image.png)\n\n\nWhen the model training process is complete, we can access the evaluation metrics on the Evaluate tab on the model page. Our training job was able to achieve an [F1 score](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/tr-metrics-use.html#tr-f1-metric) of 0.934. The model evaluation metrics are reasonably good considering the number of training images we used and the number of images used for validating the model.\n\n![image.png](https://dev-media.amazoncloud.cn/e053e06bb0204305859e11bb659cbb1d_image.png)\n\n\nAlthough the model evaluation metrics are reasonable, it’s important to understand which images the model incorrectly labels, so as to further fine-tune the model’s performance to make it more robust to handle real-world challenges. In the next section, we describe the process of evaluating the images that have inaccurate labels and retraining the model to achieve better performance.\n\n### **Fine-tune the trained model**\n\nEvaluating incorrect labels inferred by the trained model is a crucial step to further fine-tune the model. To check the detailed test results, we can choose the training job and choose View test results to evaluate the images that the model inaccurately labeled. Evaluating the model performance on test data can help you identify any potential labeling or data source-related issues. For example, the following test image shows an example of false-positive labeling of a rooftop.\n\n\n![image.png](https://dev-media.amazoncloud.cn/41433d2534eb4a2f8b5efeab668a9e92_image.png)\n\n\nAs you can determine from the preceding image, the identified rooftop is correct—it’s the rooftop of a smaller home built on the property. Based on the source image name, we can go back to the dataset to check the labels. We can do this via the Amazon Rekognition console. In the following screenshot, we can determine that the source image wasn’t labeled correctly. The labeler missed labeling that rooftop.\n\n![image.png](https://dev-media.amazoncloud.cn/b0684aac7b604240898fece8cc358eb9_image.png)\n\n\nTo correct the labeling issue, we don’t need to rerun the Ground Truth job or run an adjustment job on the whole dataset. We can easily verify or adjust individual images via the Rekognition Custom Labels console.\n\n1. On the dataset page, choose **Start labeling**.\n\n\n![image.png](https://dev-media.amazoncloud.cn/40501f4787d34b6f944014777a868bf8_image.png)\n\n2. Select the image file that needs adjustment and choose **Draw bounding box**.\n\n\n![image.png](https://dev-media.amazoncloud.cn/d00e92ac8a4346368637e96a0b8520f8_image.png)\n\nOn the labeling page, we can draw or update the bounding boxes on this image.\n\n3. Draw the bounding box around the smaller building and label it as rooftop.\n![image.png](https://dev-media.amazoncloud.cn/f731b30f3eac481bb023a8c430064cd0_image.png)\n\n4. Choose **Done** to save the changes or choose **Next** or **Previous** to navigate through additional images that require adjustments.\n\n\nIn some situations, you might have to provide more images with examples of the rooftops that the model failed to identify correctly. We can collect more images, label them, and retrain the model so that the model can learn the special cases of rooftops and solar panels.\n\nTo add more training images to the training dataset, you can create another Ground Truth job if the number of added images is large and if you need to create a labeling workforce team to label the images. When the labeling job is finished, we get a new manifest file, which contains the bounding box information for the newly added images. Then we need to manually merge the manifest file of the newly added images to the existing manifest file. We use the combined manifest file to create a new training dataset on the Rekognition Custom Labels console and train a more robust model.\n\nAnother option is to add the images directly to the current training dataset if the number of new images isn’t large and one person is sufficient to finish the labeling task on the Amazon Rekognition console. In this project, we directly add another 30 images to the original training dataset and perform labeling on the console.\n\nAfter we complete the label verification and add more images of different rooftop and panel types, we have a second model trained with 190 training images that we evaluate on the same test dataset. The second version of the trained model achieved an F1 score of 0.964, which is an improvement from the earlier score of 0.934. Based on your business requirement, you can further fine-tune the model.\n\n### **Deploy the model and analyze the images using the Rekognition Custom Labels API**\n\nNow that we have trained a model with satisfactory evaluation results, we [deploy the model](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/gs-step-start-model.html) to an endpoint for real-time inference. We analyze a few images using Python code via the Amazon Rekognition API on this deployed model. After you start the model, its status shows as Running.\n\n![image.png](https://dev-media.amazoncloud.cn/1f38bc598f614c82a462e44f5ff6ea25_image.png)\n\n\nNow the model is ready to detect the labels on the new satellite images. We can test the model by running the provided sample Python API code. On the model page, choose **API Code**.\n\n![image.png](https://dev-media.amazoncloud.cn/19a743a2dae84f97a27eb44c6d6590a4_image.png)\n\nSelect **Python** to review the sample code to start the model, analyze images, and stop the model.\n\n![image.png](https://dev-media.amazoncloud.cn/2daf71436e9147a986b27ea01b117ff8_image.png)\n\n\nCopy the Python code in the **Analyze image** section into a Jupyter notebook, which can be running on your laptop.\n\n\n![image.png](https://dev-media.amazoncloud.cn/e1cd54aea7c640c18919318e06010216_image.png)\n\n\nTo set up the environment to run the code, we need to install the AWS SDKs that we want to use and configure the security credentials to access the AWS resources. For instructions, refer to [Set Up the AWS CLI and AWS SDKs](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/su-awscli-sdk.html).\n\nUpload a test image to an S3 bucket. In the **Analyze image** Python code, substitute the variable MY_BUCKET with the bucket name that has the test image and replace MY_IMAGE_KEY with the file name of the test image.\n\n![image.png](https://dev-media.amazoncloud.cn/5c2f7b61dfd44587a6009dd7aa068628_image.png)\n\nThe following screenshot shows a sample response of running the Python code.\n\n![image.png](https://dev-media.amazoncloud.cn/15cea977eba54a2f8927d9bf201c3305_image.png)\n\n\nThe following output image shows that the model has successfully detected three labels: rooftop, rooftop-panel, and panel.\n\n![image.png](https://dev-media.amazoncloud.cn/846a8e301f1448399394382c4cc83a08_image.png)\n\n### **Clean up**\n\nAfter testing, we can stop the model to avoid any unnecessary charges incurred to run the model.\n\n![image.png](https://dev-media.amazoncloud.cn/a019ab79ef18403da4c868218e0fe3db_image.png)\n\n\n### **Conclusion**\n\nIn this post, we showed you how to detect rooftops and solar panels from the satellite imagery by building custom computer vision models with Rekognition Custom Labels. We demonstrated how Rekognition Custom Labels manages the model training by taking care of the deep learning complexities behind the scenes. We also demonstrated how to use Ground Truth to label the training images at scale. Furthermore, we discussed mechanisms to improve model accuracy by correcting the labeling of the images on the fly and retraining the model with the dataset. Power utility companies can use this solution to detect houses without solar panels to send offers and promotions to achieve efficient targeted marketing.\n\nTo learn more about how Rekognition Custom Labels can help your business, visit [Amazon Rekognition Custom Labels](Amazon Rekognition Custom Labels) or [contact AWS Sales](https://pages.awscloud.com/Amazon-Rekognition-Contact-Us-Registration.html).\n\n#### **About the Authors**\n\n![image.png](https://dev-media.amazoncloud.cn/56b5b8f5f2834e6c9ace4ab0165f8b78_image.png)\n\n**Melanie Li** is a Senior AI/ML Specialist TAM at AWS based in Sydney, Australia. She helps enterprise customers to build solutions leveraging the state-of-the-art AI/ML tools on AWS and provides guidance on architecting and implementing machine learning solutions with best practices. In her spare time, she loves to explore nature outdoors and spend time with family and friends.\n\n\n![image.png](https://dev-media.amazoncloud.cn/f23b7151cf154020b1e5feeb6b9ed565_image.png)\n\n\n**Santosh Kulkarni** is a Solutions Architect at Amazon Web Services. He works closely with enterprise customers to accelerate their Cloud journey. He is also passionate about building large-scale distributed applications to solve business problems using his knowledge in Machine Learning, Big Data, and Software Development.\n\n![image.png](https://dev-media.amazoncloud.cn/9fb45bdabc374de19f603173bf0b4f19_image.png)\n\n\n**Dr. Baichuan Sun** is a Senior Data Scientist at AWS AI/ML. He is passionate about solving strategic business problems with customers using data-driven methodology on the cloud, and he has been leading projects in challenging areas including robotics computer vision, time series forecasting, price optimization, predictive maintenance, pharmaceutical development, product recommendation system, etc. In his spare time he enjoys traveling and hanging out with family.","render":"<p>Renewable resources like sunlight provide a sustainable and carbon neutral mechanism to generate power. Governments in many countries are providing incentives and subsidies to households to install solar panels as part of small-scale renewable energy schemes. This has created a huge demand for solar panels. Reaching out to potential customers at the right time, through the right channel, and with attractive offers is very crucial for solar and energy companies. They’re looking for cost-efficient approaches and tools to conduct targeted marketing to proactively reach out to potential customers. By identifying the suburbs that have low coverage of solar panel installation at scale, they can maximize their marketing initiatives to those places, so as to maximize the return on their marketing investment.</p>\n<p>In this post, we discuss how you can identify solar panels on rooftops from satellite imagery using <a href=\"https://aws.amazon.com/rekognition/custom-labels-features/\" target=\"_blank\">Amazon Rekognition Custom Labels</a>.</p>\n<h3><a id=\"The_problem_4\"></a><strong>The problem</strong></h3>\n<p>High-resolution satellite imagery of urban areas provides an aerial view of rooftops. You can use these images to identify solar panel installations. But it is a challenging task to automatically identify solar panels with high accuracy, low cost, and in a scalable way.</p>\n<p>With rapid development in computer vision technology, several third-party tools use computer vision to analyze satellite images and identify objects (like solar panels) automatically. However, these tools are expensive and increase the overall cost of marketing. Many organizations have also successfully implemented state-of-the-art computer vision applications to identify the presence of solar panels on the rooftops from the satellite images.</p>\n<p>But the reality is that you need to build your own data science teams that have the specific expertise and experience to build a production machine learning (ML) application for your specific use case. It generally takes months for teams to build a computer vision solution that they can use in production. This leads to an increased cost in building and maintaining such a system.</p>\n<p>Is there a simpler and cost-effective solution that helps solar companies quickly build effective computer vision models without building a dedicated data science team for that purpose? Yes, Rekognition Custom Labels is the answer to this question.</p>\n<h3><a id=\"Solution_overview_15\"></a><strong>Solution overview</strong></h3>\n<p>Rekognition Custom Labels is a feature of <a href=\"https://aws.amazon.com/rekognition/\" target=\"_blank\">Amazon Rekognition</a> that takes care of the heavy lifting of computer vision model development for you, so no computer vision experience is required. You simply provide images with the appropriate labels, train the model, and deploy without having to build the model and fine-tune it. Rekognition Custom Labels has the capability to build highly accurate models with fewer labeled images. This takes away the heavy lifting of model development and helps you focus on developing value-added products and applications to your customers.</p>\n<p>In this post, we show how to label, train, and build a computer vision model to detect rooftops and solar panels from satellite images. We use <a href=\"http://aws.amazon.com/s3\" target=\"_blank\">Amazon Simple Storage Service</a> (Amazon S3) for storing satellite images, <a href=\"https://aws.amazon.com/sagemaker/groundtruth/\" target=\"_blank\">Amazon SageMaker Ground Truth</a> for labeling the images with the appropriate labels of interest, and Rekognition Custom Labels for model training and hosting. To test the model output, we use a Jupyter notebook to run Python code to detect custom labels in a supplied image by calling Amazon Rekognition APIs.</p>\n<p>The following diagram illustrates the architecture using AWS services to label the images, and train and host the ML model.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/eed6df67d5f5445daf5521c3a4ce173a_image.png\" alt=\"image.png\" /></p>\n<p>The solution workflow is as follows:</p>\n<ol>\n<li>Store satellite imagery data in Amazon S3 as the input source.</li>\n<li>Use a Ground Truth labeling job to label the images.</li>\n<li>Use Amazon Rekognition to train the model with custom labels.</li>\n<li>Fine-tune the trained model.</li>\n<li>Start the model and analyze the image with the trained model using the Rekognition Custom Labels API.</li>\n</ol>\n<h3><a id=\"Store_satellite_imagery_data_in_Amazon_S3_as_an_input_source_33\"></a><strong>Store satellite imagery data in Amazon S3 as an input source</strong></h3>\n<p>The satellite images of rooftops with and without solar panels are captured from the satellite imagery data providers and stored in an S3 bucket. For our post, we use the images of New South Wales (NSW), Australia, provided by the <a href=\"https://portal.spatial.nsw.gov.au/portal/apps/sites/#/home\" target=\"_blank\">Spatial Services, Department of Customer Service NSW</a>. We have taken the screenshots of the rooftops from this portal and stored those images in the source S3 bucket. These images are labeled using a Ground Truth labeling job, as explained in the next step.</p>\n<h3><a id=\"Use_a_Ground_Truth_labeling_job_to_label_the_images_37\"></a><strong>Use a Ground Truth labeling job to label the images</strong></h3>\n<p>Ground Truth is a fully managed data labeling service that makes it easy to build highly accurate training datasets for ML tasks. It has three options:</p>\n<ul>\n<li><a href=\"https://www.mturk.com/\" target=\"_blank\">Amazon Mechanical Turk</a>, which uses a public workforce to label the data</li>\n<li>Private, which allows you to create a private workforce from internal teams</li>\n<li>Vendor, which uses third-party resources for the labeling task</li>\n</ul>\n<p>In this example, we use a private workforce to perform the data labeling job. Refer to <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sms.html\" target=\"_blank\">Use Amazon SageMaker Ground Truth to Label Data</a> for instructions on creating a private workforce and configuring Ground Truth for a labeling job with bounding boxes.</p>\n<p>The following is an example image of the labeling job. The labeler can draw bounding boxes of the targets with the selected labels indicated by different colors. We used three labels on the images: rooftop, rooftop-panel, and panel to signify rooftops without solar panels, rooftops with solar panels, and just solar panels, respectively.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/287b39e6164c48f88d66abd56300f2cd_image.png\" alt=\"image.png\" /></p>\n<p>When the labeling job is complete, an output.manifest file is generated and stored in the S3 output location that you specified when creating the labeling job. The following code is an example of one image labeling output in the manifest file:</p>\n<pre><code class=\"lang-\">\n{\n&quot;source-ref&quot;: &quot;s3://&lt;your-bucket-name&gt;/blog-images/source-image/03-09-2021/source-image-001.png&quot;,\n“Rekognition-solar-panel-labeling”:{\n &quot;image_size&quot;: [{&quot;width&quot;:644,&quot;height&quot;:560,&quot;depth&quot;:3}],\n &quot;annotations&quot;: [\n {&quot;class_id&quot;:1,&quot;top&quot;:51,&quot;left&quot;:188,&quot;height&quot;:175,&quot;width&quot;:236},\n {&quot;class_id&quot;:2,&quot;top&quot;:58,&quot;left&quot;:276,&quot;height&quot;:32,&quot;width&quot;:105},\n {&quot;class_id&quot;:0,&quot;top&quot;:332,&quot;left&quot;:150,&quot;height&quot;:192,&quot;width&quot;:151},\n {&quot;class_id&quot;:0,&quot;top&quot;:271,&quot;left&quot;:354,&quot;height&quot;:79,&quot;width&quot;:121}\n ]},\n&quot;Rekognition-solar-panel-labeling-metadata&quot;: {\n &quot;objects&quot;: [{&quot;confidence&quot;:0},{&quot;confidence&quot;:0},{&quot;confidence&quot;:0},{&quot;confidence&quot;:0}],\n &quot;class-map&quot;:{\n &quot;1&quot;:&quot;rooftop-panel&quot;,\n &quot;2&quot;:&quot;panel&quot;,\n &quot;0&quot;:&quot;rooftop&quot;},\n &quot;type&quot;: &quot;groundtruth/object-detection&quot;,\n &quot;human-annotated&quot;: &quot;yes&quot;,\n &quot;creation-date&quot;: &quot;2021-09-14T11:30:41.125196&quot;,\n &quot;job-name&quot;: &quot;labeling-job/Rekognition-solar-panel-labeling&quot;\n }\n}\n\n</code></pre>\n<p>The output manifest file is what we need for the Amazon Rekognition training job. In the next section, we provide step-by-step instructions to create a high-performance ML model to detect objects of interest.</p>\n<h3><a id=\"Use_Amazon_Rekognition_to_train_the_model_with_custom_labels_82\"></a><strong>Use Amazon Rekognition to train the model with custom labels</strong></h3>\n<p>We now create a project for a custom object detection model, and provide the labeled images to Rekognition Custom Labels to train the model.</p>\n<ol>\n<li>On the Amazon Rekognition console, choose Use Custom Labels in the navigation pane.</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/30c337462be74154866c17f643f0f254_image.png\" alt=\"image.png\" /></p>\n<ol start=\"2\">\n<li>In the navigation pane, choose <strong>Projects</strong>.</li>\n<li>Choose <strong>Create project</strong>.</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/678399cbd7654a5184bc95a3e0d5a9f7_image.png\" alt=\"image.png\" /></p>\n<ol start=\"4\">\n<li>For Project name, enter a unique name.</li>\n<li>Choose Create project.</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/16ebf743cebb41d99e41bc2150e5ac98_image.png\" alt=\"image.png\" /></p>\n<p>Next, we create a dataset for the training job.</p>\n<ol start=\"6\">\n<li>In the navigation pane, choose Datasets.</li>\n<li>Create a dataset based on the manifest file generated by the Ground Truth labeling job.</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/99286d8aa37147fb887f1aa2c50adae8_image.png\" alt=\"image.png\" /></p>\n<p>We’re now ready to train a new model.</p>\n<ol start=\"8\">\n<li>Select the project you created and choose Train new model.</li>\n<li>Choose the training dataset you created and choose the test dataset.</li>\n<li>Choose Train to start training the model.</li>\n</ol>\n<p>You can create a new test dataset or split the training dataset to use 20% of the training data as the test dataset and the remaining 80% as the training dataset. However, if you split the training dataset, the training and test datasets are randomly selected from the whole dataset every time you train a new model. In this example, we create a separate test dataset to evaluate the trained models.</p>\n<p>We collected an additional 50 satellite images and labeled them using Ground Truth. We then used the output manifest file of this labeling job to create the test dataset.</p>\n<p>This allows us to compare the evaluation metrics of different versions of the model that are trained based on different input datasets. The first training dataset consists of 160 images; the test dataset has 50 images.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/666f7d5ecd964387b363f6d731b52fe3_image.png\" alt=\"image.png\" /></p>\n<p>When the model training process is complete, we can access the evaluation metrics on the Evaluate tab on the model page. Our training job was able to achieve an <a href=\"https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/tr-metrics-use.html#tr-f1-metric\" target=\"_blank\">F1 score</a> of 0.934. The model evaluation metrics are reasonably good considering the number of training images we used and the number of images used for validating the model.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/e053e06bb0204305859e11bb659cbb1d_image.png\" alt=\"image.png\" /></p>\n<p>Although the model evaluation metrics are reasonable, it’s important to understand which images the model incorrectly labels, so as to further fine-tune the model’s performance to make it more robust to handle real-world challenges. In the next section, we describe the process of evaluating the images that have inaccurate labels and retraining the model to achieve better performance.</p>\n<h3><a id=\"Finetune_the_trained_model_129\"></a><strong>Fine-tune the trained model</strong></h3>\n<p>Evaluating incorrect labels inferred by the trained model is a crucial step to further fine-tune the model. To check the detailed test results, we can choose the training job and choose View test results to evaluate the images that the model inaccurately labeled. Evaluating the model performance on test data can help you identify any potential labeling or data source-related issues. For example, the following test image shows an example of false-positive labeling of a rooftop.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/41433d2534eb4a2f8b5efeab668a9e92_image.png\" alt=\"image.png\" /></p>\n<p>As you can determine from the preceding image, the identified rooftop is correct—it’s the rooftop of a smaller home built on the property. Based on the source image name, we can go back to the dataset to check the labels. We can do this via the Amazon Rekognition console. In the following screenshot, we can determine that the source image wasn’t labeled correctly. The labeler missed labeling that rooftop.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/b0684aac7b604240898fece8cc358eb9_image.png\" alt=\"image.png\" /></p>\n<p>To correct the labeling issue, we don’t need to rerun the Ground Truth job or run an adjustment job on the whole dataset. We can easily verify or adjust individual images via the Rekognition Custom Labels console.</p>\n<ol>\n<li>On the dataset page, choose <strong>Start labeling</strong>.</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/40501f4787d34b6f944014777a868bf8_image.png\" alt=\"image.png\" /></p>\n<ol start=\"2\">\n<li>Select the image file that needs adjustment and choose <strong>Draw bounding box</strong>.</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/d00e92ac8a4346368637e96a0b8520f8_image.png\" alt=\"image.png\" /></p>\n<p>On the labeling page, we can draw or update the bounding boxes on this image.</p>\n<ol start=\"3\">\n<li>\n<p>Draw the bounding box around the smaller building and label it as rooftop.<br />\n<img src=\"https://dev-media.amazoncloud.cn/f731b30f3eac481bb023a8c430064cd0_image.png\" alt=\"image.png\" /></p>\n</li>\n<li>\n<p>Choose <strong>Done</strong> to save the changes or choose <strong>Next</strong> or <strong>Previous</strong> to navigate through additional images that require adjustments.</p>\n</li>\n</ol>\n<p>In some situations, you might have to provide more images with examples of the rooftops that the model failed to identify correctly. We can collect more images, label them, and retrain the model so that the model can learn the special cases of rooftops and solar panels.</p>\n<p>To add more training images to the training dataset, you can create another Ground Truth job if the number of added images is large and if you need to create a labeling workforce team to label the images. When the labeling job is finished, we get a new manifest file, which contains the bounding box information for the newly added images. Then we need to manually merge the manifest file of the newly added images to the existing manifest file. We use the combined manifest file to create a new training dataset on the Rekognition Custom Labels console and train a more robust model.</p>\n<p>Another option is to add the images directly to the current training dataset if the number of new images isn’t large and one person is sufficient to finish the labeling task on the Amazon Rekognition console. In this project, we directly add another 30 images to the original training dataset and perform labeling on the console.</p>\n<p>After we complete the label verification and add more images of different rooftop and panel types, we have a second model trained with 190 training images that we evaluate on the same test dataset. The second version of the trained model achieved an F1 score of 0.964, which is an improvement from the earlier score of 0.934. Based on your business requirement, you can further fine-tune the model.</p>\n<h3><a id=\"Deploy_the_model_and_analyze_the_images_using_the_Rekognition_Custom_Labels_API_170\"></a><strong>Deploy the model and analyze the images using the Rekognition Custom Labels API</strong></h3>\n<p>Now that we have trained a model with satisfactory evaluation results, we <a href=\"https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/gs-step-start-model.html\" target=\"_blank\">deploy the model</a> to an endpoint for real-time inference. We analyze a few images using Python code via the Amazon Rekognition API on this deployed model. After you start the model, its status shows as Running.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/1f38bc598f614c82a462e44f5ff6ea25_image.png\" alt=\"image.png\" /></p>\n<p>Now the model is ready to detect the labels on the new satellite images. We can test the model by running the provided sample Python API code. On the model page, choose <strong>API Code</strong>.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/19a743a2dae84f97a27eb44c6d6590a4_image.png\" alt=\"image.png\" /></p>\n<p>Select <strong>Python</strong> to review the sample code to start the model, analyze images, and stop the model.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/2daf71436e9147a986b27ea01b117ff8_image.png\" alt=\"image.png\" /></p>\n<p>Copy the Python code in the <strong>Analyze image</strong> section into a Jupyter notebook, which can be running on your laptop.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/e1cd54aea7c640c18919318e06010216_image.png\" alt=\"image.png\" /></p>\n<p>To set up the environment to run the code, we need to install the AWS SDKs that we want to use and configure the security credentials to access the AWS resources. For instructions, refer to <a href=\"https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/su-awscli-sdk.html\" target=\"_blank\">Set Up the AWS CLI and AWS SDKs</a>.</p>\n<p>Upload a test image to an S3 bucket. In the <strong>Analyze image</strong> Python code, substitute the variable MY_BUCKET with the bucket name that has the test image and replace MY_IMAGE_KEY with the file name of the test image.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/5c2f7b61dfd44587a6009dd7aa068628_image.png\" alt=\"image.png\" /></p>\n<p>The following screenshot shows a sample response of running the Python code.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/15cea977eba54a2f8927d9bf201c3305_image.png\" alt=\"image.png\" /></p>\n<p>The following output image shows that the model has successfully detected three labels: rooftop, rooftop-panel, and panel.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/846a8e301f1448399394382c4cc83a08_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Clean_up_207\"></a><strong>Clean up</strong></h3>\n<p>After testing, we can stop the model to avoid any unnecessary charges incurred to run the model.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/a019ab79ef18403da4c868218e0fe3db_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Conclusion_214\"></a><strong>Conclusion</strong></h3>\n<p>In this post, we showed you how to detect rooftops and solar panels from the satellite imagery by building custom computer vision models with Rekognition Custom Labels. We demonstrated how Rekognition Custom Labels manages the model training by taking care of the deep learning complexities behind the scenes. We also demonstrated how to use Ground Truth to label the training images at scale. Furthermore, we discussed mechanisms to improve model accuracy by correcting the labeling of the images on the fly and retraining the model with the dataset. Power utility companies can use this solution to detect houses without solar panels to send offers and promotions to achieve efficient targeted marketing.</p>\n<p>To learn more about how Rekognition Custom Labels can help your business, visit [Amazon Rekognition Custom Labels](Amazon Rekognition Custom Labels) or <a href=\"https://pages.awscloud.com/Amazon-Rekognition-Contact-Us-Registration.html\" target=\"_blank\">contact AWS Sales</a>.</p>\n<h4><a id=\"About_the_Authors_220\"></a><strong>About the Authors</strong></h4>\n<p><img src=\"https://dev-media.amazoncloud.cn/56b5b8f5f2834e6c9ace4ab0165f8b78_image.png\" alt=\"image.png\" /></p>\n<p><strong>Melanie Li</strong> is a Senior AI/ML Specialist TAM at AWS based in Sydney, Australia. She helps enterprise customers to build solutions leveraging the state-of-the-art AI/ML tools on AWS and provides guidance on architecting and implementing machine learning solutions with best practices. In her spare time, she loves to explore nature outdoors and spend time with family and friends.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/f23b7151cf154020b1e5feeb6b9ed565_image.png\" alt=\"image.png\" /></p>\n<p><strong>Santosh Kulkarni</strong> is a Solutions Architect at Amazon Web Services. He works closely with enterprise customers to accelerate their Cloud journey. He is also passionate about building large-scale distributed applications to solve business problems using his knowledge in Machine Learning, Big Data, and Software Development.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/9fb45bdabc374de19f603173bf0b4f19_image.png\" alt=\"image.png\" /></p>\n<p><strong>Dr. Baichuan Sun</strong> is a Senior Data Scientist at AWS AI/ML. He is passionate about solving strategic business problems with customers using data-driven methodology on the cloud, and he has been leading projects in challenging areas including robotics computer vision, time series forecasting, price optimization, predictive maintenance, pharmaceutical development, product recommendation system, etc. In his spare time he enjoys traveling and hanging out with family.</p>\n"}
目录
亚马逊云科技解决方案 基于行业客户应用场景及技术领域的解决方案
联系亚马逊云科技专家
亚马逊云科技解决方案
基于行业客户应用场景及技术领域的解决方案
联系专家
0
目录
关闭
contact-us