MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / _parse_data

Method _parse_data

bindsnet/datasets/alov300.py:65–111  ·  view source on GitHub ↗

Parses ALOV dataset and builds tuples of (template, search region) tuples from consecutive annotated frames.

(self, root, target_dir)

Source from the content-addressed store, hash-verified

63 return sample
64
65 def _parse_data(self, root, target_dir):
66 """
67 Parses ALOV dataset and builds tuples of (template, search region)
68 tuples from consecutive annotated frames.
69 """
70 self.exclude = [
71 # "01-Light_video00016",
72 # "01-Light_video00022",
73 # "01-Light_video00023",
74 # "02-SurfaceCover_video00012",
75 # "03-Specularity_video00003",
76 # "03-Specularity_video00012",
77 # "10-LowContrast_video00013",
78 ]
79
80 x = []
81 y = []
82 envs = os.listdir(target_dir)
83 num_anno = 0
84 print("Parsing ALOV dataset...")
85 for env in envs:
86 env_videos = os.listdir(root + env)
87 for vid in env_videos:
88 if vid in self.exclude:
89 continue
90 vid_src = f"{self.frame_path}{env}/{vid}"
91 vid_ann = f"{self.box_path}{env}/{vid}.ann"
92 frames = os.listdir(vid_src)
93 frames.sort()
94 frames = [vid_src + "/" + frame for frame in frames]
95 f = open(vid_ann, "r")
96 annotations = f.readlines()
97 f.close()
98 frame_idxs = [int(ann.split(" ")[0]) - 1 for ann in annotations]
99 frames = np.array(frames)
100 num_anno += len(annotations)
101 for i in range(len(frame_idxs) - 1):
102 idx = frame_idxs[i]
103 next_idx = frame_idxs[i + 1]
104 x.append([frames[idx], frames[next_idx]])
105 y.append([annotations[i], annotations[i + 1]])
106 x = np.array(x)
107 y = np.array(y)
108 self.len = len(y)
109 print("ALOV dataset parsing done.")
110 print("Total number of annotations in ALOV dataset = %d" % num_anno)
111 return x, y
112
113 def get_sample(self, idx):
114 """

Callers 1

__init__Method · 0.95

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected