10
10
11
11
from ARFlow .utils .torch_utils import restore_model
12
12
from ARFlow .models .pwclite import PWCLite
13
- from config import DATA_PATH , MAX_FLOW_VAL
14
- from utils .flow_utils import quantize_flow
15
13
from ARFlow .utils .warp_utils import flow_warp
14
+ from config import DATA_PATH
15
+
16
16
17
17
18
18
def calculate_binary_flow_weights (org_img , warped_img , thr_value , thr_type ):
@@ -87,12 +87,7 @@ def generate_arflow_flow(args):
87
87
88
88
binary_weights = calculate_binary_flow_weights (image1 , re_image1 , args .thr_value , args .thr_type )
89
89
flow = flow * binary_weights [:,:,None ]
90
- if args .raw :
91
- np .save (flow_folder / imfile1 .with_suffix ('.npy' ).name , flow )
92
- else :
93
- dx , dy = quantize_flow (flow , max_val = MAX_FLOW_VAL , norm = False )
94
- flow = np .stack ([dx , dy , np .zeros (dx .shape )], axis = - 1 )
95
- cv2 .imwrite ((flow_folder / imfile1 .name ).as_posix (), flow [:, :, [2 , 1 , 0 ]])
90
+ np .save (flow_folder / imfile1 .with_suffix ('.npy' ).name , flow )
96
91
97
92
images = list (reversed (images ))
98
93
print (f'Working on folder: { folder .name } in backward direction' )
@@ -111,20 +106,14 @@ def generate_arflow_flow(args):
111
106
112
107
binary_weights = calculate_binary_flow_weights (image1 , re_image1 , args .thr_value , args .thr_type )
113
108
flow = flow * binary_weights [:,:,None ]
114
- if args .raw :
115
- np .save (flow_folder_reverse / imfile1 .with_suffix ('.npy' ).name , flow )
116
- else :
117
- dx , dy = quantize_flow (flow , max_val = MAX_FLOW_VAL , norm = False )
118
- flow = np .stack ([dx , dy , np .zeros (dx .shape )], axis = - 1 )
119
- cv2 .imwrite ((flow_folder_reverse / imfile1 .name ).as_posix (), flow [:, :, [2 , 1 , 0 ]])
109
+ np .save (flow_folder_reverse / imfile1 .with_suffix ('.npy' ).name , flow )
120
110
121
111
if __name__ == '__main__' :
122
112
parser = argparse .ArgumentParser ()
123
113
parser .add_argument ('--model' , help = "restore checkpoint" , default = 'ARFlow/checkpoints/CityScapes/pwclite_ar.tar' )
124
114
parser .add_argument ('--dataset' , help = "dataset for flow estimation" )
125
115
parser .add_argument ('--step' , type = int , default = 1 , help = "flow step size" )
126
116
parser .add_argument ('--test-shape' , default = [384 , 640 ], type = int , nargs = 2 )
127
- parser .add_argument ('--raw' , action = 'store_true' , help = 'generate raw optical flow' )
128
117
parser .add_argument ('--thr_type' , type = str , default = 'percentile' )
129
118
parser .add_argument ('--thr_value' , type = int , default = 90 )
130
119
args = parser .parse_args ()
0 commit comments