ONNX export of
cm93/resnet50-eurosat, a ResNet-50 model fine-tuned on the
EuroSAT satellite imagery dataset for land-use and land-cover (LULC) classification.
Source model reported metrics (from
cm93/resnet50-eurosat):
1import numpy as np
2import onnxruntime as ort
3from huggingface_hub import hf_hub_download
4from transformers import AutoImageProcessor, AutoConfig
5from PIL import Image
6
7# Load ONNX session
8model_path = hf_hub_download("krylox/resnet50-eurosat-onnx", filename="model.onnx")
9session = ort.InferenceSession(model_path, providers=["CPUExecutionProvider"])
10
11# Load processor and label map from the source model
12processor = AutoImageProcessor.from_pretrained("cm93/resnet50-eurosat")
13id2label = AutoConfig.from_pretrained("cm93/resnet50-eurosat").id2label
14
15# Preprocess and infer
16image = Image.open("your_image.jpg").convert("RGB")
17pixel_values = processor(images=image, return_tensors="pt")["pixel_values"].numpy().astype(np.float32)
18
19input_name = session.get_inputs()[0].name
20output_name = session.get_outputs()[0].name
21logits = session.run([output_name], {input_name: pixel_values})[0]
22
23predicted_label = id2label[int(np.argmax(logits, axis=1)[0])]
24print(f"Predicted class: {predicted_label}")
The source model was trained on
EuroSAT, which contains 27,000 labeled, geo-referenced Sentinel-2 satellite image patches (JPEG, 64×64 px) across 10 LULC classes.