Update README.md
Browse files
README.md
CHANGED
@@ -51,6 +51,26 @@ model.push_to_hub("USERNAME/MODEL_NAME")
|
|
51 |
processor.push_to_hub("USERNAME/MODEL_NAME")
|
52 |
```
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
# Contribution
|
55 |
|
56 |
This model was originally contributed by Fangyu Liu, Francesco Piccinno et al. and added to the Hugging Face ecosystem by [Younes Belkada](https://huggingface.co/ybelkada).
|
|
|
51 |
processor.push_to_hub("USERNAME/MODEL_NAME")
|
52 |
```
|
53 |
|
54 |
+
## Get predictions from the model
|
55 |
+
|
56 |
+
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.
|
57 |
+
|
58 |
+
```python
|
59 |
+
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
|
60 |
+
import requests
|
61 |
+
from PIL import Image
|
62 |
+
|
63 |
+
model = Pix2StructForConditionalGeneration.from_pretrained('ybelkada/matcha-chartqa').to(0)
|
64 |
+
processor = Pix2StructProcessor.from_pretrained('ybelkada/matcha-chartqa')
|
65 |
+
url = "https://raw.githubusercontent.com/vis-nlp/ChartQA/main/ChartQA%20Dataset/val/png/20294671002019.png"
|
66 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
67 |
+
|
68 |
+
inputs = processor(images=image, text="Is the sum of all 4 places greater than Laos?", return_tensors="pt").to(0)
|
69 |
+
predictions = model.generate(**inputs, max_new_tokens=512)
|
70 |
+
print(processor.decode(predictions[0], skip_special_tokens=True))
|
71 |
+
>>> No
|
72 |
+
```
|
73 |
+
|
74 |
# Contribution
|
75 |
|
76 |
This model was originally contributed by Fangyu Liu, Francesco Piccinno et al. and added to the Hugging Face ecosystem by [Younes Belkada](https://huggingface.co/ybelkada).
|