prithivMLmods/Multilabel-GeoSceneNet
442
1---2license: apache-2.03datasets:4- prithivMLmods/Multilabel-GeoSceneNet-16K5library_name: transformers6language:7- en8base_model:9- google/siglip2-base-patch16-22410pipeline_tag: image-classification11tags:12- Structures13- Desert14- Glacier15- Street16- Ocean17- Image-Classifier18- art19- Mountain20---21 2223 24# **Multilabel-GeoSceneNet**25 26> **Multilabel-GeoSceneNet** is a vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for **multi-label** image classification. It is designed to recognize and label multiple geographic or environmental elements in a single image using the **SiglipForImageClassification** architecture.27 28```py29Classification Report:30 precision recall f1-score support31 32Buildings and Structures 0.8881 0.9498 0.9179 219033 Desert 0.9649 0.9480 0.9564 200034 Forest Area 0.9807 0.9855 0.9831 227135 Hill or Mountain 0.8616 0.8993 0.8800 251236 Ice Glacier 0.9114 0.8382 0.8732 240437 Sea or Ocean 0.9328 0.9525 0.9426 227438 Street View 0.9476 0.9106 0.9287 238239 40 accuracy 0.9245 1603341 macro avg 0.9267 0.9263 0.9260 1603342 weighted avg 0.9253 0.9245 0.9244 1603343```44 4546 47---48 49The model predicts the presence of one or more of the following **7 geographic scene categories**:50 51```52 Class 0: "Buildings and Structures"53 Class 1: "Desert"54 Class 2: "Forest Area"55 Class 3: "Hill or Mountain"56 Class 4: "Ice Glacier"57 Class 5: "Sea or Ocean"58 Class 6: "Street View"59```60 61---62 63## **Install dependencies**64 65```python66!pip install -q transformers torch pillow gradio67```68 69---70 71## **Inference Code**72 73```python74import gradio as gr75from transformers import AutoImageProcessor, SiglipForImageClassification76from PIL import Image77import torch78 79# Load model and processor80model_name = "prithivMLmods/Multilabel-GeoSceneNet" # Updated model name81model = SiglipForImageClassification.from_pretrained(model_name)82processor = AutoImageProcessor.from_pretrained(model_name)83 84def classify_geoscene_image(image):85 """Predicts geographic scene labels for an input image."""86 image = Image.fromarray(image).convert("RGB")87 inputs = processor(images=image, return_tensors="pt")88 89 with torch.no_grad():90 outputs = model(**inputs)91 logits = outputs.logits92 probs = torch.sigmoid(logits).squeeze().tolist() # Sigmoid for multilabel93 94 labels = {95 "0": "Buildings and Structures",96 "1": "Desert",97 "2": "Forest Area",98 "3": "Hill or Mountain",99 "4": "Ice Glacier",100 "5": "Sea or Ocean",101 "6": "Street View"102 }103 104 threshold = 0.5105 predictions = {106 labels[str(i)]: round(probs[i], 3)107 for i in range(len(probs)) if probs[i] >= threshold108 }109 110 return predictions or {"None Detected": 0.0}111 112# Create Gradio interface113iface = gr.Interface(114 fn=classify_geoscene_image,115 inputs=gr.Image(type="numpy"),116 outputs=gr.Label(label="Predicted Scene Categories"),117 title="Multilabel-GeoSceneNet",118 description="Upload an image to detect multiple geographic scene elements (e.g., forest, ocean, buildings)."119)120 121if __name__ == "__main__":122 iface.launch()123```124 125---126 127## **Intended Use:**128 129The **Multilabel-GeoSceneNet** model is suitable for recognizing multiple geographic and structural elements in a single image. Use cases include:130 131- **Remote Sensing:** Label elements in satellite or drone imagery.132- **Geographic Tagging:** Auto-tagging images for search or sorting.133- **Environmental Monitoring:** Identify features like glaciers or forests.134- **Scene Understanding:** Help autonomous systems interpret complex scenes.