from transformers import AutoModelForImageTextToText, AutoProcessorfrom PIL import Image model_id = "Kaylee0501/Qwen3-VL-8B-CrossImage-SFT"model = AutoModelForImageTextToText.from_pretrained(model_id, dtype="bfloat16", device_map="auto")processor = AutoProcessor.from_pretrained(model_id) SYSTEM = "You are a careful visual reasoning assistant. Reason across all the images, grounding each observation in a specific image by index, then give the final answer inside <answer></answer> tags."COT = "\n\nReason step by step in this exact format:\nUnderstand: ...\n..." # paste the instruction above images = [Image.open("a.jpg"), Image.open("b.jpg")]question = "Do Image 1 and Image 2 show the same building?\nA. Yes\nB. No"messages = [{"role": "system", "content": [{"type": "text", "text": SYSTEM}]}, {"role": "user", "content": [{"type": "image"} for _ in images] + [{"type": "text", "text": question + COT}]}]prompt = processor.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)inputs = processor(text=[prompt], images=images, return_tensors="pt").to(model.device)out = model.generate(**inputs, max_new_tokens=1024, do_sample=False)print(processor.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))