MCPcopy Create free account
hub / github.com/adobe-research/custom-diffusion / extract_all_captions

Function extract_all_captions

customconcept101/evaluate.py:92–102  ·  view source on GitHub ↗
(captions, model, device, batch_size=256, num_workers=8, append=False)

Source from the content-addressed store, hash-verified

90
91
92def extract_all_captions(captions, model, device, batch_size=256, num_workers=8, append=False):
93 data = torch.utils.data.DataLoader(
94 CLIPCapDataset(captions, append=append),
95 batch_size=batch_size, num_workers=num_workers, shuffle=False)
96 all_text_features = []
97 with torch.no_grad():
98 for b in tqdm(data):
99 b = b['caption'].to(device)
100 all_text_features.append(model.encode_text(b).cpu().numpy())
101 all_text_features = np.vstack(all_text_features)
102 return all_text_features
103
104
105def extract_all_images(images, model, datasetclass, device, batch_size=64, num_workers=8):

Callers 1

get_clip_scoreFunction · 0.85

Calls 1

CLIPCapDatasetClass · 0.85

Tested by

no test coverage detected