{"id":24793063,"url":"https://github.com/zhenglinlei/fireguardml","last_synced_at":"2025-03-24T17:05:07.365Z","repository":{"id":227323649,"uuid":"771083182","full_name":"ZhengLinLei/FireGuardML","owner":"ZhengLinLei","description":"Open Source Fire and Smoke AI detector trained with Yolov8","archived":false,"fork":false,"pushed_at":"2024-03-12T17:59:37.000Z","size":2628,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T22:01:36.216Z","etag":null,"topics":["deep-learning","machine-learning","object-recognition","yolov8"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZhengLinLei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-12T16:53:31.000Z","updated_at":"2024-09-02T17:36:15.000Z","dependencies_parsed_at":"2024-03-12T19:06:32.346Z","dependency_job_id":null,"html_url":"https://github.com/ZhengLinLei/FireGuardML","commit_stats":null,"previous_names":["zhenglinlei/fireguardml"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FFireGuardML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FFireGuardML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FFireGuardML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FFireGuardML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZhengLinLei","download_url":"https://codeload.github.com/ZhengLinLei/FireGuardML/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245315295,"owners_count":20595217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","machine-learning","object-recognition","yolov8"],"created_at":"2025-01-29T21:55:47.998Z","updated_at":"2025-03-24T17:05:07.336Z","avatar_url":"https://github.com/ZhengLinLei.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FireGuard Machine Learning AI\n\nFireguard is a machine learning Artificial Intelligent trained with Yolov8 to detect **Fire** and **Smokes** from pictures.\n\nFor this project you have two options:\n* Use pre-trained model in release, check **Model**\n* Train model by yourself, check **Train**\n\n## Table of Contents\n1. [Model](#model)\n2. [Train](#todel)\n\n\n--------------------------\n\n## Model\n\nIf you want to use the model directly without training your own model, download the `FireGuardBestModel.pt` or `FireGuardLastModel.pt` from [release](https://github.com/ZhengLinLei/FireGuardML/releases/)\n\n### Usage\n```python\nimport cv2\nfrom ultralytics import YOLO\nimport math\nimport os\n\n# Cargar el modelo\nmodel = YOLO('./FireGuardBestModel.pt')\n\n# Leer las clases\nclassnames = ['fire', 'neutral', 'smoke']\n\n# Crear un directorio para guardar las imágenes procesadas\nos.makedirs('../tmp', exist_ok=True)\n\n# Lista de imágenes a procesar\n# Coger las imagenes de ./img sin . .. y otros que no sean .jpg\nimages = [img for img in os.listdir('../img') if img.endswith('.jpg')]\n\nfor image_path in images:\n    # Leer la imagen\n    frame = cv2.imread(f'../img/{image_path}')\n    frame = cv2.resize(frame, (640, 480))\n\n    # Procesar la imagen con YOLO\n    result = model(frame, stream=True)\n    # Get confidence and class names\n    # print(result[0])\n\n    # Obtener la información de bbox, confianza y nombres de clases para trabajar con ella\n    for info in result:\n        boxes = info.boxes\n        for box in boxes:\n            confidence = box.conf[0]\n            confidence = math.ceil(confidence * 100)\n            Class = int(box.cls[0])\n            if confidence \u003e 10:\n                x1, y1, x2, y2 = box.xyxy[0]\n                x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)\n                print(f'Class: {classnames[Class]}, Confidence: {confidence}%')\n                cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 0, 255), 2)\n                # Write the class name and confidence\n                cv2.putText(frame, f'{classnames[Class]} {confidence}%', (x1 - 8, y1 - 8), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 1)\n\n\n                # Guardar la imagen procesada\n                processed_image_path = os.path.join('../tmp', os.path.basename(image_path))\n                cv2.imwrite(processed_image_path, frame)\n```\n\n\n--------------------------\n\n\n## Train\n\nIf you have enough time or you want to include custom data to train your own AI model, you can choose from\n1. Train in Google colab (recommended)\n2. Train in your machine\n\nYou can find the datasets from [release](https://github.com/ZhengLinLei/FireGuardML/releases/)\n\n\n### Google colab\n\n#### Dowload dataset and import to drive\n\nTo train the model in Google colab, be sure to have the datasets installed and uploaded to your Google drive with this name `~/D-Fire-datasets`. And check if you have this file branch\n\n```\n📁 D-Fire-datasets\n    |\n    \\-----\u003e 📁 fire\n                 |\n                 |----\u003e 📁 test\n                 |         |\n                 |         |---\u003e 📁 images (images)\n                 |         \\---\u003e 📁 labels (txt)\n                 |\n                 |----\u003e 📁 train\n                 |         |\n                 |         |---\u003e 📁 images (images)\n                 |         |---\u003e 📁 labels (txt)\n                 |         \\---\u003e 📄 labels.cache\n                 |\n                 |----\u003e 📁 train\n                 |         |\n                 |         |---\u003e 📁 images (images)\n                 |         |---\u003e 📁 labels (txt)\n                 |         \\---\u003e 📄 labels.cache\n                 |\n                 \\---\u003e 📄 data.yaml\n                 \n```\n\n### Download Colab file \n\nDonwload the source file from `./src/FireGuardML_Train.ipynb` and import it to google colab. **Be sure to enable GPU**\n\n\n-------\n\n### Own Machine\n\n#### Installation\nGo to `src/` and install dependecies\n\n```bash\npython3 -m pip install -r requirements.txt\n```\n\n#### Download datasets\n\nDown load the dataset from [release](https://github.com/ZhengLinLei/FireGuardML/releases/) and decompress it inside `./data` folder\n\n\n#### Usage\n\nTo train the model, execute the file `./src/setup.sh` inside `./src/context`\n\n```bash\ncd src\n./setup.sh\n```\n\n\n----------------------------------------------------------------------------\n\n\n## Information\n\n![Results](./doc/results.png)\n![Confusion](./doc/confusion_matrix_normalized.png)\n![Train](./doc/train_batch827.jpg)\n![Val_Train](./doc/val_batch0_pred.jpg)\n![R_Curve](./doc/R_curve.png)\n![PR_Curve](./doc/PR_curve.png)\n![P_Curve](./doc/P_curve.png)\n![Labels](./doc/labels.jpg)\n![Labels_Correc](./doc/labels_correlogram.jpg)\n\n\n\n\n \u003cp xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dct=\"http://purl.org/dc/terms/\"\u003e\u003ca property=\"dct:title\" rel=\"cc:attributionURL\" href=\"https://github.com/ZhengLinLei/FireGuardML\"\u003eFireGuardML\u003c/a\u003e by \u003ca rel=\"cc:attributionURL dct:creator\" property=\"cc:attributionName\" href=\"https://github.com/ZhengLinLei\"\u003eZheng Lin Lei\u003c/a\u003e is licensed under \u003ca href=\"http://creativecommons.org/licenses/by-nc/4.0/?ref=chooser-v1\" target=\"_blank\" rel=\"license noopener noreferrer\" style=\"display:inline-block;\"\u003eCC BY-NC 4.0\u003cimg style=\"height:22px!important;margin-left:3px;vertical-align:text-bottom;\" src=\"https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1\"\u003e\u003cimg style=\"height:22px!important;margin-left:3px;vertical-align:text-bottom;\" src=\"https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1\"\u003e\u003cimg style=\"height:22px!important;margin-left:3px;vertical-align:text-bottom;\" src=\"https://mirrors.creativecommons.org/presskit/icons/nc.svg?ref=chooser-v1\"\u003e\u003c/a\u003e\u003c/p\u003e ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhenglinlei%2Ffireguardml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhenglinlei%2Ffireguardml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhenglinlei%2Ffireguardml/lists"}