GlobalWheat/GWFSS_v1.0
Viewer • Updated • 1.1k • 127 • 3
How to use GlobalWheat/GWFSS_Segformer_b0 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-segmentation", model="GlobalWheat/GWFSS_Segformer_b0") # Load model directly
from transformers import AutoImageProcessor, SegformerForSemanticSegmentation
processor = AutoImageProcessor.from_pretrained("GlobalWheat/GWFSS_Segformer_b0")
model = SegformerForSemanticSegmentation.from_pretrained("GlobalWheat/GWFSS_Segformer_b0")from transformers import AutoImageProcessor, SegformerForSemanticSegmentation
import torch, torch.nn.functional as F
from PIL import Image
import numpy as np
repo = "GlobalWheat/GWFSS_model_v1.0"
processor = AutoImageProcessor.from_pretrained(repo)
model = SegformerForSemanticSegmentation.from_pretrained(repo).eval()
img = Image.open("example.jpg").convert("RGB")
inputs = processor(images=img, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
up = F.interpolate(logits, size=(img.height, img.width), mode="bilinear", align_corners=False)
pred = up.argmax(1)[0].cpu().numpy() # (H, W) class IDs
This version is based on huggingface Segformer which could be slightly different from the one we used for our paper. The paper version was implemented based on the mmsegmentation. You can find the model weight for mmsegmentation library in this repo as well.
This dataset is associated with the following paper: The Global Wheat Full Semantic Organ Segmentation (GWFSS) Dataset https://doi.org/10.1016/j.plaphe.2025.100084
Base model
nvidia/segformer-b1-finetuned-ade-512-512