Skip to main content

Signed Distance Function based loss functions for deep learning semantic segmentation to miss fewer instances.

Project description

SDF Loss

Signed Distance Function (SDF) based loss functions for deep learning semantic segmentation.

Overview

This library provides PyTorch loss functions that use Signed Distance Functions to weight pixels based on their distance from object boundaries. This approach puts heavier penalties on false positives and false negatives that are farther from the correct boundary, leading to more accurate segmentation results.

Installation

Install directly from PyPI:

pip install sdf-loss

Or using uv:

uv add sdf-loss

Quick Start

import torch
from sdf_loss import DiSCoLoss

# Initialize the loss function
criterion = DiSCoLoss()

# Your model predictions (logits) and ground truth
pred_logits = model(images)  # Shape: (B, 1, H, W)
target = ground_truth         # Shape: (B, 1, H, W), binary mask

# Compute loss
loss = criterion(pred_logits, target)
loss.backward()

License

This project is licensed under the MIT License - see the LICENSE file for details.

Issues

  1. Errors at KSAT: "Killed by signal. "
  2. Some stuck and didn't go on for a long time.
  3. At wandb, some say "Crashed", some say "Failed".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdf_loss-0.2.0.tar.gz (127.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdf_loss-0.2.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file sdf_loss-0.2.0.tar.gz.

File metadata

  • Download URL: sdf_loss-0.2.0.tar.gz
  • Upload date:
  • Size: 127.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sdf_loss-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da39d7251d5672778c19756ba92227c18803761cd9072fee0f753987cd50a44f
MD5 cd7428a32ecfe8f6e2b794cdab10168d
BLAKE2b-256 7deb4319893021ab15ad95b2bd5e2b4d3bac5140a40b4c143ee43d0b962d74ab

See more details on using hashes here.

File details

Details for the file sdf_loss-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sdf_loss-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for sdf_loss-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ab2809e2142174806bd775c8e21dd095014e51d69dd0a1f5542bff7efae78f1
MD5 c61021d5370db6e08e9615eda9938c72
BLAKE2b-256 8601ba595f2308da2c835e07fe02bf24b9394bab37659a4e8aff7e4bc2adc857

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page