{"id":15065029,"url":"https://github.com/ushariranasinghe/fire-detection","last_synced_at":"2026-01-02T23:05:38.328Z","repository":{"id":256632777,"uuid":"844044325","full_name":"ushariRanasinghe/Fire-Detection","owner":"ushariRanasinghe","description":" CNN for fire detection using OpenCV techniques to enhance image features, achieving robust performance with TensorFlow and Keras. ","archived":false,"fork":false,"pushed_at":"2024-09-20T09:55:21.000Z","size":6203,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T11:39:36.520Z","etag":null,"topics":["cnn-classification","keras","opencv","pandas","tensorflow2"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ushariRanasinghe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2024-08-18T07:51:33.000Z","updated_at":"2024-09-20T09:55:24.000Z","dependencies_parsed_at":"2024-09-14T21:59:40.196Z","dependency_job_id":"a188fb78-1d3b-4c32-9d42-4ad54cd5200c","html_url":"https://github.com/ushariRanasinghe/Fire-Detection","commit_stats":null,"previous_names":["ushariranasinghe/fire-detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushariRanasinghe%2FFire-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushariRanasinghe%2FFire-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushariRanasinghe%2FFire-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ushariRanasinghe%2FFire-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ushariRanasinghe","download_url":"https://codeload.github.com/ushariRanasinghe/Fire-Detection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243801610,"owners_count":20350106,"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":["cnn-classification","keras","opencv","pandas","tensorflow2"],"created_at":"2024-09-25T00:29:42.022Z","updated_at":"2026-01-02T23:05:38.322Z","avatar_url":"https://github.com/ushariRanasinghe.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fire Detection with Custom CNN\n\n## Overview\n\nThis project aims to detect fire in images using a Convolutional Neural Network (CNN). To improve the accuracy and reduce the training time of the model, different features of the images are extracted using cv2 library, and fed into a multi-input CNN.\n\n## Components\n\n### Data Preparation\n\n- **Dataset**: The dataset is divided into two directories: `fire` and `non_fire`, each containing images for respective classes.\n- **Data Loading**: Images are loaded into a Pandas DataFrame along with their labels (`fire` or `non_fire`).\n\n### Image Preprocessing\n\nImages are preprocessed using three types of masks:\n1. **Edge Mask**: Highlights edges in the image using Canny edge detection.\n2. **Heatmap Mask**: Identifies bright regions that may indicate fire.\n3. **Color Mask**: Isolates fire-like colors (reds, oranges, yellows) to highlight potential fire areas.\n\n### Custom Data Generator\n\nA custom data generator is implemented to:\n- Load and preprocess images.\n- Apply the three types of masks.\n- Normalize the images.\n- Yield batches of three masked images and their corresponding labels for model training.\n\n### Model Architecture\n\nA CNN model with three input branches is designed to process the three masked images. The model includes:\n- **Convolutional Layers**: To extract features from images.\n- **Pooling Layers**: To reduce spatial dimensions.\n- **Dense Layers**: To classify images into fire or non-fire.\n\nThe model is compiled using the Adam optimizer with a learning rate of 0.0001 and binary crossentropy loss.\n\n### Training and Evaluation\n\n- **Training**: The model is trained with a training set and validated with a validation set using custom data generators. Callbacks are used to manage learning rate adjustments and save the best model.\n- **Evaluation**: The model is evaluated on a test set to measure loss and accuracy.\n\n### Prediction and Visualization\n\n- **Prediction**: The model predicts the class of images (fire or non-fire) based on the preprocessed inputs.\n- **Visualization**: A set of test images with predictions is displayed to assess the model's performance visually.\n\n## Requirements\n\n- Python 3.x\n- TensorFlow 2.x\n- OpenCV\n- NumPy\n- Pandas\n- Matplotlib\n- PIL\n- tqdm\n\n## Usage\n\n1. **Prepare the Dataset**: Ensure the dataset directories are properly set up and contain images in the `fire` and `non_fire` categories.\n2. **Run the Code**: Execute the provided script to load data, preprocess images, train the model, and evaluate performance.\n3. **Visualize Results**: View the predictions on test images to understand the model's performance.\n\n## Notes\n\n- **Image Size**: The images are resized to 150x150 pixels.\n- **Masks**: Custom masks are designed to enhance features relevant to fire detection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fushariranasinghe%2Ffire-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fushariranasinghe%2Ffire-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fushariranasinghe%2Ffire-detection/lists"}