import requests import torch from PIL import Image from io import BytesIO from transformers import AutoProcessor, AutoModelForVision2Seq from transformers.image_utils import load_image DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu") image1 = load_image( "https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_960_720.jpg" ) processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics2-8b") model = AutoModelForVision2Seq.from_pretrained("HuggingFaceM4/idefics2-8b").to(DEVICE)