161 words
1 minute
YOLO Fire & Smoke Detection Model
YOLO Fire & Smoke Detection Model
โมเดล YOLO สำหรับตรวจจับ ไฟไหม้ และ ควันไฟ แบบ Real-time
จัดทำขึ้นเพื่อเป็น กรณีศึกษา สำหรับผู้ที่สนใจเรียนรู้เกี่ยวกับ Computer Vision และ Object Detection
สำหรับการศึกษาเท่านั้น — โมเดลนี้จัดทำขึ้นเพื่อเป็นกรณีศึกษาและทดลองเท่านั้น ไม่แนะนำให้นำไปใช้งานในระบบ Production หรือใช้งานจริงโดยไม่ผ่านการทดสอบอย่างเหมาะสม
ข้อมูลโมเดล
Model : YOLOv8nLayers : 129Parameters : 3,011,238GFLOPs : 8.2สิ่งที่ตรวจจับได้
โมเดลนี้สามารถตรวจจับได้ 2 คลาส:
| คลาส | คำอธิบาย |
|---|---|
| ไฟ | ตรวจจับเปลวไฟ |
| ควัน | ตรวจจับควันไฟ |
ตัวอย่างผลลัพธ์
ตรวจจับไฟไหม้

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

ดาวน์โหลดโมเดล
ดาวน์โหลดโมเดล (fire_smoke_model.pt)
วิธีการใช้งาน
ติดตั้ง Dependencies
pip install ultralytics opencv-pythonโหลดโมเดลและตรวจจับภาพ
from ultralytics import YOLOimport 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 YOLOimport 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/