# 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
pip install DarkNeurons
DarkNeuron is an Open Source Library . Target Audience are:
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 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 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:
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:
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:
split: Spliting of data automatically for validation and Training puroses
Code Example....
train,val,labels = classify.Preprocess_the_Image(method = 'point',train = True, x_train = x_train,y_train = y_train, x_test = x_test,y_test = y_test)
Let's Understand each argument:
Code Syntax:
test = classify.Preprocess_the_Image(method='image',train = False,
image_path = 'Path of the Image',
grayscale=False
)
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.
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
)
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
)
classify.Visualize_the_Metrics()
classify.Visualize_the_Predictions(number = 20)
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)
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:
csv
xml
text files
Code Syntax:
yolo.Prepare_the_Data(file_type,file_path, dataframe_name = None, class_file_name = None )
file_type: This contain file_type: whether csv, xml, or text_files
file_path: This contain the path to data directory
dataframe_name: This should be given as name of csv file in working_directory
class_file_name: provide name of the class list as text file in working directory
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
)
model_name: If user have predefine model, can provide the name.
input_shape: Input Shape for the model .
score: Score Threshold.
iou: Intersection Over Union thresholf over training (must change for better accuracy)
epochs1, epochs2: Epochs for Different Processes described above.
batch_size1, batch_size2: Batch Size for Differn Purposes
process1, process2: Process to be Done (Default: True)
This Function will be used to detect objects from video and Images.
This Function has following features:
Web Cam Detection --> It will Detect using webcams and can also be used by Mobile Phone Cameras ( see IPWebCam )
Choose Class --> You can choose your own prediction classes , means which object to predict which to not. For Example, on COCO dataset , it has 80 labels, then you should pass person to the function, it will detect only person, leave everthing else as it is.
Code Synatax:
yolo.Detect(test_folder_name = 'test', model_name = None, cam = False, videopath = 0, classes = [], score = 0.5, tracking = False )
test_folder_name: Test folder name in working directory ( images and video both, it will detect automatically and take actions according to it)
model_name: Model name saved in working_directory by Training, otherwise it will take yolov4.h5 by default.
cam: To enable Web Cam Detection
videopath: Path to the video to detect
classes: Selelctive choosing of Classes for Detections (Provide as List)
score: Threshold of Score for Prediction
tracking: DeepSort Tracking to be enable or not
[ ] Visualization of Neural Networks
MIT License
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.