Views
No views yet
1from transformers import AutoModelForVision2Seq
2import torch
3from peft import PeftModel
4
5MODEL_NAME = 'Qwen/Qwen3-VL-2B-Instruct'
6ADAPTER_PATH = 'path/to/downloaded/adapter/model'
7
8base_model = AutoModelForVision2Seq.from_pretrained(
9 MODEL_NAME,
10 dtype="auto",
11 device_map="auto",
12 trust_remote_code=True
13)
14
15# Load adapter configuration and model
16model = PeftModel.from_pretrained(base_model, ADAPTER_PATH)
17
18# Optional: Merge adapter weights for faster inference
19merged_model = model.merge_and_unload()
20
21merged_model.save_pretrained("path/to/merged/model")
22
23print("saved the merged model.")
241from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
2import torch
3
4inference_model = "path/to/fine-tuned/model"
5
6# Load the model on the available device(s)
7model = Qwen3VLForConditionalGeneration.from_pretrained(
8 inference_model, dtype="auto", device_map="auto"
9)
10
11processor = AutoProcessor.from_pretrained("Qwen/Qwen3-VL-2B-Instruct")
12
13messages = [
14 {
15 "role": "user",
16 "content": [
17 {
18 "type": "image",
19 "image": "path/to/image.png",
20 },
21 {"type": "text", "text": "What is this map about?"},
22 ],
23 }
24]
25
26# Preparation for inference
27inputs = processor.apply_chat_template(
28 messages,
29 tokenize=True,
30 add_generation_prompt=True,
31 return_dict=True,
32 return_tensors="pt"
33)
34inputs = inputs.to(model.device)
35
36# Inference: Generation of the output
37generated_ids = model.generate(**inputs, max_new_tokens=128)
38generated_ids_trimmed = [
39 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
40]
41output_text = processor.batch_decode(
42 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
43)
44print(output_text)
451@inproceedings{visqam_geoai2026,
2 author = {Koukouraki, Eftychia and Ajay, Ajay and Abubakar, Ahmad and Eid, Yomna},
3 title = {Introducing the VISQAM Dataset: Toward Automated Map Interpretation},
4 booktitle = {Proceedings of the 1st International Conference on Geospatial Artificial Intelligence (GeoAI 2026) – Oral Presentation Papers},
5 year = 2026,
6 publisher = {Zenodo},
7 address = {Ghent, Belgium},
8 doi = {10.5281/zenodo.20273245},
9 url = {https://doi.org/10.5281/zenodo.20273245},
10}