Skip to main content

Colour detection inference — Python client and CLI.

Project description

coldet

Colour detection inference — Python client and terminal CLI.

Point it at an image. Get a colour back. That's the core of it.

import coldet

coldet.token("your-api-key")                        # save once
result = coldet.request("product-photo.jpg", "coldet-v1-mini")

print(result["predicted"])    # → "beige"
print(result["confidence"])   # → 0.2778

Installation

pip install coldet

Add [video] to enable MP4 frame-by-frame analysis:

pip install "coldet[video]"

Requires Python ≥ 3.9.


Quick start

1. Save your API token

You only need to do this once. The token is written to ~/.config/coldet/token.

import coldet
coldet.token("your-api-key")

Or set the environment variable instead:

export COLDET_API_TOKEN="your-api-key"

2. Run inference

result = coldet.request("shirt.jpg", "coldet-v1-mini")

3. Read the result

print(result["predicted"])          # top colour name
print(result["confidence"])         # float 0–1
print(result["probabilities"])      # dict of all classes → probabilities
print(result["credits_left"])       # remaining API credits

API reference

coldet.token(value=None)

Get or set the saved API token.

Parameter Type Description
value str | None When given, writes the token to disk and returns it. When omitted, returns the saved token (or None).

Returns str | None

coldet.token("sk-abc123")   # save
tok = coldet.token()         # read back → "sk-abc123"

coldet.request(image_path, model, *, api_token=None)

Run colour-detection inference on a local image.

Parameter Type Default Description
image_path str required Local file path or public URL.
model str "coldet-v1-mini" Model name — no extension needed.
api_token str | None None Override the saved token for this call only.

Returns dict with the following keys:

Key Type Description
predicted str Top predicted colour name.
confidence float Probability of the top prediction (0–1).
probabilities dict[str, float] Full distribution over all colour classes.
credits_left int API credits remaining on your account.
user str Username associated with the token.
model str Model that produced the result.

Raises coldet.ColdetError if the token is missing, the file cannot be read, or the API returns an error.


coldet.ColdetError

Exception raised by coldet.request() on any API or configuration failure.

try:
    result = coldet.request("photo.jpg")
except coldet.ColdetError as e:
    print(f"something went wrong: {e}")

Available models

Model Description
coldet-v1-mini Fast, lightweight model. 58 colour classes. Recommended for most use cases.

More models will be added as they are released.


CLI

Installing the package registers a coldet command:

coldet

The terminal interface is interactive:

  • Drop in an image path (Tab-completion available) to run inference and see the full colour distribution.
  • Type // to open the command menu:
    • /model — switch the active model
    • /token — save or rotate your API token
    • /whoami — inspect your current token and model
    • /quit — exit

MP4 files are processed frame-by-frame when opencv-python is installed.


Configuration

Method Details
coldet.token("key") Saves to ~/.config/coldet/token
COLDET_API_TOKEN env var Read at runtime if no file is present
COLDET_CONFIG_DIR env var Override the config directory

Importing as a package

coldet is a regular importable package — the CLI is just one entry point.

# Batch-process a folder
from pathlib import Path
import coldet

coldet.token("your-api-key")

images = Path("product-photos").glob("*.jpg")
for img in images:
    result = coldet.request(str(img))
    print(img.name, "→", result["predicted"], f"({result['confidence']:.1%})")

License

MIT

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

coldet-1.0.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

coldet-1.0.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file coldet-1.0.1.tar.gz.

File metadata

  • Download URL: coldet-1.0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for coldet-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f9af3b8ab1fa1460a2fefdf79a7764d01a1eaab473afdc90f186f1a46e1ac845
MD5 e51dba0c5eb6649b7abb28cda2cee5a8
BLAKE2b-256 9bb265bf3245d2971808b6e1dfd53c20914e8cff7b7e7f64965b88886336a5cb

See more details on using hashes here.

File details

Details for the file coldet-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: coldet-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for coldet-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03b2e8a605b5b93fd00dbd482e07d09b498f197856441f5261f56ebaa6fb079f
MD5 c5c283234042744bf7a54ca97e2c1444
BLAKE2b-256 773b4469cc7970ad22335113b9367d0593db7917989c485027fe0a80fb7ba749

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