/ Модель

Характеристики

Лицензия
BSD 3-Clause
Библиотека
pytorch
Опубликована
23 окт 2026

spiking-edge-detection-sm

Преобразование изображенийИзображение, текст → изображение3 профессии
38скачиваний за 30 дней0лайковвеса обновлены23 окт 2026

Описание модели

Составлено на русском по карточке модели и метаданным Hugging Face

Компактная спайковая сверточная сеть выделяет границы объектов на небольших изображениях в оттенках серого.

Edge-Detection-SCNN-small — компактная сверточная спайковая нейросеть для обнаружения границ объектов на изображениях в оттенках серого. Модель разработана Mark LPD и использует нейроны leaky integrate-and-fire (LIF); в ней 56 530 параметров. Изображение подается напрямую как входной ток на 32 шагах времени, а сеть из четырех сверток с BatchNorm и LIF формирует карты границ. Реализация выполнена на PyTorch, веса доступны в формате safetensors; лицензия — BSD 3-Clause.

Модель предназначена для выделения контуров на небольших изображениях природных сцен. Она обучалась на 200 изображениях BSDS500 размером 128 × 128 пикселей. На тестовой части BSDS500 автор сообщает ODS-F 0,690 и среднюю точность AP 0,653; эти результаты получены при собственной процедуре оценки и напрямую не сопоставимы с опубликованными результатами BSDS500 на полном разрешении. У спайковой модели AP выше, чем у сравниваемой сети с той же архитектурой и ReLU, но ODS-F немного ниже.

Модель принимает только изображения в градациях серого. Проверялись входы 128 × 128 пикселей; другие размеры не тестировались. Она может реагировать на сильную текстуру и пропускать слабые границы, а на документах, медицинских и спутниковых изображениях качество может быть ниже. Хотя активность нейронов разреженная, энергопотребление на нейроморфном оборудовании не измерялось; на GPU 32 шага вычислений обходятся примерно в 32 прямых прохода несипковой версии. Авторы не рекомендуют использовать модель для критически важных задач восприятия.

Сценарии применения

  • выделение контуров объектов на фотографиях в оттенках серого
  • построение карт границ для анализа природных сцен
  • эксперименты со спайковыми нейросетями для компьютерного зрения

Ограничения

Обучение и оценка проводились на 128 × 128 пикселях по 200 изображениям BSDS500; другие размеры и домены не проверялись. Модель может реагировать на выраженную текстуру и пропускать слабые границы, а применение в критически важных системах не рекомендуется.

Публичные бенчмарки

Результаты из открытых лидербордов в сравнении с лидерами каталога

Публичных оценок пока нет

В подключённых источниках результатов этой модели не нашлось. Отсутствие оценки не значит, что модель хуже: её могли просто не проверять.

Источники: Hugging Face Leaderboards, Hugging Face Eval Results, Open LLM v2, MTEB, timm, Open ASR, EvalPlus

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

SCNN grid

Test images. Rows: input, human consensus, SCNN.

Edge-Detection-SCNN-small is a spiking convolutional network (SCNN) that detects object boundaries in grayscale images. It is built from leaky integrate-and-fire (LIF) neurons, has 56,530 parameters and was trained on the 200 training images of BSDS500 (Arbeláez et al., 2011) at 128 × 128 px.

Key Features

  1. On the 200 BSDS500 test images, the SCNN reaches an ODS-F of 0.690 ± 0.002 (mean ± SD over 3 seeds), against 0.577 for Sobel, 0.577 ± 0.004 for a small CNN and 0.459 ± 0.003 for a ResNet18 encoder-decoder with 247× more parameters.
  2. It has the highest average precision of all tested methods (0.653 ± 0.013). A non-spiking twin with the identical architecture (ReLU instead of LIF) is slightly ahead in ODS-F (0.697 ± 0.001), so the spikes cost 0.007 ODS-F.
  3. Sparse activity. Per timestep, 18% to 23% of the neurons in the hidden layers fire, and 12% in the output population.
  4. F1 stays at 0.60 or higher for every binarization threshold from 0.34 to 0.89. The CNN never reaches 0.60 (maximum 0.58).
  5. Every network got the same budget: identical data, 128 epochs, 3 seeds, and loss, augmentation and BatchNorm were chosen per model on the validation split only.
  6. The model code is a single file in plain PyTorch, so snnTorch is not needed for inference or fine-tuning.

How the SCNN works

A LIF neuron integrates its input current into a membrane potential U and fires a spike S when U crosses the threshold θ. After a spike, θ is subtracted from U:

U[t] = β · U[t−1] + I[t] − S[t−1] · θ, S[t] = H(U[t] − θ)

β (initialized at 0.85) and θ are learned per layer. The spike is a step function without a useful gradient, so training uses a fast sigmoid surrogate (∂S/∂U ≈ 1 / (1 + 25 · |U − θ|)²).

The grayscale image is fed directly as input current at each of T = 32 timesteps (direct encoding). Four 3×3 convolutions with dilations 1, 2, 5 and 1 (48, 48, 48 and 32 channels, receptive field 19 × 19 px), each followed by BatchNorm and LIF neurons, turn it into spike maps. A 1×1 convolution then drives a population of 8 LIF neurons per pixel. The edge logit is the membrane potential of this output population, averaged over the 32 timesteps and the 8 neurons, and a sigmoid turns it into an edge probability.

Usage

The model code is a single file, scnn.py, that only needs torch, huggingface_hub and safetensors (plus pillow for preprocess).

pip install torch huggingface_hub safetensors pillow
from huggingface_hub import hf_hub_download

hf_hub_download("marklpd/Edge-Detection-SCNN-small", "scnn.py", local_dir=".")
from scnn import SCNN, preprocess

model = SCNN.from_pretrained("marklpd/Edge-Detection-SCNN-small").eval()

x = preprocess("image.jpg") # (1, 1, 128, 128) grayscale in [0, 1]
edges = model.detect_edges(x) # (1, 1, 128, 128) edge probability
binary = edges > 0.70 # ODS threshold of seed 0 on the test split

model(x, return_spike_rates=True) returns the logits and the spike rate of every layer. timesteps= changes T at inference, but the weights were trained with T = 32. The network is fully convolutional, so other input sizes run, but it only saw 128 × 128 images. Resizing to 128 × 128 (as preprocess does) matches training.

Files

filecontent
model.safetensorsweights of seed 0 (use this)
scnn_seed1.safetensors, scnn_seed2.safetensorsweights of the other two seeds
config.json, scnn.pymodel hyperparameters and code
eval/metrics.jsonevery number on this page, per seed
images/figures on this page

The weights were trained with snnTorch 0.9.4 and converted to scnn.py. On all 200 test images, both give the same edge maps (see eval/metrics.json).

Evaluation

All numbers are on the 200 test images of BSDS500 at 128 × 128 px. The target is the consensus of all human annotations (every annotator's boundaries dilated by 1 px, averaged, downsampled with area interpolation and binarized at 0.5). A predicted edge pixel counts as correct within 2 px of a target edge, evaluated at 25 thresholds from 0.03 to 0.97. ODS-F is the F1 at the best threshold for the whole dataset, OIS-F at the best threshold per image, and AP the area under the precision-recall curve. ± is the standard deviation over 3 seeds. The classical operators are deterministic.

methodparametersODS-F ↑OIS-F ↑AP ↑
SCNN (this model)56.5k0.690 ± 0.0020.710 ± 0.0020.653 ± 0.013
ANN twin (ReLU instead of LIF)56.5k0.697 ± 0.0010.719 ± 0.0010.594 ± 0.004
SCNN, MSE + Dice, no BatchNorm56.2k0.627 ± 0.0230.649 ± 0.0250.450 ± 0.077
CNN (3 layers)4.8k0.577 ± 0.0040.610 ± 0.0030.523 ± 0.011
ResNet18 encoder-decoder14.0M0.459 ± 0.0030.482 ± 0.0030.351 ± 0.002
Sobel00.5770.6070.554
Laplace00.5130.5430.440
Canny00.4990.4990.000

Canny returns binary maps, so it has no precision-recall curve (AP = 0). The SCNN variant with MSE + Dice loss and without BatchNorm shows what the configuration search changed: BCE + Dice with BatchNorm raises the ODS-F by 0.063 and cuts the SD across seeds from 0.023 to 0.002.

These numbers are not comparable to published BSDS500 benchmarks. Those run at full resolution (481 × 321 px) with bipartite matching and edge thinning, where for example HED reaches an ODS-F of 0.782 (Xie & Tu, 2015).

Input encoding and spike penalty

With the same configuration (48 epochs, seed 0), the SCNN was trained with three input encodings and once with a spike penalty (λ · spike rate added to the loss).

encodingλODS-F ↑OIS-F ↑AP ↑spike rate ↓
direct + population00.6790.6990.5880.214
rate (Bernoulli)00.6170.6410.6000.187
latency (τ = 5)00.3440.3750.1950.297
direct + population0.10.6810.7050.5920.139

Direct input beats rate and latency coding, in line with Kim et al. (2022) for classification. The spike penalty cuts the spike rate by 35% at the same ODS-F (0.681 vs. 0.679, within seed noise). These runs use one seed each, and the weights with the spike penalty are not part of this repository.

Training

  1. Data. BSDS500 (Kaggle mirror balraj98/berkeley-segmentation-dataset-500-bsds500), 200 training, 100 validation and 200 test images, converted to grayscale and resized to 128 × 128 px.
  2. Configuration search. Every network (SCNN, ANN twin, CNN, ResNet18) went through the same search on the validation split (seed 0, 48 epochs): loss (MSE + 0.5 · Dice or BCE with positive weight 10 + Dice) and augmentation (90° rotations, flips), then BatchNorm or spike-element-wise residuals (Fang et al., 2021) for the SCNN and its twin. For the SCNN, BatchNorm before the LIF neurons gave the largest gain (+0.04 ODS-F), residuals none.
  3. Final runs. BCE + Dice, BatchNorm, no augmentation, Adam with a learning rate of 5·10⁻⁴ and cosine annealing, 128 epochs, batch size 16, seeds 0, 1 and 2. The test split was only used for the final evaluation.

Training ran on one NVIDIA A100 (40 GB) in Google Colab with PyTorch and snnTorch 0.9.4.

Limitations

  • The model was trained and evaluated at 128 × 128 px. Fine edges that only exist at full resolution are lost, and other input sizes are untested.
  • It only sees grayscale, so it cannot separate regions that differ only in color.
  • Its training data are 200 natural photos. Expect worse results on other domains (documents, medical or satellite images).
  • It also responds to strong texture (tree bark) and misses faint object boundaries.
  • Spikes are only counted, energy was not measured on neuromorphic hardware. On a GPU the 32 timesteps cost roughly 32 forward passes of the non-spiking twin.
  • 3 seeds are enough for the SD on this page but not for significance tests, and the encoding comparison uses a single seed.

Out-of-Scope Use

  • Safety-critical perception (driving, robotics near people, medical diagnosis). This is a small research model.
  • Claims against published BSDS500 results, because the resolution and evaluation differ (see Evaluation).

License

The code and weights are released under the BSD 3-Clause License. The weights were trained on BSDS500 (Arbeláez et al., 2011), so check the dataset's terms before commercial use.

Citation

@misc{leupold2026scnnedge,
  author = {Leupold, Mark-Daniel},
  title = {Edge-Detection-SCNN-small: A Spiking CNN for Boundary Detection on BSDS500},
  year = {2026},
  publisher = {Hugging Face},
  url = {https://huggingface.co/marklpd/Edge-Detection-SCNN-small}
}

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · pytorch

Нельзя запустить

Модели «картинка → картинка» пока не запускаются.

Ревизия весов
d97158b

0 моделей