Spaces:
Running
A newer version of the Streamlit SDK is available:
1.41.1
license: apache-2.0
title: Weapon Detection
sdk: streamlit
emoji: π’
colorFrom: green
colorTo: green
weapon-detection-alert-location-share
This project focuses on enhancing the security of different places, like public areas and banks, by implementing a robust gun detection and alert system. The system is designed to capture images from an IP camera strategically placed. within the bank's premises. When a captured image contains an identifiable gun, the system takes appropriate actions, such as playing alerts or sharing the location of the detected weapons, including knife and guns.
Image Capture:
Utilizes an IP camera to continuously capture images in real-time within the camera range. Images are processed and analyzed for potential gun presence.
Gun Detection:
Employs advanced computer vision algorithms for accurate gun detection in captured images. The system recognizes various types of firearms and distinguishes them from other objects.
Alert Systems:
When a gun is detected, the system triggers immediate alerts. Alerts can be configured to notify security personnel, law enforcement, and relevant authorities.
π Technologies
- Python
- FastAPI
- Streamlit
- YOLO
- OpenCV
- Docker
File Structure
File structure of the project
.
βββ config
β βββ config.ini
βββ images
β βββ cam_images
β βββ th-3711382641.jpg
βββ logs
β βββ gun_det.log
β βββ ipcam.log
βββ resources
β βββ alert
β β βββ alert.mp3
β βββ flag_load_image
β βββ image_capturing
β βββ models
β βββ best.pt
β βββ v1
β β βββ best.pt
βββ src
β βββ api
β β βββ fast_api.py
β β βββ __init__.py
β βββ __init__.py
β βββ services
β β βββ alert_service
β β β βββ alert_service.py
β β β βββ __init__.py
β β β βββ __pycache__
β β βββ entity
β β β βββ entity_config.py
β β β βββ __init__.py
β β βββ image_capture_service
β β β βββ capture_main.py
β β β βββ image_load_main.py
β β β βββ __init__.py
β β βββ __init__.py
β β βββ weapon_det_service
β β βββ __init__.py
β β βββ weapon_detection_service.py
β βββ utils
β βββ __init__.py
β βββ __pycache__
β βββ settings.py
βββ demos
β βββ alert_service_example.py
β βββ cam_service_example
β β βββ start_frame_capturing.py
β β βββ stop_frame_capturing.py
β βββ image_load_service_example
β β βββ start_image_load_example.py
β β βββ stop_image_load_example.py
β βββ __init__.py
β βββ single_image_inference.py
βββ Dockerfiles
βββ app.py
βββ main.py
βββ README.md
βββ requirements.txt
βββ streamlit_app.py
How to Run
Clone the repository:
git clone https://github.com/ishworrsubedii/gun-detection-alert.git cd cd gun-detection
Create and activate the Conda environment:
conda create -n weapon-detection python=3.10 -y conda activate gun-detection
Install required packages:
pip install -r requirements.txt
Perform Inference/Prediction:
streamlit run streamlit_app.py
- We have to run both programs for inference. py for fastapi post request and streamlit for UI for the prediction.
Perform Single Image Inference:
streamlit run app.py
Docker
docker build -t myapp .
Then run the docker container
docker myapp
π₯Features
- Real-time Gun Detection: The system can detect guns in real-time images captured by an IP camera.
- Alert System: The system can send alerts to security personnel and law enforcement when a gun is detected.
β οΈ Limitations
- The system may not be able to detect guns in low-light conditions or when the weapon is partially obscured.
- Accuracy may vary based on the quality of the images captured by the IP camera.
Future Work
- One of the future work is to train the model on diverse datasets to improve the model's performance and accuracy.
- Implement and test the system in real-world scenarios using raspberry pi or other edge devices.
- Develop a feature to share the location of detected with the authorities.
Demo
For single image inference i have used huggingface here you can try it out here
Recommendations
Your recommendations are highly valuable, and I highly value your insights and suggestions to enhance this project! Feel free to propose new features, report bugs, or suggest improvements.
Contributors
Contributions are always welcome! If you'd like to contribute to this project or have any suggestions, please feel free to reach out or submit a pull request.