netdef_models
netdef_models copied to clipboard
Controller eval code wrong in readme (part 2)
out = c.net_actions.eval(img0, img1)
returns:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: eval() missing 1 required positional argument: 'image_1'
(using tried with img0 and img1 as path to the image and as numpy array)
The problem is coming from the fact that self.net_actions=NetAction class is not initialized correctly. So, to solve this issue change the eval code like this:
import netdef_slim as nd
img0 = 'path to image 0 path'
img1 = 'path to image 1 path'
c_model = nd.load_module(path='full path to controller.py, avoid the relational path')
c = c_model.Controller()
c_net = c.net_actions(net_dir=c.base_path)
out = c_net.eval(img0, img1)
out_flow = out['flow[0].fwd'][0]
# You can use flowlib.py/flow_to_image() from FlowNet2 or other packages to visualize the results.
# Don't forget to do the dimension correction. Curent dimension are [2,w,h] and 2 for (u,v) pairs
# out is an OrderedDict with the following structure
#OrderedDict(['flow[0].fwd', np.array[...],
'occ[0].fwd', np.array[...],
'occ_soft[0].fwd', np.array[...],
'mb[0].fwd', np.array[...],
'mb_soft[0].fwd', np.array[...],
])