MCPcopy
hub / github.com/jindongwang/transferlearning / get_image_features

Method get_image_features

code/clip/clip_model.py:48–53  ·  view source on GitHub ↗
(self, image, need_preprocess=False)

Source from the content-addressed store, hash-verified

46 return name
47
48 def get_image_features(self, image, need_preprocess=False):
49 if need_preprocess:
50 image = self.preprocess(image).unsqueeze(0).to(self.device)
51 with torch.no_grad():
52 image_features = self.model.encode_image(image)
53 return image_features
54
55 def get_text_feature(self, text):
56 text = clip.tokenize(text).to(self.device)

Callers 2

feature_extractionMethod · 0.95
evaluateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected