Skip to content

Commit 1c03b40

Browse files
author
Clément Pinard
committed
let user choose upsampling algorithm
1 parent c6a079c commit 1c03b40

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

run_inference.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
parser.add_argument("--img-exts", default=['png', 'jpg', 'bmp'], nargs='*', type=str, help="images extensions to glob")
2929
parser.add_argument('--max_flow', default=None, type=float,
3030
help='max flow value. Flow map color is saturated above this value. If not set, will use flow map\'s max value')
31-
parser.add_argument('--no-resize', action='store_true', help='if set, will output FlowNet raw input, which is 4 times downsampled.'
32-
'if not set, will output full resolution flow map, with bilinear upsampling')
31+
parser.add_argument('--upsampling', '-u', choices=['nearest', 'bilinear'], default=None, help='if not set, will output FlowNet raw input,'
32+
'which is 4 times downsampled. If set, will output full resolution flow map, with selected upsampling')
3333
parser.add_argument('--bidirectional', action='store_true', help='if set, will output invert flow (from 1 to 0) along with regular flow')
3434

3535

@@ -81,8 +81,8 @@ def main():
8181

8282
# compute output
8383
output = model(input_var)
84-
if not args.no_resize:
85-
output = torch.nn.functional.upsample(output, size=img1.size()[-2:], mode='bilinear')
84+
if args.upsampling is not None:
85+
output = torch.nn.functional.upsample(output, size=img1.size()[-2:], mode=args.upsampling)
8686
for suffix, flow_output in zip(['flow', 'inv_flow'], output.data.cpu()):
8787
rgb_flow = flow2rgb(args.div_flow * flow_output.numpy(), max_value=args.max_flow)
8888
to_save = (rgb_flow * 255).astype(np.uint8)

0 commit comments

Comments
 (0)