Skip to content

Commit 45518f2

Browse files
Merge pull request #1 from DeepQuestAI/anike/firenet
Building FireNET repository
2 parents 5bf0fb7 + b71f99f commit 45518f2

14 files changed

+105
-1
lines changed

README.md

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,95 @@
11
# DeepStack_FireNET
2-
A custom DeepStack model for detecting fire indoor and outdoor
2+
3+
4+
This repository provides a custom DeepStack model that has been trained and can be used for creating a new `object detection API` for detecting **fire** present indoor and outdoor using [FireNET Dataset](https://github.com/OlafenwaMoses/FireNET). Also included in this repository is that dataset with the **YOLO annotations**.
5+
6+
[>> Watch Video Demo](https://www.youtube.com/watch?v=ts3yxfNrDnY)
7+
8+
- **Download DeepStack Model and Dataset**
9+
- **Create API and Detect Objects**
10+
- **Discover more Custom Models**
11+
- **Train your own Model**
12+
13+
![](images/fire_net.png)
14+
15+
# Download DeepStack Model and Dataset
16+
17+
You can download the pre-trained **DeepStack_FireNET** model and the annotated dataset via the links below.
18+
19+
- [YOLOv5x DeepStack Model](https://github.com/DeepQuestAI/DeepStack_FireNET/releases/tag/v1)
20+
21+
- [FireNET with YOLO annotation](https://github.com/DeepQuestAI/DeepStack_FireNET/releases/download/v1/firenet_yolo.zip)
22+
23+
24+
# Create API and Detect Fire
25+
26+
The Trained Model can detect **fire** in images and videos.
27+
28+
To start detecting, follow the steps below
29+
30+
- **Install DeepStack:** Install DeepStack AI Server with instructions on DeepStack's documentation via [https://docs.deepstack.cc](https://docs.deepstack.cc/index.html#installation)
31+
- **Download Custom Model:** Download the trained custom model `firenetv1.pt` from [this GitHub release](https://github.com/DeepQuestAI/DeepStack_FireNET/releases/tag/v1). Create a folder on your machine and move the downloaded model to this folder.
32+
33+
E.g A path on Windows Machine `C\Users\MyUser\Documents\DeepStack-Models`, which will make your model file path `C\Users\MyUser\Documents\DeepStack-Models\firenetv1.pt`
34+
35+
- **Run DeepStack:** To run DeepStack AI Server with the custom FireNET model, run the command that applies to your machine as detailed on DeepStack's documentation [linked here](https://docs.deepstack.cc/custom-models/deployment/index.html#starting-deepstack).
36+
37+
E.g
38+
39+
For a Windows version, you run the command below
40+
```bash
41+
deepstack --MODELSTORE-DETECTION "C\Users\MyUser\Documents\DeepStack-Models" --PORT 80
42+
```
43+
44+
For a Linux machine
45+
```bash
46+
sudo docker run -v /home/MyUser/Documents/DeepStack-Models -p 80:5000 deepquestai/deepstack
47+
```
48+
Once DeepStack runs, you will see a log like the one below in your `Terminal/Console`
49+
50+
![](images/custom_model.png)
51+
52+
That means DeepStack is running your custom `firenet.pt` model and now ready to start detecting fire images via the API endpoint `http://localhost:80/v1/vision/custom/firenet` or `http://your_machine_ip:80/v1/vision/custom/firenet`
53+
54+
- **Detect fire in image:** You can detect objects in an image by sending a `POST` request to the url mentioned above with the paramater `image` set to an `image` using any proggramming language or with a tool like POSTMAN. For the purpose of this repository, we have provided a sample Python code below.
55+
56+
- A sample image can be found in `images/test.jpg` of this repository.
57+
58+
![](images/test.png)
59+
60+
- Install Python and install the **DeepStack Python SDK** via the command below
61+
```bash
62+
pip install deepstack_sdk
63+
```
64+
- Run the Python file `detect.py` in this repository.
65+
66+
```bash
67+
python detect.py
68+
```
69+
- After the code runs, you will find a new image in `images/test_detected.jpg` with the detection visualized, with the following results printed in the Terminal/Console.
70+
71+
```
72+
Name: fire, Confidence: 0.92534935, x_min: 607, y_min: 348, x_max: 797, y_max: 530
73+
```
74+
75+
![](images/test_detected.jpg)
76+
77+
- Fire detection sample images
78+
79+
![](images/test1_detected.jpg)
80+
81+
![](images/test2_detected.jpg)
82+
83+
# Discover more Custom Models
84+
85+
For more custom DeepStack models that has been trained and ready to use, visit the Custom Models sample page on DeepStack's documentation [https://docs.deepstack.cc/custom-models-samples/](https://docs.deepstack.cc/custom-models-samples/) .
86+
87+
88+
89+
# Train your own Model
90+
91+
If you will like to train a custom model yourself, follow the instructions below.
92+
93+
- **Prepare and Annotate:** Collect images on and annotate object(s) you plan to detect as [ detailed here ](https://docs.deepstack.cc/custom-models/datasetprep/index.html)
94+
- **Train your Model:** Train the model as [detailed here](https://docs.deepstack.cc/custom-models/training/index.html)
95+

detect.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from deepstack_sdk import ServerConfig, Detection
2+
import os
3+
4+
config = ServerConfig("http://localhost:80")
5+
detection = Detection(config, name="firenetv1")
6+
7+
response = detection.detectObject(image=os.path.join("images", "test.png"), output=os.path.join("images", "test_detected.jpg"))
8+
9+
for obj in response:
10+
print("Name: {}, Confidence: {}, x_min: {}, y_min: {}, x_max: {}, y_max: {}".format(obj.label, obj.confidence, obj.x_min, obj.y_min, obj.x_max,
11+
obj.y_max))

images/custom_model.PNG

2.91 KB
Loading

images/fire_net.png

2.36 MB
Loading

images/test.png

159 KB
Loading

images/test1.jpg

49.6 KB
Loading

images/test1_detected.jpg

59.1 KB
Loading

images/test2.jpg

4.72 MB
Loading

images/test2_detected.jpg

2.49 MB
Loading

images/test3.jpg

313 KB
Loading

0 commit comments

Comments
 (0)