MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / extract_feature

Function extract_feature

eval_video_segmentation.py:153–163  ·  view source on GitHub ↗

Extract one frame feature everytime.

(model, frame, return_h_w=False)

Source from the content-addressed store, hash-verified

151
152
153def extract_feature(model, frame, return_h_w=False):
154 """Extract one frame feature everytime."""
155 out = model.get_intermediate_layers(frame.unsqueeze(0).cuda(), n=1)[0]
156 # out = out[:, 1:, :] # we discard the [CLS] token
157 h, w = int(frame.shape[1] / model.patch_embed.patch_size), int(frame.shape[2] / model.patch_embed.patch_size)
158 dim = out.shape[-1]
159 out = out[0].reshape(h, w, dim)
160 out = out.reshape(-1, dim)
161 if return_h_w:
162 return out, h, w
163 return out
164
165
166def imwrite_indexed(filename, array, color_palette):

Callers 2

label_propagationFunction · 0.85

Calls 1

Tested by

no test coverage detected