Code Monkey home page Code Monkey logo

fire-detection's People

Contributors

hatellezp avatar skar0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fire-detection's Issues

error program launcher.py

import argparse
import numpy as np
from keras.models import load_model
from keras.preprocessing import image
from evaluate_model import evaluate_model, extract_hard_samples
from transfer_learning import train_simpler_inception_based_model
from video_annotation import video_fire_detection
from keras.applications.inception_v3 import preprocess_input as inception_preprocess_input

if name == 'main':

classes = ['fire', 'no_fire', 'start_fire']

parser = argparse.ArgumentParser(description='Convolutional neural network for forest fire detection',
                                 formatter_class=argparse.ArgumentDefaultsHelpFormatter)

subparsers = parser.add_subparsers(title='',
                                   description='Network can be trained on a provided dataset or predictions can be'
                                               'made using a pre-trained model. Models can also be evaluated.',
                                   help='', dest='mode')

subparsers.required = True


parser_train = subparsers.add_parser('train',
                                     help='Create and train the simpler InceptionV3-based model.',
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser_train.add_argument('-data',
                          type=str,
                          action='store',
                          dest='dataset',
                          help='Path to the dataset on which to train.',
                          default=argparse.SUPPRESS,
                          required=True)

parser_train.add_argument('-prop',
                          type=float,
                          action='store',
                          dest='proportion',
                          help='Proportion of the dataset to be used for training (the rest is for validation).',
                          default=argparse.SUPPRESS,
                          required=True)

parser_train.add_argument('-freeze',
                          type=bool,
                          action='store',
                          dest='freeze',
                          help='Whether to freeze every layer except the last fully connected ones.',
                          default=argparse.SUPPRESS,
                          required=True)

parser_train.add_argument('-epochs',
                          type=int,
                          action='store',
                          dest='epochs',
                          help='Number of epochs.',
                          default=10,
                          required=False)

parser_train.add_argument('-batch',
                          type=int,
                          action='store',
                          dest='batch_size',
                          help='Size of a batch.',
                          default=32,
                          required=False)

parser_tune = subparsers.add_parser('tune', help='Fine-tune a pre-trained Inception-V3-based model.',
                                    formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser_tune.add_argument('-model',
                         type=str,
                         action='store',
                         dest='model_path',
                         help='Path to the pre-trained model.',
                         default=argparse.SUPPRESS,
                         required=True)

parser_tune.add_argument('-lr',
                         type=float,
                         action='store',
                         dest='learning_rate',
                         help='Learning rate to be used for fine-tuning.',
                         default=0.001,
                         required=False)

parser_tune.add_argument('-data',
                         type=str,
                         action='store',
                         dest='dataset',
                         help='Path to the dataset on which to train.',
                         default=argparse.SUPPRESS,
                         required=True)

parser_tune.add_argument('-prop',
                         type=float,
                         action='store',
                         dest='proportion',
                         help='Proportion of the dataset to be used for training (the rest is for validation).',
                         default=argparse.SUPPRESS,
                         required=True)

parser_tune.add_argument('-freeze',
                         type=bool,
                         action='store',
                         dest='freeze',
                         help='Whether to freeze every layer except the last fully connected ones.',
                         default=argparse.SUPPRESS,
                         required=True)

parser_tune.add_argument('-epochs',
                         type=int,
                         action='store',
                         dest='epochs',
                         help='Number of epochs.',
                         default=10,
                         required=False)

parser_tune.add_argument('-batch',
                         type=int,
                         action='store',
                         dest='batch_size',
                         help='Size of a batch.',
                         default=32,
                         required=False)

parser_predict = subparsers.add_parser('predict',
                                       help='Perform prediction on a provided picture.')

parser_predict.add_argument('-path',
                            type=str,
                            action='store',
                            dest='image_path',
                            help='Path to an image.',
                            default=argparse.SUPPRESS,
                            required=True)

parser_predict.add_argument('-model',
                            type=str,
                            action='store',
                            dest='model_path',
                            help='Path to a trained model.',
                            default=argparse.SUPPRESS,
                            required=True)

parser_video = subparsers.add_parser('video',
                                     help='Perform prediction on a video.',
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser_video.add_argument('-in',
                          type=str,
                          action='store',
                          dest='input_video_path',
                          help='Path to an mp4 video.',
                          default=argparse.SUPPRESS,
                          required=True)

parser_video.add_argument('-out',
                          type=str,
                          action='store',
                          dest='output_video_path',
                          help='Path to output the annotated mp4 video.',
                          default=argparse.SUPPRESS,
                          required=True)

parser_video.add_argument('-model',
                          type=str,
                          action='store',
                          dest='model_path',
                          help='Path to a trained model.',
                          default=argparse.SUPPRESS,
                          required=True)

parser_video.add_argument('-freq',
                          type=int,
                          action='store',
                          dest='freq',
                          help='Prediction is to be made every freq frames.',
                          default=12,
                          required=False)

parser_extract = subparsers.add_parser('extract',
                                       help='Extract hard examples from a dataset (samples classified with low '
                                            'confidence).')

parser_extract.add_argument('-data',
                            type=str,
                            action='store',
                            dest='dataset',
                            help='Path to a dataset.',
                            default=argparse.SUPPRESS,
                            required=True)

parser_extract.add_argument('-model',
                            type=str,
                            action='store',
                            dest='model_path',
                            help='Path to a trained model.',
                            default=argparse.SUPPRESS,
                            required=True)

parser_extract.add_argument('-threshold',
                            type=float,
                            action='store',
                            dest='extract_threshold',
                            help='Threshold for the hard examples.',
                            default=argparse.SUPPRESS,
                            required=True)

parser_test = subparsers.add_parser('test',
                                    help='Test a model on a test set of images.')

parser_test.add_argument('-data',
                         type=str,
                         action='store',
                         dest='dataset',
                         help='Path to a test set.',
                         default=argparse.SUPPRESS,
                         required=True)

parser_test.add_argument('-model',
                         type=str,
                         action='store',
                         dest='model_path',
                         help='Path to a trained model.',
                         default=argparse.SUPPRESS,
                         required=True)

parsed = parser.parse_args()

if parsed.mode == "train":

    train_simpler_inception_based_model(parsed.dataset,
                                        fine_tune_existing=None,
                                        freeze=parsed.freeze,
                                        learning_rate=0.001,
                                        percentage=parsed.proportion,
                                        nbr_epochs=parsed.epochs,
                                        batch_size=parsed.batch_size)

elif parsed.mode == "tune":

    train_simpler_inception_based_model(parsed.dataset,
                                        fine_tune_existing=parsed.model_path,
                                        freeze=parsed.freeze,
                                        learning_rate=parsed.learning_rate,
                                        percentage=parsed.proportion,
                                        nbr_epochs=parsed.epochs,
                                        batch_size=parsed.batch_size)

elif parsed.mode == "predict":

    model = load_model(parsed.model_path)

    img = image.load_img(parsed.image_path, target_size=(224, 224, 3))

    # processed image to feed the network
    processed_img = image.img_to_array(img)
    processed_img = np.expand_dims(processed_img, axis=0)
    processed_img = inception_preprocess_input(processed_img)

    # get prediction using the network
    predictions = model.predict(processed_img)[0]

    print(predictions)

elif parsed.mode == "video":

    video_fire_detection(parsed.input_video_path,
                         parsed.output_video_path,
                         parsed.model_path,
                         inception_preprocess_input,
                         (224, 224),
                         parsed.freq)

elif parsed.mode == "extract":
    print(extract_hard_samples(parsed.model_path,
                               inception_preprocess_input,
                               parsed.dataset,
                               parsed.extract_threshold))

elif parsed.mode == "test":
    print(evaluate_model(parsed.model_path,
                         classes,
                         inception_preprocess_input,
                         parsed.dataset,
                               parsed.extract_threshold))   

git lfs, faild download pretrained model

git lfs faild download pretrained model .
here is faild log.

batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.