File size: 3,562 Bytes
4dd1c2a
 
 
b80b8a9
b05e876
 
 
e98e399
b05e876
 
 
 
 
 
d555e36
 
b05e876
 
 
 
c3e0c2e
b05e876
d555e36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b05e876
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
license: apache-2.0
datasets:
- jonathan-roberts1/RSI-CB256
language:
- en
base_model:
- google/siglip2-base-patch16-224
pipeline_tag: image-classification
library_name: transformers
tags:
- Remote Sensing Instruments
- RSI
- Location
---

![4.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/6wc37VzmAH_l6nJ2YmV_D.png)

# **RSI-CB256-07**

> **RSI-CB256-07** is a SigLIP2-based model fine-tuned for **coarse-grained remote sensing land-cover classification**. It distinguishes among 7 essential categories commonly used in environmental, urban planning, and geospatial analysis applications. The model is built on `google/siglip2-base-patch16-224 ` using the `SiglipForImageClassification` architecture.

```py
Classification Report:
                   precision    recall  f1-score   support

   transportation     0.9810    0.9858    0.9834      3300
    other objects     0.9854    0.9932    0.9893       884
         woodland     0.9973    0.9958    0.9966      6258
       water area     0.9870    0.9837    0.9854      4104
       other land     0.9925    0.9919    0.9922      3593
  cultivated land     0.9918    0.9901    0.9909      2817
construction land     0.9945    0.9963    0.9954      3791

         accuracy                         0.9912     24747
        macro avg     0.9899    0.9910    0.9904     24747
     weighted avg     0.9912    0.9912    0.9912     24747
```

![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/TK92T1T135eFWucPmTGqw.png)

---

## **Label Space: 7 Remote Sensing Classes**

This model predicts one of the following categories for a given satellite or aerial image:

```
Class 0:  "transportation"  
Class 1:  "other objects"  
Class 2:  "woodland"  
Class 3:  "water area"  
Class 4:  "other land"  
Class 5:  "cultivated land"  
Class 6:  "construction land"
```

---

## **Install Dependencies**

```bash
pip install -q transformers torch pillow gradio
```

---

## **Inference Code**

```python
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch

# Load model and processor
model_name = "prithivMLmods/RSI-CB256-07"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)

# ID to label mapping
id2label = {
    "0": "transportation",
    "1": "other objects",
    "2": "woodland",
    "3": "water area",
    "4": "other land",
    "5": "cultivated land",
    "6": "construction land"
}

def classify_rsi_image(image):
    image = Image.fromarray(image).convert("RGB")
    inputs = processor(images=image, return_tensors="pt")

    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()

    prediction = {
        id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
    }

    return prediction

# Gradio Interface
iface = gr.Interface(
    fn=classify_rsi_image,
    inputs=gr.Image(type="numpy"),
    outputs=gr.Label(num_top_classes=7, label="Predicted Land-Cover Category"),
    title="RSI-CB256-07",
    description="Upload a satellite or aerial image to classify it into one of seven coarse land-cover classes using SigLIP2."
)

if __name__ == "__main__":
    iface.launch()
```

---

## **Applications**

* **Urban vs Rural Segmentation**
* **Land-Use Classification**
* **National/Regional Land Cover Monitoring**
* **Environmental Impact Assessment**