Update README.md
Browse files
README.md
CHANGED
|
@@ -51,24 +51,6 @@ model.push_to_hub("USERNAME/MODEL_NAME")
|
|
| 51 |
processor.push_to_hub("USERNAME/MODEL_NAME")
|
| 52 |
```
|
| 53 |
|
| 54 |
-
## Run a prediction
|
| 55 |
-
|
| 56 |
-
You can run a prediction by querying an input image together with a question as follows:
|
| 57 |
-
```python
|
| 58 |
-
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
|
| 59 |
-
import requests
|
| 60 |
-
from PIL import Image
|
| 61 |
-
|
| 62 |
-
model = Pix2StructForConditionalGeneration.from_pretrained('google/matcha-chartqa')
|
| 63 |
-
processor = Pix2StructProcessor.from_pretrained('google/matcha-chartqa')
|
| 64 |
-
url = "https://raw.githubusercontent.com/vis-nlp/ChartQA/main/ChartQA%20Dataset/val/png/5090.png"
|
| 65 |
-
image = Image.open(requests.get(url, stream=True).raw)
|
| 66 |
-
|
| 67 |
-
inputs = processor(images=image, text="Generate underlying data table of the figure below:", return_tensors="pt")
|
| 68 |
-
predictions = model.generate(**inputs, max_new_tokens=512)
|
| 69 |
-
print(processor.decode(predictions[0], skip_special_tokens=True))
|
| 70 |
-
```
|
| 71 |
-
|
| 72 |
# Contribution
|
| 73 |
|
| 74 |
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 |
# 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).
|