in build_graph/build.py [0:0]
def __init__(self, args):
self.args = args
if args.dset=='epic':
self.dset = epic.EPICInteractions('data/epic', 'val', 32)
self.dset.fps = 60
self.start_frame = 1
self.end_frame = self.dset.annotations['vid_lengths'][args.v_id]
elif args.dset=='gtea':
self.dset = gtea.GTEAInteractions('data/gtea', 'val', 32)
self.dset.fps = 24
# a lot of GTEA are blank
video_bounds = json.load(open('data/gtea/video_start_end.json'))
self.start_frame, self.end_frame = video_bounds[args.v_id]
self.dset.transform = util.default_transform('val')
# subsample frames to 6fps for graph generation
vid_length = self.dset.annotations['vid_lengths'][args.v_id]
subsample = self.dset.fps//6
self.frames = [(args.v_id, f_id) for f_id in range(1, vid_length+1, subsample)]
self.frame_to_idx = {frame: idx for idx, frame in enumerate(self.frames)}
print (f'Generating graph for {args.dset}-{args.v_id}. {len(self.frames)} frames')
#-------------------------------------------------------------------------------------#
'''
Set up the graph:
- leaders: the graph node that each frame belongs to
- pos: the graph layout for visualization
- last state: used to decide edges etc.
- G: the nx Graph. Each node has a bunch of attributes:
- visitation: a dict with start/end times of a visit to that node
- img: the node thumbnail (most recent visitation)
'''
self.G = nx.Graph()
self.G.pos = None
self.state = {'frame':None, 'node':None, 'inactive':True, 'viz_node':self.start_frame, 'last_node':self.start_frame, 'phase':'localize'}
self.create_new_node(self.G, self.start_frame, [{'start':self.start_frame, 'stop':self.start_frame}]) # temporary node until initialized
#-------------------------------------------------------------------------------------#
# number of frames after which the edge will be declared far
# edge will still be made, but with attr color='grey' as opposed to 'black'
self.edge_delay = 20
self.thresh_upper = 0.7
self.thresh_lower = 0.4
# Only recognize a node if there are N consecutive localizations there
self.window_size = 9
self.reset_buffer()
self.history = []