nielsr HF staff commited on
Commit
6e37eb9
1 Parent(s): 5227407

Update funsd-layoutlmv3.py

Browse files
Files changed (1) hide show
  1. funsd-layoutlmv3.py +12 -2
funsd-layoutlmv3.py CHANGED
@@ -7,8 +7,18 @@ import os
7
 
8
  import datasets
9
 
10
- from layoutlmft.data.image_utils import load_image, normalize_bbox
11
-
 
 
 
 
 
 
 
 
 
 
12
 
13
  logger = datasets.logging.get_logger(__name__)
14
 
 
7
 
8
  import datasets
9
 
10
+ def load_image(image_path):
11
+ image = Image.open(image_path).convert("RGB")
12
+ w, h = image.size
13
+ return image, (w, h)
14
+
15
+ def normalize_bbox(bbox, size):
16
+ return [
17
+ int(1000 * bbox[0] / size[0]),
18
+ int(1000 * bbox[1] / size[1]),
19
+ int(1000 * bbox[2] / size[0]),
20
+ int(1000 * bbox[3] / size[1]),
21
+ ]
22
 
23
  logger = datasets.logging.get_logger(__name__)
24