def vocabulary_size(self):
return len(self.token2id)
- def generate(self, descr_primer, model, nb_tokens):
+ def generate(self, primer_descr, model, nb_tokens):
results = autoregression(
model, self.batch_size,
- 1, nb_tokens, primer = descr2tensor(descr_primer),
+ 1, nb_tokens, primer = descr2tensor(primer_descr),
device = self.device
)
return ' '.join([ self.id2token[t.item()] for t in results.flatten() ])
result_descr = [ ]
nb_per_primer = 8
- for descr_primer in [
+ for primer_descr in [
'red above green <sep> green top <sep> blue right of red <img>',
'there is red <sep> there is yellow <sep> there is blue <img>',
'red below yellow <sep> yellow below green <sep> green below blue <sep> red right <sep> yellow left <sep> green right <sep> blue left <img>',
]:
for k in range(nb_per_primer):
- result_descr.append(self.generate(descr_primer, model, nb_tokens))
+ result_descr.append(self.generate(primer_descr, model, nb_tokens))
img = [ picoclvr.descr2img(d, height = self.height, width = self.width)
for d in result_descr ]