fashion_segformer / README.md
fj11's picture
Update README.md
e37c04a verified
|
Raw
History Blame Contribute Delete
1.31 kB
metadata
license: apache-2.0
datasets:
  - fj11/fashion
base_model:
  - nvidia/mit-b3
pipeline_tag: image-segmentation
library_name: transformers

SegFormer‑B3 for Fashion Semantic Segmentation (48 classes)

Base model: nvidia/mit-b3 Task: multi-class semantic segmentation for fashion images Classes: 0–47

🚀 Inference

from transformers import AutoModelForSemanticSegmentation, SegformerImageProcessor
from PIL import Image
import numpy as np
import requests
import matplotlib.pyplot as plt
import torch.nn as nn

model_id = "Itbanque/fashion_segformer"
processor = SegformerImageProcessor(
    size={"height": 512, "width": 512},
    do_resize=True,
    do_normalize=True
)
model = AutoModelForSemanticSegmentation.from_pretrained(model_id).eval()

url = "https://plus.unsplash.com/premium_photo-1673210886161-bfcc40f54d1f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8cGVyc29uJTIwc3RhbmRpbmd8ZW58MHx8MHx8&w=1000&q=80"

image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(images=image, return_tensors="pt")

outputs = model(**inputs)
logits = outputs.logits.cpu()

upsampled_logits = nn.functional.interpolate(
    logits,
    size=image.size[::-1],
    mode="bilinear",
    align_corners=False,
)

pred_seg = upsampled_logits.argmax(dim=1)[0]
plt.imshow(pred_seg)