MCPcopy Create free account
hub / github.com/DragonisCV/RAM / dequantize_flow

Function dequantize_flow

ram/utils/flow_util.py:102–123  ·  view source on GitHub ↗

Recover from quantized flow. Args: dx (ndarray): Quantized dx. dy (ndarray): Quantized dy. max_val (float): Maximum value used when quantizing. denorm (bool): Whether to multiply flow values with width/height. Returns: ndarray: Dequantized flow.

(dx, dy, max_val=0.02, denorm=True)

Source from the content-addressed store, hash-verified

100
101
102def dequantize_flow(dx, dy, max_val=0.02, denorm=True):
103 """Recover from quantized flow.
104
105 Args:
106 dx (ndarray): Quantized dx.
107 dy (ndarray): Quantized dy.
108 max_val (float): Maximum value used when quantizing.
109 denorm (bool): Whether to multiply flow values with width/height.
110
111 Returns:
112 ndarray: Dequantized flow.
113 """
114 assert dx.shape == dy.shape
115 assert dx.ndim == 2 or (dx.ndim == 3 and dx.shape[-1] == 1)
116
117 dx, dy = [dequantize(d, -max_val, max_val, 255) for d in [dx, dy]]
118
119 if denorm:
120 dx *= dx.shape[1]
121 dy *= dx.shape[0]
122 flow = np.dstack((dx, dy))
123 return flow
124
125
126def quantize(arr, min_val, max_val, levels, dtype=np.int64):

Callers 1

flowreadFunction · 0.85

Calls 1

dequantizeFunction · 0.85

Tested by

no test coverage detected