import torchfrom PIL import Imagefrom transformers import AutoModelForImageTextToText, AutoProcessor model_id = "inclusionAI/VISTA-4B" model = AutoModelForImageTextToText.from_pretrained( model_id, torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True,)processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True) image = Image.open("screenshot.png").convert("RGB")instruction = "Click the search button"prompt = ( "Output the center point of the position corresponding to the instruction: " f"{instruction}. The output should just be the coordinates of a point, " "in the format [x,y].") messages = [ { "role": "user", "content": [ {"type": "image", "image": image}, {"type": "text", "text": prompt}, ], }] text = processor.apply_chat_template( messages, tokenize=False, add_generation_prompt=True,)inputs = processor( text=[text], images=[image], padding=True, return_tensors="pt",).to(model.device) generated = model.generate( **inputs, max_new_tokens=32, do_sample=False,)new_tokens = generated[:, inputs.input_ids.shape[1]:]response = processor.batch_decode(new_tokens, skip_special_tokens=True)[0].strip()print(response) # e.g. [512,384]