nielsr HF staff commited on
Commit
13a2fa6
1 Parent(s): 3ea11d5

Add truncation for inputs that are too long

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -52,7 +52,7 @@ def process_image(image):
52
  words, boxes = encoding_feature_extractor.words, encoding_feature_extractor.boxes
53
 
54
  # encode
55
- encoding = tokenizer(words, boxes=boxes, return_offsets_mapping=True, return_tensors="pt")
56
  offset_mapping = encoding.pop('offset_mapping')
57
  encoding["image"] = encoding_feature_extractor.pixel_values
58
 
 
52
  words, boxes = encoding_feature_extractor.words, encoding_feature_extractor.boxes
53
 
54
  # encode
55
+ encoding = tokenizer(words, boxes=boxes, truncation=True, return_offsets_mapping=True, return_tensors="pt")
56
  offset_mapping = encoding.pop('offset_mapping')
57
  encoding["image"] = encoding_feature_extractor.pixel_values
58