tensorcv.utils.common.
apply_mask
(input_matrix, mask)[source]¶Get partition of input_matrix using index 1 in mask.
Parameters: |
|
---|---|
Returns: | A Tensor with elements from data with entries in mask equal to 1. |
tensorcv.utils.common.
apply_mask_inverse
(input_matrix, mask)[source]¶Get partition of input_matrix using index 0 in mask.
Parameters: |
|
---|---|
Returns: | A Tensor with elements from data with entries in mask equal to 0. |
tensorcv.utils.common.
get_tensors_by_names
(names)[source]¶Get a list of tensors by the input name list.
Parameters: | names (str) – A str or a list of str |
---|---|
Returns: | A list of tensors with name in input names. |
Warning
If more than one tensor have the same name in the graph. This function will only return the tensor with name NAME:0.
tensorcv.utils.common.
deconv_size
(input_height, input_width, stride=2)[source]¶Compute the feature size (height and width) after filtering with a specific stride. Mostly used for setting the shape for deconvolution.
Parameters: | |
---|---|
Returns: | (int, int) – Height and width of feature after filtering. |
tensorcv.utils.common.
match_tensor_save_name
(tensor_names, save_names)[source]¶Match tensor_names and corresponding save_names for saving the results of the tenors. If the number of tensors is less or equal to the length of save names, tensors will be saved using the corresponding names in save_names. Otherwise, tensors will be saved using their own names. Used for prediction or inference.
Parameters: | |
---|---|
Returns: | (list, list) – List of tensor names and list of names to save the tensors. |
tensorcv.utils.sesscreate.
NewSessionCreator
(target='', graph=None, config=None)[source]¶Bases: tensorflow.python.training.monitored_session.SessionCreator
tf.train.SessionCreator for a new session
tensorcv.utils.sesscreate.
ReuseSessionCreator
(sess)[source]¶Bases: tensorflow.python.training.monitored_session.SessionCreator
tf.train.SessionCreator for reuse an existed session
tensorcv.utils.utils.
get_rng
(obj=None)[source]¶This function is copied from tensorpack. Get a good RNG seeded with time, pid and the object. :param obj: some object to use to generate random seed.
Returns: | np.random.RandomState – the RNG. |
---|
tensorcv.utils.viz.
image_overlay
(im_1, im_2, color=True, normalize=True)[source]¶Overlay two images with the same size.
Parameters: | |
---|---|
Returns: | np.ndarray – an overlay image of im_1*0.5 + im_2*0.5 |
tensorcv.utils.viz.
intensity_to_rgb
(intensity, cmap='jet', normalize=False)[source]¶This function is copied from tensorpack. Convert a 1-channel matrix of intensities to an RGB image employing a colormap. This function requires matplotlib. See matplotlib colormaps for a list of available colormap.
Parameters: | |
---|---|
Returns: | np.ndarray – an RGB float32 image in range [0, 255], a colored heatmap. |
tensorcv.utils.viz.
save_merge_images
(images, merge_grid, save_path, color=False, tanh=False)[source]¶Save multiple images with same size into one larger image.
The best size number is int(max(sqrt(image.shape[0]),sqrt(image.shape[1]))) + 1
Parameters: |
|
---|
Example
The batch_size is 64, then the size is recommended [8, 8]. The batch_size is 32, then the size is recommended [6, 6].