Main class to modify networks
Main module for modifying networks
NetworkModifier
Class for transforming a deep CNN inputs and outputs. The network should be trained with Tensorflow
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
VersionModifyConfig
|
configurations to load and modify the network |
required |
Source code in conftrainer/modifications/modifier.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
input_placeholder
property
A default placeholder for signature inputs in case there's no input function specified
modified_signature: ConcreteFunction
property
Get a signature from custom inference function
Returns:
| Name | Type | Description |
|---|---|---|
out |
list of tf.TensorSpec
|
modified signatures of the network |
predict_batch(batch)
Wrap new prediction function to accept only one positional argument
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch |
tf.Tensor
|
a batch of inputs |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
tf.Tensor
|
predictions on received inputs |
Source code in conftrainer/modifications/modifier.py
preprocess(inp)
Apply resizing, preprocessing and input function on given inputs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inp |
tf.Tensor
|
A single input. Must be of input type of self.input_func if any, otherwise must be an image type |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
tf.Tensor
|
resized and preprocessed tensor |
Source code in conftrainer/modifications/modifier.py
save_modified(filepath)
Save the modified network to given path
First the method tries to save with newer model.save method. If the AttributeError is raised, the model will be saved with tf.saved_model. This behavior is usable when modifying older models saved with tf<2.5 or using tensorrt conversion
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath |
str
|
path to save the new model to |
required |
Source code in conftrainer/modifications/modifier.py
modify_multiple_networks(all_configs, serve_config_save_path)
Modify 1 or more network with given configurations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_configs |
List[NetModifyConfig]
|
configuration for modifying the networks |
required |
serve_config_save_path |
str
|
path to save generated serving config file |
required |
Source code in conftrainer/modifications/modifier.py
modify_single_net(model_config)
Modify and save a single network with given configuration
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_config |
VersionModifyConfig
|
configuration for modifying the network |
required |
Source code in conftrainer/modifications/modifier.py
options: docstring_style: numpy members_order: source