Views
No views yet
1from transformers import AutoImageProcessor, AutoModel
2from PIL import Image
3import requests
4
5image_processor = AutoImageProcessor.from_pretrained("deepang/adaptformer-LEVIR-CD")
6model = AutoModel.from_pretrained("deepang/adaptformer-LEVIR-CD")
7
8image_A = Image.open(requests.get('https://raw.githubusercontent.com/aigzhusmart/AdaptFormer/main/figures/test_2_1_A.png', stream=True).raw)
9image_B = Image.open(requests.get('https://raw.githubusercontent.com/aigzhusmart/AdaptFormer/main/figures/test_2_1_B.png', stream=True).raw)
10label = Image.open(requests.get('https://raw.githubusercontent.com/aigzhusmart/AdaptFormer/main/figures/test_2_1_label.png', stream=True).raw)
11
12
13inputs = preprocessor(images=(image_A, image_B), return_tensors="pt")
14outputs = adaptfromer_model(**inputs)
15logits = outputs.logits # shape (batch_size, num_labels, height, width)
16pred = logits.argmax(dim=1)[0]1@article{huang2024adaptformer,
2 title={AdaptFormer: An Adaptive Hierarchical Semantic Approach for Change Detection on Remote Sensing Images},
3 author={Huang, Teng and Hong, Yile and Pang, Yan and Liang, Jiaming and Hong, Jie and Huang, Lin and Zhang, Yuan and Jia, Yan and Savi, Patrizia},
4 journal={IEEE Transactions on Instrumentation and Measurement},
5 year={2024},
6 publisher={IEEE}
7}