MCPcopy Create free account
hub / github.com/Adamdad/hash3D / encode_text

Method encode_text

eval_clip_sim.py:25–29  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

23 return image_features
24
25 def encode_text(self, text):
26 inputs = self.processor(text=[text], padding=True, return_tensors="pt").to(self.device)
27 text_features = self.clip_model.get_text_features(**inputs)
28 text_features = text_features / text_features.norm(dim=-1, keepdim=True) # normalize features
29 return text_features
30
31def sample_images(folder, num_images):
32 all_images = [f for f in os.listdir(folder) if f.lower().endswith(('.png', '.jpg', '.jpeg'))]

Callers 1

eval_clip_sim.pyFile · 0.45

Calls 1

toMethod · 0.45

Tested by

no test coverage detected