161 words
1 minute
YOLO Fire & Smoke Detection Model

YOLO Fire & Smoke Detection Model#

โมเดล YOLO สำหรับตรวจจับ ไฟไหม้ และ ควันไฟ แบบ Real-time
จัดทำขึ้นเพื่อเป็น กรณีศึกษา สำหรับผู้ที่สนใจเรียนรู้เกี่ยวกับ Computer Vision และ Object Detection

สำหรับการศึกษาเท่านั้น — โมเดลนี้จัดทำขึ้นเพื่อเป็นกรณีศึกษาและทดลองเท่านั้น ไม่แนะนำให้นำไปใช้งานในระบบ Production หรือใช้งานจริงโดยไม่ผ่านการทดสอบอย่างเหมาะสม


ข้อมูลโมเดล#

Model : YOLOv8n
Layers : 129
Parameters : 3,011,238
GFLOPs : 8.2

สิ่งที่ตรวจจับได้#

โมเดลนี้สามารถตรวจจับได้ 2 คลาส:

คลาสคำอธิบาย
ไฟตรวจจับเปลวไฟ
ควันตรวจจับควันไฟ

ตัวอย่างผลลัพธ์#

ตรวจจับไฟไหม้

ตัวอย่างการตรวจจับไฟ

ตรวจจับควันไฟ

ตัวอย่างการตรวจจับควัน


ดาวน์โหลดโมเดล#

ดาวน์โหลดโมเดล (fire_smoke_model.pt)


วิธีการใช้งาน#

ติดตั้ง Dependencies#

Terminal window
pip install ultralytics opencv-python

โหลดโมเดลและตรวจจับภาพ#

from ultralytics import YOLO
import cv2
# โหลดโมเดล
model = YOLO("fire_smoke_model.pt")
# ทำการตรวจจับจากรูปภาพ
results = model.predict(source="image.jpg", conf=0.5, save=True)
# แสดงผลลัพธ์
for result in results:
boxes = result.boxes
for box in boxes:
cls = int(box.cls[0])
conf = float(box.conf[0])
class_name = model.names[cls]
print(f"พบ: {class_name} ความมั่นใจ: {conf:.2f}")

ตรวจจับแบบ Real-time จาก Webcam#

from ultralytics import YOLO
import cv2
model = YOLO("fire_smoke_model.pt")
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
results = model.predict(frame, conf=0.5, verbose=False)
annotated_frame = results[0].plot()
cv2.imshow("Fire & Smoke Detection", annotated_frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()

ตรวจจับจากไฟล์วิดีโอ#

from ultralytics import YOLO
model = YOLO("fire_smoke_model.pt")
results = model.predict(
source="video.mp4",
conf=0.5,
save=True,
show=True
)

Export โมเดลเป็น ONNX#

from ultralytics import YOLO
model = YOLO("fire_smoke_model.pt")
model.export(format="onnx")

หมายเหตุ#

หัวข้อรายละเอียด
วัตถุประสงค์เพื่อการศึกษาและทดลองเท่านั้น
ไม่แนะนำใช้งานในระบบ Production โดยตรง
ควรทำทดสอบกับข้อมูลของคุณเองก่อนนำไปใช้จริง

ข้อควรระวัง: ผู้พัฒนาไม่รับผิดชอบต่อความเสียหายใดๆ ที่อาจเกิดขึ้นจากการนำโมเดลนี้ไปใช้งาน
โปรดใช้วิจารณญาณและทดสอบอย่างรอบคอบก่อนนำไปใช้งานจริง

YOLO Fire & Smoke Detection Model
https://blog.lukkid.dev/posts/yolo-fire-smoke-detection/
Author
LUKKID
Published at
2025-12-14
License
CC BY-NC-SA 4.0