Code Implementation Of A Rapid Disaster Assessment Tool Using Ibm’s Open-source Resnet-50 Model

Trending 4 weeks ago
ARTICLE AD BOX

In this tutorial, we research an innovative and applicable exertion of IBM’s open-source ResNet-50 deep learning model, showcasing its capacity to categorize outer imagery for disaster guidance rapidly. Leveraging pretrained convolutional neural networks (CNNs), this attack empowers users to swiftly analyse outer images to place and categorize disaster-affected areas, specified arsenic floods, wildfires, aliases earthquake damage. Using Google Colab, we’ll locomotion done a step-by-step process to easy group up nan environment, preprocess images, execute inference, and construe results.

First, we instal basal libraries for PyTorch-based image processing and visualization tasks.

!pip instal torch torchvision matplotlib pillow

We import basal libraries and load nan pretrained IBM-supported ResNet-50 exemplary from PyTorch, preparing it for conclusion tasks.

import torch import torchvision.models arsenic models import torchvision.transforms arsenic transforms from PIL import Image import requests from io import BytesIO import matplotlib.pyplot arsenic plt model = models.resnet50(pretrained=True) model.eval()

Now, we specify nan modular preprocessing pipeline for images, resizing and cropping them, converting them into tensors, and normalizing them to lucifer ResNet-50’s input requirements.

preprocess = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize( mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225] ) ])

Here, we retrieve a outer image from a fixed URL, preprocess it, categorize it utilizing nan pretrained ResNet-50 model, and visualize nan image pinch its apical prediction. It besides prints nan apical 5 predictions pinch associated probabilities.

def classify_satellite_image(url): consequence = requests.get(url) img = Image.open(BytesIO(response.content)).convert('RGB') input_tensor = preprocess(img) input_batch = input_tensor.unsqueeze(0) pinch torch.no_grad(): output = model(input_batch) labels_url = "https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt" labels = requests.get(labels_url).text.split("n") probabilities = torch.nn.functional.softmax(output[0], dim=0) top5_prob, top5_catid = torch.topk(probabilities, 5) plt.imshow(img) plt.axis('off') plt.title("Top Prediction: {}".format(labels[top5_catid[0]])) plt.show() print("Top 5 Predictions:") for one successful range(top5_prob.size(0)): print(labels[top5_catid[i]], top5_prob[i].item())

Finally, we download a wildfire-related outer image, categorize it utilizing nan pretrained ResNet-50 model, and visually show it on pinch its apical 5 predictions.

image_url = "https://upload.wikimedia.org/wikipedia/commons/0/05/Burnout_ops_on_Mangum_Fire_McCall_Smokejumpers.jpg" classify_satellite_image(image_url)

In conclusion, we’ve successfully harnessed IBM’s open-source ResNet-50 exemplary successful Google Colab to efficiently categorize outer imagery, supporting captious disaster appraisal and consequence tasks. The attack outlined demonstrates nan practicality and accessibility of precocious machine learning models and emphasizes really pretrained CNNs tin beryllium creatively applied to real-world challenges. With minimal setup, we now person a powerful instrumentality astatine our disposal.


Here is nan Colab Notebook. Also, don’t hide to travel america on Twitter and subordinate our Telegram Channel and LinkedIn Group. Don’t Forget to subordinate our 85k+ ML SubReddit.

Asif Razzaq is nan CEO of Marktechpost Media Inc.. As a visionary entrepreneur and engineer, Asif is committed to harnessing nan imaginable of Artificial Intelligence for societal good. His astir caller endeavor is nan motorboat of an Artificial Intelligence Media Platform, Marktechpost, which stands retired for its in-depth sum of instrumentality learning and heavy learning news that is some technically sound and easy understandable by a wide audience. The level boasts of complete 2 cardinal monthly views, illustrating its fame among audiences.

More