Update README.md
Browse files
README.md
CHANGED
@@ -8,6 +8,8 @@ language:
|
|
8 |
inference: false
|
9 |
pipeline_tag: visual-question-answering
|
10 |
license: apache-2.0
|
|
|
|
|
11 |
---
|
12 |
# Model card for MatCha - fine-tuned on PlotQA-v2 dataset
|
13 |
|
@@ -30,7 +32,26 @@ The abstract of the paper states that:
|
|
30 |
|
31 |
# Using the model
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
You can use the [`convert_pix2struct_checkpoint_to_pytorch.py`](https://github.com/huggingface/transformers/blob/main/src/transformers/models/pix2struct/convert_pix2struct_original_pytorch_to_hf.py) script as follows:
|
36 |
```bash
|
|
|
8 |
inference: false
|
9 |
pipeline_tag: visual-question-answering
|
10 |
license: apache-2.0
|
11 |
+
tags:
|
12 |
+
- matcha
|
13 |
---
|
14 |
# Model card for MatCha - fine-tuned on PlotQA-v2 dataset
|
15 |
|
|
|
32 |
|
33 |
# Using the model
|
34 |
|
35 |
+
You should ask specific questions to the model in order to get consistent generations. Here we are asking the model whether the sum of values that are in a chart are greater than the largest value.
|
36 |
+
|
37 |
+
```python
|
38 |
+
from transformers import Pix2StructProcessor, Pix2StructForConditionalGeneration
|
39 |
+
import requests
|
40 |
+
from PIL import Image
|
41 |
+
|
42 |
+
processor = Pix2StructProcessor.from_pretrained('google/matcha-plotqa-v2')
|
43 |
+
model = Pix2StructForConditionalGeneration.from_pretrained('google/matcha-plotqa-v2')
|
44 |
+
|
45 |
+
url = "https://raw.githubusercontent.com/vis-nlp/ChartQA/main/ChartQA%20Dataset/val/png/20294671002019.png"
|
46 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
47 |
+
|
48 |
+
inputs = processor(images=image, text="Is the sum of all 4 places greater than Laos?", return_tensors="pt")
|
49 |
+
predictions = model.generate(**inputs, max_new_tokens=512)
|
50 |
+
print(processor.decode(predictions[0], skip_special_tokens=True))
|
51 |
+
>>> No
|
52 |
+
```
|
53 |
+
|
54 |
+
# Converting from T5x to huggingface
|
55 |
|
56 |
You can use the [`convert_pix2struct_checkpoint_to_pytorch.py`](https://github.com/huggingface/transformers/blob/main/src/transformers/models/pix2struct/convert_pix2struct_original_pytorch_to_hf.py) script as follows:
|
57 |
```bash
|