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

Class CLIPCapDataset

customconcept101/evaluate.py:19–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19class CLIPCapDataset(torch.utils.data.Dataset):
20 def __init__(self, data, append=False, prefix='A photo depicts'):
21 self.data = data
22 self.prefix = ''
23 if append:
24 self.prefix = prefix
25 if self.prefix[-1] != ' ':
26 self.prefix += ' '
27
28 def __getitem__(self, idx):
29 c_data = self.data[idx]
30 c_data = clip.tokenize(self.prefix + c_data, truncate=True).squeeze()
31 return {'caption': c_data}
32
33 def __len__(self):
34 return len(self.data)
35
36
37def Convert(image):

Callers 1

extract_all_captionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected