MCPcopy Create free account
hub / github.com/ImprintLab/Medical-SAM2 / __getitem__

Method __getitem__

sam2_train/utils/misc.py:138–157  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

136 self.thread.start()
137
138 def __getitem__(self, index):
139 if self.exception is not None:
140 raise RuntimeError("Failure in frame loading thread") from self.exception
141
142 img = self.images[index]
143 if img is not None:
144 return img
145
146 img, video_height, video_width = _load_img_as_tensor(
147 self.img_paths[index], self.image_size
148 )
149 self.video_height = video_height
150 self.video_width = video_width
151 # normalize by mean and std
152 img -= self.img_mean
153 img /= self.img_std
154 if not self.offload_video_to_cpu:
155 img = img.cuda(non_blocking=True)
156 self.images[index] = img
157 return img
158
159 def __len__(self):
160 return len(self.images)

Callers 2

__init__Method · 0.95
_load_framesMethod · 0.95

Calls 1

_load_img_as_tensorFunction · 0.85

Tested by

no test coverage detected