Views
No views yet
task="semantic", "instance", or "panoptic" to the same weights. The processor combines an image processor and a tokenizer for that task token.shi-labs/oneformer_ade20k_swin_tiny for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.OneFormerUniversalSegment) trained on ADE20K (150 classes, Swin-Tiny). All three tasks share these weights.1import os
2os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
3
4from PIL import Image
5from zeromodels.models.oneformer import (
6 OneFormerUniversalSegment,
7 OneFormerProcessor,
8)
9
10model = OneFormerUniversalSegment.from_weights("zeromodels/oneformer_ade20k_swin_tiny")
11processor = OneFormerProcessor.from_weights("zeromodels/oneformer_ade20k_swin_tiny")
12
13image = Image.open("your_image.jpg").convert("RGB")
14# task is an argument: "semantic" | "instance" | "panoptic"
15inputs = processor(images=image, task="panoptic")
16output = model(inputs)
17result = processor.post_process_panoptic_segmentation(
18 output, target_size=(image.height, image.width)
19)
20print(result["segmentation"].shape)from_weights("zeromodels/<variant>"):| Variant | Hub | Dataset | Backbone |
|---|---|---|---|
oneformer_ade20k_swin_tiny | zeromodels/oneformer_ade20k_swin_tiny | ADE20K | Swin-Tiny |
oneformer_ade20k_swin_large | zeromodels/oneformer_ade20k_swin_large | ADE20K | Swin-Large |
oneformer_coco_swin_large | zeromodels/oneformer_coco_swin_large | COCO | Swin-Large |
oneformer_cityscapes_swin_large | zeromodels/oneformer_cityscapes_swin_large | Cityscapes | Swin-Large |
KERAS_BACKEND before importing Keras / zeromodels.OneFormerProcessor.from_weights(...) so image size and tokenizer match the variant.processor(..., task=...); the checkpoint vocabulary comes from the training set, not the task.hf: prefix, e.g. OneFormerUniversalSegment.from_weights("hf:shi-labs/oneformer_ade20k_swin_tiny").