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