Skip to main content

Plug-and-play contrastive learning framework designed for spatially structured modalities.

Project description

🧭 Overview

SpatialCL is a plug-and-play contrastive learning framework designed for spatially structured modalities, including RGB, thermal, RGB-D data etc. It robustly handles intra- and inter-class variability, enabling consistent embeddings across challenging datasets.

🧪 As a demonstration of its capabilities, SpatialCL has been applied in DiSCO 🔗Detection of Spills in Indoor environments using weakly supervised contrastive learning — showcasing its practical impact in real-world spill detection scenarios.

⚙️ While the framework is modality-agnostic and can be extended to other dense spatial tasks, extending SpatialCL to sparse, graph-structured data such as skeletons represents an exciting direction for future work.

Framework Architecture

SpatialCL Architecture

figure 1: Through the encoder, feature embeddings are extracted to obtain zij , which are subsequently normalized. From these embeddings, the cohesion score cij is computed, representing how likely samples xi and xj remain compact within the same co-cluster. A binomial opinion is modeled as a Beta probability density function (PDF), under the assumption of a bijective mapping between both representations. The uncertainty uij is then computed to measure the confidence that xi and xj can be close within a cluster, enabling the model to avoid forcing samples of the same class together despite strong visual differences. To ensure stable and gradual learning, a curriculum function is introduced to guide progressive training and to compute the adaptive weight wij , addressing intra-class variability. For inter-class modeling, the parameter β is computed as described in the schema above, allowing the model to focus on hard negatives and enhance class separation. All these components are integrated into the final loss function Lij .

🎯 Why DISCO Submodule of SpatialCL?

DISCO (Detection of Indoor Spills with Contrastive learning) addresses one of the most persistent challenges in computer vision: uncertainty under weak supervision. Traditional vision systems are typically designed and optimized for perception tasks involving rigid, well-structured objects with distinct geometric cues. However, these systems often fail when faced with visually ambiguous targets such as indoor liquid spills, whose irregular shapes, diffuse boundaries, and variable textures defy conventional object representations.

  • The difficulty arises from several intertwined factors:
  • The absence of clear contours or well-defined shapes;
  • Extreme intra-class variability in appearance and scale;
  • Weak or inconsistent edge and texture cues;
  • Frequent occlusion and foreground–background blending;
  • A scarcity of reliable labeled examples; and
  • environmental disturbances such as illumination changes, surface reflections, and sensor noise.

Key Features

  • ✅ Handles ambiguous and irregular objects that standard vision models struggle with
  • ✅ Supports: RGB, thermal, depth, etc.
  • Memory-optimized contrastive learning for faster training
  • ✅ Produces highly discriminative embeddings for downstream tasks
  • ✅ Handles class imbalance
  • ✅ Easy integration into existing PyTorch pipelines

Beyond DISCO / SpatialCL applied to Anomaly Detection

key features

  • ✅ Handle class level variability for downstream tasks
  • ✅ Handles class imbalance

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

spatialcl-0.1.2.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

spatialcl-0.1.2-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file spatialcl-0.1.2.tar.gz.

File metadata

  • Download URL: spatialcl-0.1.2.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for spatialcl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1515ce8191f441846ff0a7a98a7a3c42ce8585b6aa22431c99073502468af6b2
MD5 12d5f619ef45f1ae033da2a33757fa5e
BLAKE2b-256 a5c291330b93c7d100fd469c87c55e0704e71b3af24f045702e0da3af684a4ab

See more details on using hashes here.

File details

Details for the file spatialcl-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: spatialcl-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for spatialcl-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71862cc980daeed5167f381c79e4a6dbb04af29acd0a565dda8952a4552e7a05
MD5 396142cee56d0bebd78a06df5d7db22b
BLAKE2b-256 da7d8acb611d7f1b3c887ad4a71993cc9ee0178881e2e695662020919188d4b4

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