swirlspy.qpf.dl.helpers package
Submodules
swirlspy.qpf.dl.helpers.gifmaker module
- swirlspy.qpf.dl.helpers.gifmaker.save_gif(single_seq, fname)
Save a single gif consisting of image sequence in single_seq to fname.
- swirlspy.qpf.dl.helpers.gifmaker.save_gifs(seq, prefix)
Save several gifs.
- Parameters:
seq (Shape (num_gifs, IMG_SIZE, IMG_SIZE))
prefix (prefix-idx.gif will be the final filename.)
swirlspy.qpf.dl.helpers.log_analysis module
- swirlspy.qpf.dl.helpers.log_analysis.parse_log(file_path, regex)
- Parameters:
file_path
regex
- swirlspy.qpf.dl.helpers.log_analysis.remove_duplicates_and_convert_npy(val_list)
- swirlspy.qpf.dl.helpers.log_analysis.temporal_smoothing(training_statistics, stride=10, window_size=100)
We always assume the first axis in statistics is the iteration
- Parameters:
training_statistics
stride
window_size
- Returns:
smoothed_mean
smoothed_std
swirlspy.qpf.dl.helpers.msssim module
Python implementation of MS-SSIM. Usage: python msssim.py –original_image=original.png –compared_image=distorted.png
- swirlspy.qpf.dl.helpers.msssim.MultiScaleSSIM(img1, img2, max_val=255, filter_size=11, filter_sigma=1.5, k1=0.01, k2=0.03, weights=None)
Return the MS-SSIM score between img1 and img2. This function implements Multi-Scale Structural Similarity (MS-SSIM) Image Quality Assessment according to Zhou Wang’s paper, “Multi-scale structural similarity for image quality assessment” (2003). Link: https://ece.uwaterloo.ca/~z70wang/publications/msssim.pdf Author’s MATLAB implementation: http://www.cns.nyu.edu/~lcv/ssim/msssim.zip
- Parameters:
img1 (Numpy array holding the first RGB image batch.)
img2 (Numpy array holding the second RGB image batch.)
max_val (the dynamic range of the images (i.e., the difference between the) – maximum the and minimum allowed values).
filter_size (Size of blur kernel to use (will be reduced for small images).)
filter_sigma (Standard deviation for Gaussian blur kernel (will be reduced) – for small images).
k1 (Constant used to maintain stability in the SSIM calculation (0.01 in) – the original paper).
k2 (Constant used to maintain stability in the SSIM calculation (0.03 in) – the original paper).
weights (List of weights for each level; if none, use five levels and the) – weights from the original paper.
- Return type:
MS-SSIM score between img1 and img2.
- Raises:
RuntimeError – If input images don’t have the same shape or don’t have four: dimensions: [batch_size, height, width, depth].
swirlspy.qpf.dl.helpers.ordered_easydict module
- class swirlspy.qpf.dl.helpers.ordered_easydict.OrderedEasyDict(d=None, **kwargs)
Bases:
OrderedDictUsing OrderedDict for the easydict package See Also https://pypi.python.org/pypi/easydict/
swirlspy.qpf.dl.helpers.visualization module
- swirlspy.qpf.dl.helpers.visualization.flow_to_img(flow_dat, max_displacement=None)
Convert optical flow data to HSV images
- Parameters:
flow_dat (np.ndarray) – Shape: (seq_len, 2, H, W)
max_displacement (float or None)
- Returns:
rgb_dat – Shape: (seq_len, 3, H, W)
- Return type:
np.ndarray
- swirlspy.qpf.dl.helpers.visualization.get_color_flow_legend_image(size=50)
- swirlspy.qpf.dl.helpers.visualization.merge_rgba_cv2(front_img, back_img)
Merge the front image with the background image using the Painter’s algorithm
- Parameters:
front_img (np.ndarray)
back_img (np.ndarray)
- Returns:
result_img
- Return type:
np.ndarray
- swirlspy.qpf.dl.helpers.visualization.save_hko_gif(im_dat, save_path)
Save the HKO images to gif
- Parameters:
im_dat (np.ndarray) – Shape: (seqlen, H, W)
save_path (str)
- swirlspy.qpf.dl.helpers.visualization.save_hko_movie(im_dat, datetime_list, mask_dat=None, save_path='hko.mp4', masked=False, fps=5, prediction_start=None)
Save the HKO images to a video file
- Parameters:
im_dat (np.ndarray) – Shape : (seq_len, H, W)
datetime_list (list) – list of datetimes
mask_dat (np.ndarray or None) – Shape : (seq_len, H, W)
save_path (str)
masked (bool) – whether the mask the inputs when saving the image
fps (float) – the fps of the saved movie
prediction_start (int or None) – The starting point of the prediction