You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A small library for speeding up the dataset preparation and model testing steps for deep learning on various frameworks. (mostly for me)
What can it do
Creates all the required files for darknet-yolo3,4 training including cfg file with default parameters and class calculations in a single line. (example usage)
Creates train ready data for image classification tasks for keras in a single line.(example usage)
Makes multiple image prediction process easier with using keras model from both array and directory.
Predicts and saves multiple images on a directory with using darknet.
Includes a simple annotation tool for darknet-yolo style annotation. (example usage)
Auto annotation by given random points for yolo.(example usage)
Draws bounding boxes of the images from annotation files for preview.
Plots training history graph from keras history object.(example usage)
fromimagepreprocessing.keras_functionsimportcreate_history_graph_keras# training# history = model.fit(...)create_history_graph_keras(history)
Make prediction from test array and create the confusion matrix with keras model
fromimagepreprocessing.keras_functionsimportcreate_training_data_keras, make_prediction_from_array_kerasfromimagepreprocessing.utilitiesimportcreate_confusion_matrix, train_test_splitimages_path="datasets/my_dataset"# Create training data split the datax, y, x_val, y_val=create_training_data_keras(images_path, save_path=None, validation_split=0.2, percent_to_use=0.5)
# split training datax, y, test_x, test_y=train_test_split(x,y,save_path=save_path)
# ...# training# ...class_names= ["apple", "melon", "orange"]
# make predictionpredictions=make_prediction_from_array_keras(test_x, model, print_output=False)
# create confusion matrixcreate_confusion_matrix(predictions, test_y, class_names=class_names, one_hot=True)
create_confusion_matrix(predictions, test_y, class_names=class_names, one_hot=True, cmap_color="Blues")
Make multi input model prediction and create the confusion matrix
fromimagepreprocessing.keras_functionsimportcreate_training_data_kerafromimagepreprocessing.utilitiesimportcreate_confusion_matrix, train_test_splitimportnumpyasnp# Create training data split the data and split the datasource_path="datasets/my_dataset"x, y=create_training_data_keras(source_path, image_size=(28,28), validation_split=0, percent_to_use=1, grayscale=True, convert_array_and_reshape=False)
x, y, test_x, test_y=train_test_split(x,y)
# prepare the data for multi input training and testingx1=np.array(x).reshape(-1,28,28,1)
x2=np.array(x).reshape(-1,28,28)
y=np.array(y)
x= [x1, x2]
test_x1=np.array(test_x).reshape(-1,28,28,1)
test_x2=np.array(test_x).reshape(-1,28,28)
test_y=np.array(test_y)
test_x= [test_x1, test_x2]
# ...# training# ...# make predictionpredictions=make_prediction_from_array_keras(test_x, model, print_output=False, model_summary=False, show_images=False)
# create confusion matrixcreate_confusion_matrix(predictions, test_y, class_names=["0","1","2","3","4","5","6","7","8","9"], one_hot=True)
Create required files for training on darknet-yolo and auto annotate images by center
Auto annotation is for testing the dataset or just for using it for classification, detection won't work without proper annotations.
fromimagepreprocessing.darknet_functionsimportcreate_training_data_yolo, auto_annotation_by_random_pointsimportosmain_dir="datasets/my_dataset"# auto annotating all images by their center points (x,y,w,h)folders=sorted(os.listdir(main_dir))
forindex, folderinenumerate(folders):
auto_annotation_by_random_points(os.path.join(main_dir, folder), index, annotation_points=((0.5,0.5), (0.5,0.5), (1.0,1.0), (1.0,1.0)))
# creating required filescreate_training_data_yolo(main_dir)