hi i tried codes for extracting optical flow from images frames(stored in google drive) using pwc-net algorithm in google colab as below:
from mmcv.utils import config
# Copyright (c) OpenMMLab. All rights reserved.
!pip install mmcv-full
!pip install mmflow
import os.path as osp
from argparse import ArgumentParser
import mmcv
# use the pre-trained model for the whole PWC-Net
load_from = 'https://download.openmmlab.com/mmflow/pwcnet/pwcnet_8x1_sfine_flyingthings3d_subset_384x768.pth' # model path can be found in model zoo
from mmflow.apis import inference_model, init_model
from mmflow.datasets import visualize_flow, write_flow
parser = ArgumentParser()
img1='/content/drive/My Drive/resizedImages_river/frame1.jpg'
img2='/content/drive/My Drive/resizedImages_river/frame2.jpg'
config='configs/pwcnet/pwcnet_8x1_slong_flyingchairs_384x448.py'
checkpoint='checkpoints/pwcnet_8x1_slong_flyingchairs_384x448.pth'
parser.add_argument('img1', help='Image1 file')
parser.add_argument('img2', help='Image2 file')
parser.add_argument('--valid',help='Valid file. If the predicted flow is''sparse, valid mask will filter the output flow map.')
parser.add_argument('config', help='Config file')
parser.add_argument('checkpoint', help='Checkpoint file')
parser.add_argument('flow_map', help='Path of directory to save flow map and flow file')
parser.add_argument('--out_prefix',help='The prefix for the output results ''including flow file and visualized flow map',default='flow')
parser.add_argument('--device', default='cuda:0', help='Device used for inference')
args = parser.parse_args()
return args
def main(args):
# build the model from a config file and a checkpoint file
model = init_model(args.config, args.checkpoint, device=args.device)
# test a single image
result = inference_model(model, args.img1, args.img2)
result = inference_model(model, args.img1, args.img2, valids=args.valid)
# save the results
mmcv.mkdir_or_exist(args.flow_map)
visualize_flow(result, osp.join(args.flow_map, f'{args.out_prefix}.jpg'))
but google colab shows error message as below:
colab_kernel_launcher.py: error: the following arguments are required: img1, img2, config, checkpoint, flow_map An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
i searched google for fix this error, but i did not find any solution.I appreciate any help
If you don't want to run this from a command line, then just fake it by supplying all the arguments in an object.