Package: deeptoolkit
DeepToolKitDeepToolKit provides implementations of popular machine learning algorithms, extensions to existing
deep learning pipelines using TensorFlow and Keras, and convenience utilities to speed up the process
of implementing, training, and testing deep learning models. In addition, DeepToolKit includes an inbuilt
computer vision module containing implementations of facial detection and image processing algorithms.InstallationPython PackageDeepToolKit can be installed directly from the command line:pipinstalldeeptoolkitYou can then work with it either by importing the library as a whole, or by importing
the functionality you need from the relevant submodules.# Complete library import.importdeeptoolkitasdtk# Module and function imports.fromdeeptoolkit.dataimportplot_data_clusterfromdeeptoolkit.blocksimportSeparableConvolutionBlockfromdeeptoolkit.lossesimportCategoricalFocalLossFrom SourceIf you want to install DeepToolKit directly from source, (i.e. for local development), then first
install the git source:gitclonehttps://github.com/amogh7joshi/deeptoolkit.gitThen install system requirements and activate the virtual environment. A Makefile is included for installation:makeinstallFeaturesDeepToolKit provides a number of features to either use standalone or integrated in a deep learning model
construction pipeline. Below is a high-level list of features in the module. Proper documentation is under construction.Model Architecture Blocks:deeptoolkit.blocksGeneric model architecture blocks, including convolution and depthwise separable convolution blocks, implemented astf.keras.layers.Layerobjects so you can directly use them in a Keras model.Applied model architecture blocks, including squeeze and excitation blocks and ResNet identity blocks.For Example:fromtensorflow.keras.modelsimportModelfromtensorflow.keras.layersimportMaxPooling2Dfromtensorflow.keras.layersimportInput,Dense,Flattenfromdeeptoolkit.blocksimportConvolutionBlock# Construct a Keras Functional model like normal.inp=Input((256,256,3))x=ConvolutionBlock(32,kernel_size=(3,3),activation='relu')(inp)x=MaxPooling2D(pool_size=(2,2))(x)x=ConvolutionBlock(16,kernel_size=(3,3),activation='relu')(x)x=MaxPooling2D(pool_size=(2,2))(x)x=Flatten()(x)x=Dense(1024,activation='relu')(x)x=Dense(10,activation='relu')(x)model=Model(inp,x)Loss Functions:deeptoolkit.lossesCustom loss functions including binary and categorical focal loss, built astf.keras.losses.Lossobjects
so you can use them in a Keras model training pipeline as well.For Example:fromtensorflow.keras.optimizersimportAdamfromdeeptoolkit.lossesimportBinaryFocalLoss# Using the model from the above example.model.compile(optimizer=Adam(),loss=BinaryFocalLoss(),metrics=['accuracy'])Data Processing and Visualization:deeptoolkit.dataData preprocessing, including splitting data into train, validation, and test sets, and
shuffling datasets while keeping data-label mappings intact.Data visualization, including cluster visualizations.For Example:importnumpyasnpfromdeeptoolkit.dataimporttrain_val_test_splitX=np.random.random(100)y=np.random.random(100)X_train,X_val,X_test,y_train,y_val,y_test=train_val_test_split(X,y,split=[0.6,0.2,0.2])Model Evaluation:deeptoolkit.evaluationModel evaluation resources, including visualization of model training metrics over time.Computer Vision:deeptoolkit.visionA pre-built facial detection model:deeptoolkit.vision.FacialDetector. A large number of modern
computer vision algorithms include a facial detection component, and DeepToolKit's facial detection module
provides fast and accurate face detection using OpenCV's DNN implementation. To use it, simply execute the
following:importcv2fromdeeptoolkit.visionimportFacialDetector# Initialize detector.detector=FacialDetector()# Detect face from image path and save image to path.detector.detect_face('image/path',save='image/save/path')# Detect face from existing image and continue to use it.image=cv2.imread('image/path')annotated_image=detector.detect_face(image)LicenseAll code in this repository is licensed under theMIT License.Issue ReportingIf you notice any issues or bugs in the library, please create an issue under the issues tab. To get started
and for more information, see theissue templates.