MCPcopy Create free account
hub / github.com/OpenMatch/UniVL-DR / load_file

Function load_file

CLIP-DPR/data.py:146–164  ·  view source on GitHub ↗
(path, txt=True, img=True)

Source from the content-addressed store, hash-verified

144
145
146def load_file(path, txt=True, img=True):
147 data = []
148 with open(path) as fin:
149 assert (txt or img)
150 for line in fin:
151 example = json.loads(line.strip())
152 txt_negFacts = example['txt_negFacts']
153 np.random.shuffle(txt_negFacts)
154 example['txt_negFacts'] = txt_negFacts
155
156 img_negFacts = example['img_negFacts']
157 np.random.shuffle(img_negFacts)
158 example['img_negFacts'] = img_negFacts
159
160 if txt and len(example['txt_posFacts']) != 0:
161 data.append(example)
162 if img and len(example['img_posFacts']) != 0:
163 data.append(example)
164 return data
165
166def load_docs(path):
167 data = {}

Callers 1

train.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected