A collection of deep learning -- computer vision utility functions
pip install optical_toolkit
Visualize a dataset in a grid
from sklearn .datasets import load_digits
from optical_toolkit .visualize import plot_images
X , y = load_digits ()
plot_images (X , targets = y )
Summarize a dataset by classes
from sklearn .datasets import load_digits
from optical_toolkit .visualize import plot_images
X , y = load_digits ()
summarize_images (X , targets = y , num_images_per_class = 10 , num_classes = 10 )
Visualize the 2d and 3d embeddings of images
from sklearn .datasets import load_digits
from optical_toolkit .visualize .embeddings import get_embeddings
X , y = load_digits ()
2 d_embeddings , fig_2d = get_embeddings (X , y , dims = 2 , embedding_type = "tsne" , return_plot = True )
3 d_embeddings , fig_3d = get_embeddings (X , y , dims = 3 , embedding_type = "tsne" , return_plot = True )
Visualize the filters of a (trained) CNN model
from optical_toolkit .cnn_filters import display_filters , display_model_filters
model_name = "xception"
layer_names = [
"block2_sepconv1" ,
"block5_sepconv1" ,
"block9_sepconv1" ,
"block14_sepconv1" ,
]
for layer_name in layer_names :
display_filters (
model = model_name ,
layer_name = layer_name ,
)
display_model_filters (model = model_name )
Visualize the filters of your custom CNN with custom objects
import keras
model_name = "examples/custom_models/svdnet.keras"
dir_name = "examples/insights"
@keras .saving .register_keras_serializable ()
class ResidualConvBlock (keras .layers .Layer ):
...
display_model_filters (
model_name ,
custom_layer_prefix = "residual" ,
)
A high level function for image dataset analysis
from sklearn .datasets import load_digits
from optical_toolkit .analyze .analyze import analyze_image_dataset
digits = load_digits ()
X = digits .images
y = digits .target
analyze_image_dataset (X , y , output_path = "examples/analyze/analysis.pdf" )
View full analysis (PDF)