Spaces:
Runtime error
Runtime error
yolo fire
Browse files- .idea/workspace.xml +46 -18
- Dockerfile +1 -0
- demo.py +1 -1
- requirements.txt +27 -1
- yolo_fire.py +51 -0
.idea/workspace.xml
CHANGED
@@ -4,9 +4,12 @@
|
|
4 |
<option name="autoReloadType" value="SELECTIVE" />
|
5 |
</component>
|
6 |
<component name="ChangeListManager">
|
7 |
-
<list default="true" id="d7806539-b6d6-42e7-bb45-1565f5d54891" name="Changes" comment="try to
|
|
|
8 |
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
9 |
<change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Dockerfile" afterDir="false" />
|
|
|
|
|
10 |
</list>
|
11 |
<option name="SHOW_DIALOG" value="false" />
|
12 |
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
@@ -28,6 +31,9 @@
|
|
28 |
<component name="MarkdownSettingsMigration">
|
29 |
<option name="stateVersion" value="1" />
|
30 |
</component>
|
|
|
|
|
|
|
31 |
<component name="ProjectColorInfo">{
|
32 |
"associatedIndex": 6
|
33 |
}</component>
|
@@ -37,21 +43,22 @@
|
|
37 |
<option name="hideEmptyMiddlePackages" value="true" />
|
38 |
<option name="showLibraryContents" value="true" />
|
39 |
</component>
|
40 |
-
<component name="PropertiesComponent"
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
}
|
54 |
-
}
|
55 |
<component name="RecentsManager">
|
56 |
<key name="CopyFile.RECENT_KEYS">
|
57 |
<recent name="$PROJECT_DIR$" />
|
@@ -118,7 +125,8 @@
|
|
118 |
<option name="presentableId" value="Default" />
|
119 |
<updated>1702301546100</updated>
|
120 |
<workItem from="1702301554378" duration="4025000" />
|
121 |
-
<workItem from="1702450051021" duration="
|
|
|
122 |
</task>
|
123 |
<task id="LOCAL-00001" summary="init commit">
|
124 |
<option name="closed" value="true" />
|
@@ -160,18 +168,38 @@
|
|
160 |
<option name="project" value="LOCAL" />
|
161 |
<updated>1702453169015</updated>
|
162 |
</task>
|
163 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
<servers />
|
165 |
</component>
|
166 |
<component name="TypeScriptGeneratedFilesManager">
|
167 |
<option name="version" value="3" />
|
168 |
</component>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
<component name="VcsManagerConfiguration">
|
170 |
<MESSAGE value="init commit" />
|
171 |
<MESSAGE value="fix build" />
|
172 |
<MESSAGE value="remove cv2" />
|
173 |
<MESSAGE value="try to create /.cache folder" />
|
174 |
-
<
|
|
|
175 |
</component>
|
176 |
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
177 |
<SUITE FILE_PATH="coverage/detector$demo.coverage" NAME="demo Coverage Results" MODIFIED="1702302380580" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
|
|
4 |
<option name="autoReloadType" value="SELECTIVE" />
|
5 |
</component>
|
6 |
<component name="ChangeListManager">
|
7 |
+
<list default="true" id="d7806539-b6d6-42e7-bb45-1565f5d54891" name="Changes" comment="try to grant user can access `/.cache` folder">
|
8 |
+
<change afterPath="$PROJECT_DIR$/yolo_fire.py" afterDir="false" />
|
9 |
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
10 |
<change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Dockerfile" afterDir="false" />
|
11 |
+
<change beforePath="$PROJECT_DIR$/demo.py" beforeDir="false" afterPath="$PROJECT_DIR$/demo.py" afterDir="false" />
|
12 |
+
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
|
13 |
</list>
|
14 |
<option name="SHOW_DIALOG" value="false" />
|
15 |
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
|
31 |
<component name="MarkdownSettingsMigration">
|
32 |
<option name="stateVersion" value="1" />
|
33 |
</component>
|
34 |
+
<component name="ProblemsViewState">
|
35 |
+
<option name="selectedTabId" value="QODANA_PROBLEMS_VIEW_TAB" />
|
36 |
+
</component>
|
37 |
<component name="ProjectColorInfo">{
|
38 |
"associatedIndex": 6
|
39 |
}</component>
|
|
|
43 |
<option name="hideEmptyMiddlePackages" value="true" />
|
44 |
<option name="showLibraryContents" value="true" />
|
45 |
</component>
|
46 |
+
<component name="PropertiesComponent">{
|
47 |
+
"keyToString": {
|
48 |
+
"Python.demo.executor": "Run",
|
49 |
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
50 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
51 |
+
"git-widget-placeholder": "main",
|
52 |
+
"last_opened_file_path": "/Users/famer.me/PycharmProjects/detector",
|
53 |
+
"node.js.detected.package.eslint": "true",
|
54 |
+
"node.js.detected.package.tslint": "true",
|
55 |
+
"node.js.selected.package.eslint": "(autodetect)",
|
56 |
+
"node.js.selected.package.tslint": "(autodetect)",
|
57 |
+
"nodejs_package_manager_path": "npm",
|
58 |
+
"settings.editor.selected.configurable": "settings.qodana",
|
59 |
+
"vue.rearranger.settings.migration": "true"
|
60 |
}
|
61 |
+
}</component>
|
62 |
<component name="RecentsManager">
|
63 |
<key name="CopyFile.RECENT_KEYS">
|
64 |
<recent name="$PROJECT_DIR$" />
|
|
|
125 |
<option name="presentableId" value="Default" />
|
126 |
<updated>1702301546100</updated>
|
127 |
<workItem from="1702301554378" duration="4025000" />
|
128 |
+
<workItem from="1702450051021" duration="10065000" />
|
129 |
+
<workItem from="1702476484538" duration="5222000" />
|
130 |
</task>
|
131 |
<task id="LOCAL-00001" summary="init commit">
|
132 |
<option name="closed" value="true" />
|
|
|
168 |
<option name="project" value="LOCAL" />
|
169 |
<updated>1702453169015</updated>
|
170 |
</task>
|
171 |
+
<task id="LOCAL-00006" summary="try to grant user can access `/.cache` folder">
|
172 |
+
<option name="closed" value="true" />
|
173 |
+
<created>1702454105421</created>
|
174 |
+
<option name="number" value="00006" />
|
175 |
+
<option name="presentableId" value="LOCAL-00006" />
|
176 |
+
<option name="project" value="LOCAL" />
|
177 |
+
<updated>1702454105421</updated>
|
178 |
+
</task>
|
179 |
+
<option name="localTasksCounter" value="7" />
|
180 |
<servers />
|
181 |
</component>
|
182 |
<component name="TypeScriptGeneratedFilesManager">
|
183 |
<option name="version" value="3" />
|
184 |
</component>
|
185 |
+
<component name="Vcs.Log.Tabs.Properties">
|
186 |
+
<option name="TAB_STATES">
|
187 |
+
<map>
|
188 |
+
<entry key="MAIN">
|
189 |
+
<value>
|
190 |
+
<State />
|
191 |
+
</value>
|
192 |
+
</entry>
|
193 |
+
</map>
|
194 |
+
</option>
|
195 |
+
</component>
|
196 |
<component name="VcsManagerConfiguration">
|
197 |
<MESSAGE value="init commit" />
|
198 |
<MESSAGE value="fix build" />
|
199 |
<MESSAGE value="remove cv2" />
|
200 |
<MESSAGE value="try to create /.cache folder" />
|
201 |
+
<MESSAGE value="try to grant user can access `/.cache` folder" />
|
202 |
+
<option name="LAST_COMMIT_MESSAGE" value="try to grant user can access `/.cache` folder" />
|
203 |
</component>
|
204 |
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
205 |
<SUITE FILE_PATH="coverage/detector$demo.coverage" NAME="demo Coverage Results" MODIFIED="1702302380580" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
Dockerfile
CHANGED
@@ -11,4 +11,5 @@ RUN mkdir $HOME/.cache
|
|
11 |
RUN chown -R user $HOME/.cache
|
12 |
|
13 |
RUN pip install -r requirements.txt
|
|
|
14 |
ENTRYPOINT ["streamlit", "run", "demo.py"]
|
|
|
11 |
RUN chown -R user $HOME/.cache
|
12 |
|
13 |
RUN pip install -r requirements.txt
|
14 |
+
RUN python yolo_fire.py
|
15 |
ENTRYPOINT ["streamlit", "run", "demo.py"]
|
demo.py
CHANGED
@@ -3,7 +3,7 @@ import time
|
|
3 |
from PIL import Image
|
4 |
import streamlit as st
|
5 |
|
6 |
-
from
|
7 |
|
8 |
|
9 |
def main():
|
|
|
3 |
from PIL import Image
|
4 |
import streamlit as st
|
5 |
|
6 |
+
from yolo_fire import detect
|
7 |
|
8 |
|
9 |
def main():
|
requirements.txt
CHANGED
@@ -5,64 +5,90 @@ attrs==23.1.0
|
|
5 |
blinker==1.7.0
|
6 |
cachetools==5.3.2
|
7 |
certifi==2023.11.17
|
|
|
8 |
charset-normalizer==3.3.2
|
9 |
click==8.1.7
|
|
|
|
|
10 |
exceptiongroup==1.2.0
|
11 |
fastapi==0.104.1
|
12 |
filelock==3.13.1
|
|
|
|
|
13 |
fsspec==2023.12.1
|
14 |
gitdb==4.0.11
|
15 |
GitPython==3.1.40
|
16 |
h11==0.14.0
|
17 |
httptools==0.6.1
|
|
|
18 |
idna==3.6
|
19 |
importlib-metadata==6.11.0
|
|
|
20 |
Jinja2==3.1.2
|
21 |
jsonschema==4.20.0
|
22 |
jsonschema-specifications==2023.11.2
|
|
|
23 |
markdown-it-py==3.0.0
|
24 |
MarkupSafe==2.1.3
|
|
|
25 |
mdurl==0.1.2
|
26 |
mpmath==1.3.0
|
27 |
networkx==3.2.1
|
28 |
numpy==1.26.2
|
|
|
|
|
29 |
packaging==23.2
|
30 |
pandas==2.1.4
|
31 |
Pillow==10.1.0
|
32 |
protobuf==4.25.1
|
|
|
|
|
33 |
pyarrow==14.0.1
|
|
|
34 |
pydantic==2.5.2
|
35 |
pydantic_core==2.14.5
|
36 |
pydeck==0.8.1b0
|
37 |
Pygments==2.17.2
|
|
|
38 |
python-dateutil==2.8.2
|
39 |
python-dotenv==1.0.0
|
|
|
40 |
pytz==2023.3.post1
|
41 |
PyYAML==6.0.1
|
42 |
referencing==0.32.0
|
43 |
requests==2.31.0
|
|
|
44 |
rich==13.7.0
|
|
|
45 |
rpds-py==0.13.2
|
|
|
46 |
scipy==1.11.4
|
|
|
|
|
47 |
six==1.16.0
|
48 |
smmap==5.0.1
|
49 |
sniffio==1.3.0
|
50 |
starlette==0.27.0
|
51 |
streamlit==1.29.0
|
|
|
52 |
sympy==1.12
|
53 |
tenacity==8.2.3
|
|
|
|
|
|
|
54 |
toml==0.10.2
|
55 |
toolz==0.12.0
|
56 |
torch==2.1.1
|
57 |
torchaudio==2.1.1
|
58 |
torchvision==0.16.1
|
59 |
tornado==6.4
|
|
|
60 |
typing_extensions==4.9.0
|
61 |
tzdata==2023.3
|
62 |
tzlocal==5.2
|
|
|
63 |
urllib3==2.1.0
|
64 |
uvicorn==0.24.0.post1
|
65 |
-
uvloop==0.19.0
|
66 |
validators==0.22.0
|
67 |
watchfiles==0.21.0
|
68 |
websockets==12.0
|
|
|
5 |
blinker==1.7.0
|
6 |
cachetools==5.3.2
|
7 |
certifi==2023.11.17
|
8 |
+
chardet==4.0.0
|
9 |
charset-normalizer==3.3.2
|
10 |
click==8.1.7
|
11 |
+
contourpy==1.2.0
|
12 |
+
cycler==0.10.0
|
13 |
exceptiongroup==1.2.0
|
14 |
fastapi==0.104.1
|
15 |
filelock==3.13.1
|
16 |
+
fire==0.5.0
|
17 |
+
fonttools==4.46.0
|
18 |
fsspec==2023.12.1
|
19 |
gitdb==4.0.11
|
20 |
GitPython==3.1.40
|
21 |
h11==0.14.0
|
22 |
httptools==0.6.1
|
23 |
+
huggingface-hub==0.19.4
|
24 |
idna==3.6
|
25 |
importlib-metadata==6.11.0
|
26 |
+
importlib-resources==6.1.1
|
27 |
Jinja2==3.1.2
|
28 |
jsonschema==4.20.0
|
29 |
jsonschema-specifications==2023.11.2
|
30 |
+
kiwisolver==1.4.5
|
31 |
markdown-it-py==3.0.0
|
32 |
MarkupSafe==2.1.3
|
33 |
+
matplotlib==3.8.2
|
34 |
mdurl==0.1.2
|
35 |
mpmath==1.3.0
|
36 |
networkx==3.2.1
|
37 |
numpy==1.26.2
|
38 |
+
opencv-python==4.7.0.72
|
39 |
+
opencv-python-headless==4.8.0.74
|
40 |
packaging==23.2
|
41 |
pandas==2.1.4
|
42 |
Pillow==10.1.0
|
43 |
protobuf==4.25.1
|
44 |
+
psutil==5.9.6
|
45 |
+
py-cpuinfo==9.0.0
|
46 |
pyarrow==14.0.1
|
47 |
+
pybboxes==0.1.6
|
48 |
pydantic==2.5.2
|
49 |
pydantic_core==2.14.5
|
50 |
pydeck==0.8.1b0
|
51 |
Pygments==2.17.2
|
52 |
+
pyparsing==2.4.7
|
53 |
python-dateutil==2.8.2
|
54 |
python-dotenv==1.0.0
|
55 |
+
python-magic==0.4.27
|
56 |
pytz==2023.3.post1
|
57 |
PyYAML==6.0.1
|
58 |
referencing==0.32.0
|
59 |
requests==2.31.0
|
60 |
+
requests-toolbelt==1.0.0
|
61 |
rich==13.7.0
|
62 |
+
roboflow==1.1.12
|
63 |
rpds-py==0.13.2
|
64 |
+
sahi==0.11.15
|
65 |
scipy==1.11.4
|
66 |
+
seaborn==0.13.0
|
67 |
+
shapely==2.0.2
|
68 |
six==1.16.0
|
69 |
smmap==5.0.1
|
70 |
sniffio==1.3.0
|
71 |
starlette==0.27.0
|
72 |
streamlit==1.29.0
|
73 |
+
supervision==0.17.1
|
74 |
sympy==1.12
|
75 |
tenacity==8.2.3
|
76 |
+
termcolor==2.4.0
|
77 |
+
terminaltables==3.1.10
|
78 |
+
thop==0.1.1.post2209072238
|
79 |
toml==0.10.2
|
80 |
toolz==0.12.0
|
81 |
torch==2.1.1
|
82 |
torchaudio==2.1.1
|
83 |
torchvision==0.16.1
|
84 |
tornado==6.4
|
85 |
+
tqdm==4.66.1
|
86 |
typing_extensions==4.9.0
|
87 |
tzdata==2023.3
|
88 |
tzlocal==5.2
|
89 |
+
ultralytics==8.0.227
|
90 |
urllib3==2.1.0
|
91 |
uvicorn==0.24.0.post1
|
|
|
92 |
validators==0.22.0
|
93 |
watchfiles==0.21.0
|
94 |
websockets==12.0
|
yolo_fire.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
from PIL import ImageDraw, Image
|
3 |
+
from huggingface_hub import hf_hub_download
|
4 |
+
from ultralytics import YOLO
|
5 |
+
|
6 |
+
# Load model
|
7 |
+
weight_file = hf_hub_download("SHOU-ISD/fire-and-smoke", "yolov8n.pt")
|
8 |
+
model = YOLO(weight_file) # pretrained YOLOv8n model
|
9 |
+
|
10 |
+
# Helper Functions for Plotting BBoxes
|
11 |
+
def plot_one_box(x, img, color=None, label=None, line_thickness=None):
|
12 |
+
width, height = img.size
|
13 |
+
tl = line_thickness or round(0.002 * (width + height) / 2) + 1 # line/font thickness
|
14 |
+
color = color or (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
|
15 |
+
c1, c2 = (int(x[0]), int(x[1])), (int(x[2]), int(x[3]))
|
16 |
+
img_draw = ImageDraw.Draw(img)
|
17 |
+
img_draw.rectangle((c1[0], c1[1], c2[0], c2[1]), outline=color, width=tl)
|
18 |
+
if label:
|
19 |
+
tf = max(tl - 1, 1) # font thickness
|
20 |
+
x1, y1, x2, y2 = img_draw.textbbox(c1, label, stroke_width=tf)
|
21 |
+
img_draw.rectangle((x1, y1, x2, y2), fill=color)
|
22 |
+
img_draw.text((x1, y1), label, fill=(255, 255, 255))
|
23 |
+
|
24 |
+
|
25 |
+
# Ploting Bounding Box on img
|
26 |
+
def add_bboxes(pil_img, result, confidence=0.6):
|
27 |
+
for box in result.boxes:
|
28 |
+
[cl] = box.cls.tolist()
|
29 |
+
[conf] = box.conf.tolist()
|
30 |
+
if conf < confidence:
|
31 |
+
continue
|
32 |
+
[rect] = box.xyxy.tolist()
|
33 |
+
text = f'{result.names[cl]}: {conf: 0.2f}'
|
34 |
+
plot_one_box(x=rect, img=pil_img, label=text)
|
35 |
+
|
36 |
+
return pil_img
|
37 |
+
|
38 |
+
|
39 |
+
def detect(im, confidence):
|
40 |
+
results = model(source=im)
|
41 |
+
res_img = im
|
42 |
+
for result in results:
|
43 |
+
res_img = add_bboxes(res_img, result, confidence)
|
44 |
+
return res_img
|
45 |
+
|
46 |
+
if __name__ == '__main__':
|
47 |
+
im = Image.open("./tests/fire1.jpg")
|
48 |
+
results = model(source=im)
|
49 |
+
for result in results:
|
50 |
+
im = add_bboxes(im, result)
|
51 |
+
im.show()
|