Tushar-ml / DarkNeuron

This Library will deal with the implementation of Automatic Deep Learning which can reduce the time and Complexity for non-technical users and Specialists in this field to train their own networks with significant accuracies and can perform Image Classification, Object Detection and hybridization of Models.
MIT License
5 stars 3 forks source link
automation-framework classification-model keras keras-tensorflow object-detection python yolov4

# Welcome to DarkNeuron !

Dark Neuron will deal with implementation of Automatic Deep Learning which can reduce the time and Complexity for non-technical users to train their own netwroks without Comprimising Accuracies for Classification of Images and Object Detection, most demanding tecniques for Autonomous Systems and Medical Fields.

" By augmenting human performance, AI has the potential to markedly improve productivity, efficiency, workflow, accuracy and speed, both for physicians and for patients … What I’m most excited about is using the future to bring back the past: to restore the care in healthcare. " - Eric Topol

CONTENTS :

Installation

pip install DarkNeurons

DarkNeuron Target Audience:

DarkNeuron is an Open Source Library . Target Audience are:

Classification of Images

DarkNeuron Classification has feature of implementing Pretrained Models on ImageNet Data. Users can directly train pretrained models or can retrain their own models. Models provided are:

Initialization of Classification Model

Initialization of Classification Model of DarkNeuron requires working_directory as a main argument. It should have models and Raw_Data in it. It can be Initialized as below:

from DarkNeurons import Classify_Images
classify = Classify_Images(working_directory = "Working Directory")

Preparation of Data

Preparation of Data for Classification takes place in terms of whether the user wants to Train the Model or Predict from the Model and the Method of Importing Images:

Method: Directory

Code Syntax: (Continue from above....)

train,val,labels = classify.Preprocess_the_Image(method = 'directory', train =True,
            num_classes = 2, batch_size = 32, #Default
            target_image_size = (224,224,3) #Default
            model_name = 'InceptionV3',
            user_model = None, #Default,
            training_image_directory = 'Directory_Path
            validation_image_directory = None,
            )

Let's See each argument and their default values:

Method: DataFrame

Code Syntax:

train,val,labels = classify.Preprocess_the_Image(method = 'dataframe', train = True,
            num_classes = 2,batch_size = 32,
            dataframe = df ,
            x_col_name = 'filename',
            y_col_name = 'label',
            image_directory = None,
            split = 0.1 )

Let's Understand the above arguments:

Let's Understand each argument:

Method: Image

Code Syntax:

test = classify.Preprocess_the_Image(method='image',train = False,
            image_path = 'Path of the Image',
            grayscale=False
            )

Model Creation

This Feature takes no argument , but necessary when user provide model_name .
It will create the full structure of the model based on the data provided in Prepare the Data function call.

model = classify.Create_the_Model()

That's it. Model will be created and Generated. If you have PreDownloaded weights, then must sure the following:

Otherwise, it will automatically Download the weights.

Model Training

This Feature will be used for Model Training purposes . Code Syntax:

model = classify.Train_the_Model(model = model,
                rebuild = False,
                train_data_object = train,
                validation_data_object = train,
                epochs = 10,
                optimizers = 'adam',
                loss = 'binary_crossentropy',
                fine_tuning = False,
                layers = 20,
                metrics = ['accuracy'],
                validation_steps = 80,
                steps_per_epoch = 50,
                callbacks = None
                )

Prediction

This Feature will be used for Prediction from the model on the Test Dataset.
To do this step, First Prepare the Data with train argument set to False and obtain test object from it.

Code Syntax:

classify.Predict_from_the_Model(labels = labels,
                model = model,
                img = None,
                generator = None,
                top = 5
                )

Visualization of Predictions and Metrics

Metrics Visualization

classify.Visualize_the_Metrics()

Prediction Visualization

classify.Visualize_the_Predictions(number = 20)

Here Comes the Ending to Classification Part

Let's move on to Object Detection Part

Object Detection (YOLOv4)

Initialization of Object Detection Model

This Function will take working directory as an argument where the training data is present and weights be present . If no weights are there then it will be downloaded.
If you have predefined yolov4 weights : Named it as --> 'yolov4.weights' If you have predefined yolov4 model: Named it as --> 'yolov4.h5'

from DarkNeuron import YOLOv4
yolo = YOLOv4( working_directory , output_directory)

Preparation of Data

For this Function, All Images and corressponding labels should be in working_Directory within no sub folder.( For Simplicity, Train directory = Working directory). This Function take file in three formats and converted them into YOLO Format Automatically:

Model Training

This Function will be used to Train the model on user custom data set.
There are two process involved :

Code Syntax:

yolo.Train_the_Yolo(model_name = 'yolov4.h5',
            input_shape = (608,608) #Multiple of 32 required
            score = 0.5,
            iou = 0.5,
            epochs1 = 50, #For Process 1
            epochs2 = 51, #For Process 2
            batch_size1 = 32,
            batch_size2 = 4,
            validation_split = 0.1,
            process1 = True,
            process2 = True
           )

Further Release

Copyright (c) 2020 DarkNeuron Tushar-ml

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.