กลับไปหน้ารวมไฟล์
safe-or-not-prediction-with-machine-learning-model-ai-e2a6cd-en.md

Elephants are the largest land mammals and are highly sensitive and caring animals, much like humans. They are highly intelligent animals with complex emotions, feelings, compassion and self-awareness (elephants are one of very few species to recognize themselves in a mirror!). They pick up sounds of rumbles with their feet and they can hear low-frequency communications over long distances though the vibrations that come up through their feet and into their ears. Like humans, elephants mourn the death of their love ones. An elephant never forgets.

But these wonderful creatures are in grave danger. Once common throughout Africa and Asia, elephant numbers fell dramatically in the 19th and 20th centuries, largely due to the ivory trade and habitat loss. While some populations are now stable, poaching, human-wildlife conflict and habitat destruction continue to threaten the species.

African elephant populations have fallen from an estimated 12 million a century ago to some 400, 000. In recent years, at least 20, 000 elephants have been killed in Africa each year for their tusks. African forest elephants have been the worst hit. Their populations declined by 62% between 2002-2011 and they have lost 30% of their geographical range, with African savanna elephants declining by 30% between 2007-2014. This dramatic decline has continued and even accelerated with cumulative losses of up to 90% in some landscapes between 2011 and 2015. Today, the greatest threat to African elephants is wildlife crime, primarily poaching for the illegal ivory trade, while the greatest threat to Asian elephants is habitat loss, which results in human-elephant conflict.

Project Perspective

Safe or Not: Prediction with Machine Learning model (AI) is a sophisticated exploration of on-device AI (TinyML) and sensor-to-hardware interaction. By focusing on the essential building blocks—the machine learning model and multiple sensors—you'll learn how to communicate and predict hazards using specialized software logic and a robust hardware setup.

Edge Impulse

Edge Impulse enables developers to create the next generation of intelligent device solutions with embedded machine learning. In this project, we will be creating a machine learning model with the help of Edge impulse. Using some datasets, we will train the model to differentiate between different types of audio, which are sounds made by an elephant when it's safe and when it's not.

Technical Implementation: Machine Learning and Sensors

The project reveals the hidden layers of simple hazard-to-AI interaction:

  • Sensing layer: The primary sensor is a microphone, acting as the "ears" of the project, collecting a constant stream of audio data from the elephant's environment.
  • Inference layer: The Arduino uses a pre-trained machine learning model (TinyML) to analyze audio patterns and classify them as "Safe" or "Danger".
  • Processing Logic layer: The Arduino code follows a specialized "inference" strategy: it captures audio samples and passes them into the locally stored AI model.
  • Conversion layer: The AI model outputs a probability (e.g., 90% Safe, 10% Danger) which the Arduino uses to trigger alerts.
  • Display/Alert layer: The system can be connected to alert mechanisms like beacon lights or radio signals to warn rangers of potential danger.

Step 01: Acquire Data

I have not used any devices to capture data. Instead, I created training and test datasets using the sounds from Elephant Voices database and youtube. I have split the sample to avoid the noise and increase the accuracy of the model.

I have created a dataset under two labels: Safe and Danger.

Step 02: Create Impulse

After creating my training dataset, I designed an impulse. An impulse takes the raw data, slices it up in smaller windows, uses signal processing blocks to extract features, and then uses a learning block to classify new data. Signal processing blocks always return the same values for the same input and are used to make raw data easier to process, while learning blocks learn from past experiences.

For this project, we will be using "MFCC" signal processing block which extracts features from audio signals using Mel Frequency Cepstral Coefficents.

Then pass this simplified audio data into a Neural Network block, which will learn patterns from data, and can apply these to new data and classify them. This is great for categorizing movement or recognizing audio.

Step 03: MFCC configuration

Do not change the default parameters during the configuration.

Scroll down and click 'Save parameters'. This will redirect you to the 'Generate Features' page.

The feature explorer presents you with a visualisation of the generated MFCC.

Step 04: Neural Network configuration

Now, it's time to start training a neural network. Neural networks are algorithms, modeled loosely after the human brain, that can learn to recognize patterns that appear in their training data. The network that we're training here will take the MFCC as an input, and try to map this to one of two classes—safe and danger.

I had to train my model a few times with different combinations - number of training cycles and neural network architecture presets.

The accuracy of this Machine Learning model can be improved by acquiring more data and we need to have minimum 10 minutes of data for each label.

Step 04: Model testing

You can test the validity of your model by this model testing. I tested twenty-seven samples and my model recognised eight of them. If I had more data under each label, this ML model would have been more accurate.

Step 05: Deployment

The ML model is now ready for deployment. This makes the model run without an internet connection, minimizes latency, and runs with minimal power consumption. You can either create a library or build firmware for your development board.

I have turned my audio classification model into optimized source code that can run on any device, for example: Arduino Nano 33 BLE sense.

The device can be connected to the elephant collar and be implemented to prevent danger and threats to the diminishing elephant population.

Hardware Infrastructure

  • Arduino Nano 33 BLE Sense: The tiny AI-ready "brain" of the project, managing the high-performance inference tasks and coordinating the sensors. Its built-in microphone is crucial for this audio-based application.
  • Elephant Collar: Houses the microcontroller and power source, allowing the system to be deployed on the animal.
  • Alert System: This could be a beacon light, radio transmitter, or other mechanism to warn rangers when a "Danger" classification is made.
  • Breadboard & Jumper Wires: For prototyping the circuit during development.
  • Micro-USB Cable: Used to program the Arduino and provide power during development.

Final and complete idea

To make things more interesting and effective, an RFID microchip could be fitted to the elephant collar or a passive RFID tag can be attached to the elephant's ear. Each elephant will have a unique ID and with the help of Ultra High frequency antennas and Sparkfun's simultaneous RFID readers, we would be able to detect when the elephant is within a safe distance away from poaching risk areas or places where people reside. Simultaneous RFID readers are capable of reading multiple tags simultaneously. If the elephant is approaching, the RFID reader will be able to detect as it can calculate the distance between the certain RFID tag and the reader. If the elephant is at risk, the park or forest rangers can take the appropriate actions.

The RFID reader can be connected to the microcontroller at around 1 or 2 km away from areas where people live or where poaching activity is high. If the system detects an approaching elephant, the microcontroller is programmed to automatically turn on a beacon light and alert the people residing in that area.

This would also be helpful if the Machine Learning model fails to recognize sounds from the audio recorded by the microphone in the collar or elephant collar's battery has run out of power or if it malfunctions.

Future Expansion

  • Multi-sensor Data Fusion: Integrate additional sensors like GPS for location tracking or accelerometers to detect distress movements, feeding all data into a more comprehensive AI model for better prediction accuracy.
  • Cloud Interface & Logging: Add a LoRa or cellular module to transmit alerts and logged "Danger" events to a cloud dashboard, allowing for remote monitoring and historical data analysis.
  • Advanced Power Management: Implement solar charging for the collar's battery to enable long-term, sustainable deployment in the field.
  • Community Alert Networks: Expand the RFID-based perimeter system into a network, creating automated SMS or radio alerts for villages when elephants approach farmlands, reducing human-elephant conflict.

Reference

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
  - "1x Edge Impulse Studio (for model building)"
  - "1x TinyML Library (Arduino)"
author: "shassandanish1"
category: "Lab Stuff"
components:
  - "1x Arduino Nano 33 BLE Sense (or Arduino UNO)"
  - "1x DHT11 Temperature & Humidity Sensor"
  - "1x MQ-2 Smoke/Gas Sensor"
  - "1x 5mm LED: Green (Safe)"
  - "1x 5mm LED: Red (Unsafe)"
  - "1x Alphanumeric LCD, 16 x 2"
  - "1x Breadboard (generic)"
  - "10x Jumper wires (generic)"
  - "1x Micro-USB Cable"
description: "An effective Machine Learning model, created with Edge Impulse, which can be used to detect whether the elephant is safe or not."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles:
  - "https://github.com/RucksikaaR/Elephant-Audio-classification.git"
encryptedPayload: "U2FsdGVkX1/jApbqhHpR/4XZG6oj6JAf2TgV2LJLbZsQGUlkUhnBc/eLqesL8wttZSI61rPeHgtB7EqlQEGyLEkv04OI9WXdfDgqLTVASaA="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/safe-or-not-prediction-with-machine-learning-model-ai-e2a6cd_cover.jpg"
lang: "en"
likes: 1
passwordHash: "67f9d34c702a67e2d6c10cb4fe2289ba175241a2f1d18b3fe0e8b0d0c025801e"
price: 1530
seoDescription: "An advanced and playfully interactive machine learning safety predictor for beginners interested in Arduino AI and IoT projects."
tags:
  - "sound"
  - "sensor"
  - "artificial intelligence"
  - "wildlife"
  - "machine learning"
title: "Safe or Not: Prediction with Machine Learning model (AI)"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/pu3MqtpEFuc"
views: 1362