c4dynamics.datasets.nn_model

Contents

c4dynamics.datasets.nn_model#

c4dynamics.datasets.nn_model(nn_name: str) str[source]#

Fetches the path of a neural network model from the local cache.

nn_model downloads and manages neural network files from c4dynamics datasets.

NN Name

Description

YOLOv3

Pre-trained weights file (237 MB)

YOLOv3 weights file can be found at https://pjreddie.com/media/files/yolov3.weights

Parameters:

nn_name (str) – The name of the neural network model to download

Returns:

out (str) – A path to the neural network in the local cache

Examples

Import required packages:

>>> import c4dynamics as c4d
>>> import cv2

Print first 5 layers of YOLOv3:

>>> impath = c4d.datasets.nn_model('yolov3')
Fetched successfully
>>> net = cv2.dnn.readNet(impath, 'c4dynamics/detectors/yolov3.cfg')
>>> for i, layer in enumerate(net.getLayerNames()):
...   print(f"Layer {i}:  {layer}")
...   if i > 4: break
Layer 0:  conv_0
Layer 1:  bn_0
Layer 2:  leaky_1
Layer 3:  conv_1
Layer 4:  bn_1
Layer 5:  leaky_2