ybelkada commited on
Commit
de51b30
·
1 Parent(s): 4fa4a67

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -2
README.md CHANGED
@@ -60,17 +60,19 @@ 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).
 
60
  import requests
61
  from PIL import Image
62
 
63
+ model = Pix2StructForConditionalGeneration.from_pretrained('ybelkada/matcha-chartqa')
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")
69
  predictions = model.generate(**inputs, max_new_tokens=512)
70
  print(processor.decode(predictions[0], skip_special_tokens=True))
71
  >>> No
72
  ```
73
 
74
+ To run the predictions on GPU, simply add `.to(0)` when creating the model and when getting the inputs (`inputs = inputs.to(0)`)
75
+
76
  # Contribution
77
 
78
  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).