Skip to content
Back to skills

Segmentation Models

ASecurity

"Use Segmentation Models for Keras/TensorFlow image segmentation

  • 247 stars
  • 0 votes
  • 1 copy
  • 4 views
  • Added September 9, 2026
datapythonbashbackend

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill segmentation-models --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Segmentation Models?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Segmentation Models
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-segmentation-models/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-segmentation-models)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: segmentation-models
description: "Use Segmentation Models for Keras/TensorFlow image segmentation
  model construction, losses, metrics, preprocessing, training utilities, and
  troubleshooting."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Segmentation Models Repo Skill

Use this repo skill when a task asks about the Python package `segmentation_models` / Segmentation Models: constructing Keras semantic-segmentation models, selecting backbones, configuring preprocessing, choosing segmentation losses/metrics, or assembling small training/evaluation/fine-tuning workflows.

This skill is for using the package as an operating library. If the task is about editing the repository source, packaging releases, or changing tests, use a Python repository maintenance skill instead.

## Install and import baseline

Segmentation Models 1.x expects a Keras backend plus its own package dependencies. The package metadata installs `keras_applications`, `image-classifiers`, and `efficientnet`; TensorFlow/Keras itself is chosen separately for the target platform.

```bash
pip install segmentation-models
# Install a compatible TensorFlow/Keras backend for the environment.
```

In modern TensorFlow environments, prefer TensorFlow Keras and set the framework before import:

```python
import os
os.environ.setdefault("SM_FRAMEWORK", "tf.keras")
import segmentation_models as sm

print(sm.__version__)
print(sm.framework())
print(sm.get_available_backbone_names()[:5])
```

Run `scripts/check_environment.py` when a task needs a no-data import/framework/backbone smoke check. Add `--build-model` only when the environment can import TensorFlow/Keras and can build a tiny offline model with `encoder_weights=None`.

## Route map

| User task | Read |
| --- | --- |
| Instantiate `Unet`, `Linknet`, `FPN`, or `PSPNet`; choose `backbone_name`, `input_shape`, `classes`, `activation`, `encoder_weights`; debug shape/backbone/framework constructor errors. | `sub-skills/model-construction/SKILL.md` |
| Choose `IOUScore`, `FScore`, Dice/Jaccard/focal/CE losses; configure class weights/indexes, thresholds, per-image reduction; hand-check metric math. | `sub-skills/losses-metrics/SKILL.md` |
| Assemble training/evaluation/fine-tuning loops; use `get_preprocessing`; set image/mask shapes; handle non-RGB data; freeze/unfreeze encoders; add regularization; run synthetic training smoke checks. | `sub-skills/training-utilities/SKILL.md` |
| Diagnose package-wide install/import/backend/version problems before a workflow-specific route. | `references/troubleshooting.md` |
| Decide whether this skill is current for a checkout or package release. | `references/repo-provenance.md` |

## Fast workflow patterns

### Binary segmentation model

```python
import os
os.environ.setdefault("SM_FRAMEWORK", "tf.keras")
import segmentation_models as sm

BACKBONE = "resnet34"
preprocess_input = sm.get_preprocessing(BACKBONE)
model = sm.Unet(
    BACKBONE,
    classes=1,
    activation="sigmoid",
    encoder_weights="imagenet",
)
model.compile("Adam", loss=sm.losses.bce_jaccard_loss, metrics=[sm.metrics.iou_score])
```

### Multiclass model

```python
model = sm.FPN(
    "efficientnetb0",
    input_shape=(256, 256, 3),
    classes=4,
    activation="softmax",
    encoder_weights="imagenet",
)
model.compile("Adam", loss=sm.losses.cce_jaccard_loss, metrics=[sm.metrics.IOUScore()])
```

### Offline smoke construction

```python
model = sm.Unet(
    "resnet18",
    input_shape=(32, 32, 3),
    classes=1,
    activation="sigmoid",
    encoder_weights=None,
)
```

## Safety and scope notes

- `encoder_weights="imagenet"` may download weights and expects RGB-compatible input. Use `encoder_weights=None` for offline checks, non-RGB direct inputs, and deterministic smoke tests.
- The bundled scripts use synthetic data or parser/help checks only; they do not clone datasets, train benchmark models, or require GPU.
- CUDA/GPU is optional acceleration for real training in this package. CPU TensorFlow/Keras is sufficient for import, model-construction, loss/metric, and tiny training validation.
- Original notebooks and tests were used as evidence, but runtime guidance here is self-contained; do not require future agents to open or execute files from the original checkout.

Files in this skill

  • SKILL.md4.2 KB
  • references/repo-provenance.md2.2 KB
  • references/repo-routing-metadata.json339 B
  • references/troubleshooting.md4.7 KB
  • scripts/check_environment.py4.3 KB
  • sub-skills/losses-metrics/SKILL.md2.6 KB
  • sub-skills/losses-metrics/references/api-reference.md9.2 KB
  • sub-skills/losses-metrics/references/recipes.md7 KB
  • sub-skills/losses-metrics/references/troubleshooting.md7.4 KB
  • sub-skills/losses-metrics/scripts/check_losses_metrics.py7 KB
  • sub-skills/model-construction/SKILL.md2.9 KB
  • sub-skills/model-construction/references/api-reference.md7.8 KB
  • sub-skills/model-construction/references/backbones-and-architectures.md6.2 KB
  • sub-skills/model-construction/references/troubleshooting.md7.2 KB
  • sub-skills/model-construction/scripts/model_constructor_smoke.py7.6 KB
  • sub-skills/training-utilities/SKILL.md3.8 KB
  • sub-skills/training-utilities/references/data-and-masks.md6.2 KB
  • sub-skills/training-utilities/references/training-workflows.md7.1 KB
  • sub-skills/training-utilities/references/troubleshooting.md7.6 KB
  • sub-skills/training-utilities/scripts/tiny_training_smoke.py6.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.