Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ppaanngggg committed Mar 4, 2024
1 parent 40f3bde commit 53a6e2f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,22 @@ The original [LayoutReader](https://github.com/microsoft/unilm/tree/master/layou

```python
from transformers import LayoutLMv3ForTokenClassification
from v3.helpers import prepare_inputs, boxes2inputs, parse_logits

model = LayoutLMv3ForTokenClassification.from_pretrained("hantian/layoutreader")
# TODO

boxes = [[...], ...] # list of [left, top, right, bottom], bboxes of spans
inputs = boxes2inputs(boxes)
inputs = prepare_inputs(inputs, model)
logits = model(**inputs).logits.cpu().squeeze(0)
orders = parse_logits(logits, len(boxes))
print(orders)

# [0, 1, 2, ...]
```

Or you can `python main.py` to serve the model.

## Dataset

### Download Original Dataset
Expand Down

0 comments on commit 53a6e2f

Please sign in to comment.