ragavsachdeva
commited on
Commit
•
fb1caa5
1
Parent(s):
b071df7
Update modelling_magiv2.py
Browse files- modelling_magiv2.py +2 -2
modelling_magiv2.py
CHANGED
@@ -413,7 +413,7 @@ class Magiv2Model(PreTrainedModel):
|
|
413 |
|
414 |
return crop_embeddings_for_batch
|
415 |
|
416 |
-
def predict_ocr(self, images, crop_bboxes, move_to_device_fn=None, use_tqdm=False, batch_size=32):
|
417 |
assert not self.config.disable_ocr
|
418 |
move_to_device_fn = self.move_to_device if move_to_device_fn is None else move_to_device_fn
|
419 |
|
@@ -439,7 +439,7 @@ class Magiv2Model(PreTrainedModel):
|
|
439 |
pbar = range(0, len(crops_per_image), batch_size)
|
440 |
for i in pbar:
|
441 |
crops = crops_per_image[i:i+batch_size]
|
442 |
-
generated_ids = self.ocr_model.generate(crops)
|
443 |
generated_texts = self.processor.postprocess_ocr_tokens(generated_ids)
|
444 |
all_generated_texts.extend(generated_texts)
|
445 |
|
|
|
413 |
|
414 |
return crop_embeddings_for_batch
|
415 |
|
416 |
+
def predict_ocr(self, images, crop_bboxes, move_to_device_fn=None, use_tqdm=False, batch_size=32, max_new_tokens=512):
|
417 |
assert not self.config.disable_ocr
|
418 |
move_to_device_fn = self.move_to_device if move_to_device_fn is None else move_to_device_fn
|
419 |
|
|
|
439 |
pbar = range(0, len(crops_per_image), batch_size)
|
440 |
for i in pbar:
|
441 |
crops = crops_per_image[i:i+batch_size]
|
442 |
+
generated_ids = self.ocr_model.generate(crops, max_new_tokens=max_new_tokens)
|
443 |
generated_texts = self.processor.postprocess_ocr_tokens(generated_ids)
|
444 |
all_generated_texts.extend(generated_texts)
|
445 |
|