nielsr HF staff commited on
Commit
3f270f4
1 Parent(s): 2176166

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -5
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 Chart2text-statista
13
 
@@ -30,7 +32,26 @@ The abstract of the paper states that:
30
 
31
  # Using the model
32
 
33
- ## Converting from T5x to huggingface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@@ -51,10 +72,6 @@ model.push_to_hub("USERNAME/MODEL_NAME")
51
  processor.push_to_hub("USERNAME/MODEL_NAME")
52
  ```
53
 
54
- ## Run predictions
55
-
56
- To run predictions, refer to the [instructions presented in the `matcha-chartqa` model card](https://huggingface.co/ybelkada/matcha-chartqa#get-predictions-from-the-model).
57
-
58
  # Contribution
59
 
60
  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).
 
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 Chart2text-statista
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-chart2text-statista')
43
+ model = Pix2StructForConditionalGeneration.from_pretrained('google/matcha-chart2text-statista')
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
 
72
  processor.push_to_hub("USERNAME/MODEL_NAME")
73
  ```
74
 
 
 
 
 
75
  # Contribution
76
 
77
  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).