Update README.md
Browse files
README.md
CHANGED
|
@@ -26,12 +26,6 @@ layout = [[381, 91, 505, 115], [738, 96, 804, 122]]
|
|
| 26 |
# intialize feature extractor
|
| 27 |
feature_extractor = ErnieFeatureExtractor()
|
| 28 |
|
| 29 |
-
# open the image of the document
|
| 30 |
-
pil_image = Image.open("/path/to/image").convert("RGB")
|
| 31 |
-
|
| 32 |
-
# Process image
|
| 33 |
-
tokenized_res['pixel_values'] = feature_extractor(pil_image)
|
| 34 |
-
|
| 35 |
# Tokenize context & questions
|
| 36 |
context_encodings, = prepare_context_info(tokenizer, context, layout)
|
| 37 |
question = "what is it?"
|
|
@@ -41,6 +35,13 @@ tokenized_res = ernie_qa_tokenize(tokenizer, question, context_encodings)
|
|
| 41 |
tokenized_res['start_positions'] = 6
|
| 42 |
tokenized_res['end_positions'] = 12
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# initialize config
|
| 45 |
config = ErnieLayoutConfig.from_pretrained(pretrained_model_name_or_path=pretrain_torch_model_or_path)
|
| 46 |
config.num_classes = 2 # start and end
|
|
|
|
| 26 |
# intialize feature extractor
|
| 27 |
feature_extractor = ErnieFeatureExtractor()
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Tokenize context & questions
|
| 30 |
context_encodings, = prepare_context_info(tokenizer, context, layout)
|
| 31 |
question = "what is it?"
|
|
|
|
| 35 |
tokenized_res['start_positions'] = 6
|
| 36 |
tokenized_res['end_positions'] = 12
|
| 37 |
|
| 38 |
+
# open the image of the document
|
| 39 |
+
pil_image = Image.open("/path/to/image").convert("RGB")
|
| 40 |
+
|
| 41 |
+
# Process image
|
| 42 |
+
tokenized_res['pixel_values'] = feature_extractor(pil_image)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
# initialize config
|
| 46 |
config = ErnieLayoutConfig.from_pretrained(pretrained_model_name_or_path=pretrain_torch_model_or_path)
|
| 47 |
config.num_classes = 2 # start and end
|