JustinLin610
commited on
Commit
•
90e0293
1
Parent(s):
335e715
Update README.md
Browse filesreformat code of generator
README.md
CHANGED
@@ -43,8 +43,13 @@ After, refer the path to OFA-tiny to `ckpt_dir`, and prepare an image for the te
|
|
43 |
|
44 |
>>> # using the generator of fairseq version
|
45 |
>>> model = OFAModel.from_pretrained(ckpt_dir, use_cache=True)
|
46 |
-
>>> generator = sequence_generator.SequenceGenerator(
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
48 |
>>> data = {}
|
49 |
>>> data["net_input"] = {"input_ids": inputs, 'patch_images': patch_img, 'patch_masks':torch.tensor([True])}
|
50 |
>>> gen_output = generator.generate([model], data)
|
|
|
43 |
|
44 |
>>> # using the generator of fairseq version
|
45 |
>>> model = OFAModel.from_pretrained(ckpt_dir, use_cache=True)
|
46 |
+
>>> generator = sequence_generator.SequenceGenerator(
|
47 |
+
tokenizer=tokenizer,
|
48 |
+
beam_size=5,
|
49 |
+
max_len_b=16,
|
50 |
+
min_len=0,
|
51 |
+
no_repeat_ngram_size=3,
|
52 |
+
)
|
53 |
>>> data = {}
|
54 |
>>> data["net_input"] = {"input_ids": inputs, 'patch_images': patch_img, 'patch_masks':torch.tensor([True])}
|
55 |
>>> gen_output = generator.generate([model], data)
|