Functions to apply to input/output of networks
tensorflow functions to add into input or output signatures of model
argmax_predictions(predictions)
Return argmax of given predictions for each sample
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions |
tf.Tensor
|
outputs of the network |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
tf.Tensor
|
indices of maximal value for each prediction row |
Source code in conftrainer/modifications/tf_functions.py
base64_to_img(base64)
Decode a base64 encoded image onto jpeg
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base64 |
tf.Tensor, str
|
base64 to decode |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
tf.Tensor
|
decoded image |
Source code in conftrainer/modifications/tf_functions.py
img_to_base64(image, return_string=True)
Encode a single image to base64 format
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image |
tf.Tensor
|
input image |
required |
return_string |
bool
|
whether to return regular string or a tf.string |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
tf.Tensor
|
base64 encoding of an image |
Source code in conftrainer/modifications/tf_functions.py
read_from_disk(path)
Read and decode an image from disk
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path |
str
|
path to the file to read |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
tf.Tensor
|
an image |
Source code in conftrainer/modifications/tf_functions.py
rescale(images, scale, offset)
Rescale and normalize image arrays by given factors
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images |
tf.Tensor
|
a batch of images |
required |
scale |
float
|
a float to divide the inputs into |
required |
offset |
float
|
a float to add to all inputs |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
tf.Tensor
|
preprocessed batch of images |
Source code in conftrainer/modifications/tf_functions.py
options: docstring_style: numpy members_order: source