Instructions to use google/deplot with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/deplot with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("visual-question-answering", model="google/deplot")# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("google/deplot") model = AutoModelForImageTextToText.from_pretrained("google/deplot") - Notebooks
- Google Colab
- Kaggle
how to use cuda
#17
by susht - opened
how to add cuda?
model_path = "google/deplot"
processor = Pix2StructProcessor.from_pretrained(model_path)
model = Pix2StructForConditionalGeneration.from_pretrained(model_path)
image = Image.open(image_path).convert("RGB")
inputs = processor(images=image, text="Generate underlying data table of the figure below:", return_tensors="pt")
predictions = model.generate(**inputs, max_new_tokens=512)
res = processor.decode(predictions[0], skip_special_tokens=True)
I can move the model to GPU model.to(device) but it still complains about another tensor...
Working now:
model = Pix2StructForConditionalGeneration.from_pretrained('google/deplot').to(device)
....
inputs.to(device)