Safety Gate AI
Safety Gate AI: AI-Powered PPE Access Control Prototype
Introduction
For my Project One, I made Safety Gate AI. It is a prototype gate system that checks if a person is wearing the required personal protective equipment before giving access.
The system uses a camera and a YOLO object detection model. It checks for:
- safety helmet
- safety vest
- safety glasses
- safety shoes
If all required PPE is detected, the system gives access. If something is missing, access stays denied. The prototype also uses a Raspberry Pi 5, a Freenove project kit, a servo gate, an RGB LED, a buzzer, RFID, and a Gradio dashboard.
This project is made as a safety prototype. The goal is not to replace a real safety officer, but to show how AI can support safety checks at an entrance.
Supplies
For this project I used:
- Raspberry Pi 5
- Freenove project kit
- Camera
- Servo motor
- RGB LED
- Buzzer
- RFID module
- Jumper wires
- Breadboard or project board
- Laptop or monitor for testing
- Safety helmet
- Safety vest
- Safety glasses
- Safety shoes
- Trained YOLO model file: best.pt
- Python
- OpenCV
- Ultralytics YOLO
- Gradio
Train the PPE Detection Model
First I collected my own image dataset. I took photos of different people, different backgrounds, and different PPE combinations.
The model was trained to detect these classes:
- no_helmet
- no_shoes
- no_vest
- person
- safety_glasses
- safety_helmet
- safety_shoes
- safety_vest
The required classes for opening the gate are:
- safety_helmet
- safety_vest
- safety_glasses
- safety_shoes
At first, the model had problems detecting safety glasses because they are small in a full-body image. To improve this, I collected around 130 extra photos with safety glasses and retrained the model. After that, the safety glasses detection became better.
Test the Model Locally
Before connecting all hardware, I tested the model with a simple live camera script.
The script opened the camera, detected PPE, and showed the result on the screen. I tested it with:
- full PPE
- missing helmet
- missing vest
- missing glasses
- missing safety shoes
- different people
- different backgrounds
The model worked well after retraining. I also added a rule that all PPE must be detected several times in a row before access is approved. This makes the system more stable and prevents one lucky wrong detection from opening the gate.
Prepare the Raspberry Pi 5
After the model worked on my laptop, I moved the project to the Raspberry Pi 5.
I installed the needed Python packages:
I placed the trained model file inside my project folder:
Then I tested if the Raspberry Pi could load the model and detect PPE from the camera.
Build the Gradio Dashboard
I used Gradio as the user interface. This makes the prototype easier to use because I do not need to run everything only from the terminal.
The Gradio dashboard has pages/tabs for:
- running the PPE check
- showing camera result
- showing access approved or denied
- showing missing PPE
- showing logs
- explaining how the system works
The user starts the check from the Gradio dashboard. There is no physical start button in my current prototype.
The dashboard shows a clear result:
or:
Connect the Servo Gate
The servo motor is used as a small gate.
When access is denied, the servo stays closed.
When access is approved, the servo moves to the open position.
Example behavior:
This makes the prototype easy to understand during a demo. The servo is not a real industrial gate, but it simulates the same idea.
Connect the RGB LED
The RGB LED gives quick visual feedback.
I used these colors:
- Red = access denied
- Green = access approved
- Blue or white = system ready / waiting
This helps the user understand the system without reading the screen all the time.
Example:
Connect the Buzzer
The buzzer gives sound feedback.
I used it like this:
- short beep = access approved
- warning beep = access denied
This is useful because in a real gate system, users may not always look at the screen. Sound feedback makes the result more noticeable.
Add RFID
The RFID module is used to simulate user identification.
The idea is:
- User scans an RFID card.
- The system knows someone wants access.
- The PPE check is started from the Gradio dashboard.
- The system checks the camera image.
- The gate opens only if all PPE is detected.
In the current prototype, RFID is part of the access system, but the main safety decision still comes from the AI PPE detection.
Access Logic
The most important part of the project is the access logic.
The system does not approve access just because one frame looks correct. Instead, the required PPE must be detected multiple times in a row.
The rule is:
If one required item is missing, the counter resets.
This makes the system more reliable.
Example:
After access is approved, it stays approved until the system is reset.
Testing the Prototype
I tested the prototype with different situations.
Some test cases:
TestExpected result
Person with all PPE
Access approved
Missing helmet
Access denied
Missing vest
Access denied
Missing safety glasses
Access denied
Missing safety shoes
Access denied
Different person
Should still work
Different background
Should still work
Helmet in hand
Should not count as correct PPE
Glasses not worn
Should not approve
Bad lighting
May be harder, access should stay denied if uncertain
The most difficult class was safety glasses because they are small. I improved this by collecting more photos with safety glasses.
Build the Kiosk / Enclosure
The electronics are placed in a kiosk-style prototype. The kiosk holds the camera and makes the project look more like a real access control system.
The camera must be placed so it can see the full body, including the safety shoes. This is important because the model needs to check all PPE items.
The enclosure also helps with cable management and presentation.
Final Result
The final prototype can:
- detect a person
- detect required PPE
- show the result in Gradio
- deny access if PPE is missing
- approve access if all PPE is detected
- open a servo gate
- show RGB LED feedback
- make buzzer feedback
- use RFID as part of the access flow
The project works well with different people and different backgrounds. The AI model is not perfect, but the safety logic is strict. If something is uncertain or missing, the gate does not open.
This is important for a safety project.
Problems I Had
The biggest problem was detecting safety glasses. They are small, and in a full-body image they are harder to detect than a vest or helmet.
I solved this by:
- collecting more photos
- adding more full-PPE images with glasses
- retraining the YOLO model
- testing with different people and backgrounds
Another problem was making the system user-friendly. A terminal demo works for testing, but it is not clear for normal users. That is why I used Gradio. It makes the system easier to use and explain.
Conclusion
Safety Gate AI is a working prototype for AI-based PPE access control.
The project combines computer vision, Raspberry Pi hardware, Gradio, RFID, and physical feedback using a servo, LED, and buzzer.
I learned that the AI model is only one part of the project. A good prototype also needs clear user feedback, stable logic, testing, and a physical setup that people can understand.
The most important lesson was that safety systems must be strict. If the model is unsure, the system should deny access instead of allowing someone without the correct PPE.