AI

Code Implementation of a Rapid Disaster Assessment Tool Using IBM’s Open-Source ResNet-50 Model

In this tutorial, we explore an innovative and practical application of the IBM Open Open-50, which shows its ability to classify satellite images of disaster management quickly. Benefiting from pre -fighter nervous networks (CNN), this approach enables users to quickly analyze satellite images to determine and classify disasters affected areas, such as floods, forest fires or earthquake damage. Using Google Colab, we will imagine a step -by -step process to prepare the environment easily, pre -processing, inference, and interpret the results.

First, we install the basic libraries for the photo processing tasks and the percench -based perception.

!pip install torch torchvision matplotlib pillow

We import the necessary libraries and download the IBM-subsidiary of the IBM from Pytorch, and prepare it for inferiority tasks.

import torch
import torchvision.models as models
import torchvision.transforms as transforms
from PIL import Image
import requests
from io import BytesIO
import matplotlib.pyplot as plt


model = models.resnet50(pretrained=True)
model.eval()

Now, we define the standard processing pipeline of the images, change their size and count, turn them into tension, and normalize them to match the requirements of the RESNET-50 input.

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 recover the image of a satellite from a specific URL, processing it in advance, classifying it using the pre-pre-used Resnet-50 model, and depicts the image with its highest prediction. It also prints the five best predictions with the possibilities associated with it.

def classify_satellite_image(url):
    response = requests.get(url)
    img = Image.open(BytesIO(response.content)).convert('RGB')


    input_tensor = preprocess(img)
    input_batch = input_tensor.unsqueeze(0)


    with torch.no_grad():
        output = model(input_batch)


    labels_url = ""
    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 i in range(top5_prob.size(0)):
        print(labels[top5_catid[i]], top5_prob[i].item())

Finally, we download a fire-related satellite image, classify it using the Resnet-50 Pretrained, and visually display it with the five best predictions.

image_url = ""
classify_satellite_image(image_url)

In conclusion, we have succeeded in harnessing the IBM Resnet-50 model in Google Colab to efficiently classify satellite images, support disaster assessments and critical response. The indication indicates that the practical application and access to advanced machine learning models and emphasizes how CNNS is creatively applying the real world challenges. With the minimum setting, we now have a powerful tool at our disposal.


Here is Clap notebook. Also, do not forget to follow us twitter And join us Telegram channel and LinkedIn GrOup. Don’t forget to join 85k+ ml subreddit.


Asif Razzaq is the CEO of Marktechpost Media Inc .. As a pioneer and vision engineer, ASIF is committed to harnessing the potential of artificial intelligence for social goodness. His last endeavor is to launch the artificial intelligence platform, Marktechpost, which highlights its in -depth coverage of machine learning and deep learning news, which is technically intact and can be easily understood by a wide audience. The platform is proud of more than 2 million monthly views, which shows its popularity among the masses.

2025-03-22 03:24:00

Related Articles

Back to top button