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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coldet-1.0.0.tar.gz.
File metadata
- Download URL: coldet-1.0.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec9403fd9de15217750d0334c28da650786d7bb383df38ce7ec02d45b5db0e46
|
|
| MD5 |
72dc4f283bc52d8f42f94f0ed8ce4eba
|
|
| BLAKE2b-256 |
d412000c7e7fcc84456e8e3805f9aa9c958f80c5bdf4b0b94ce283218b74704b
|
File details
Details for the file coldet-1.0.0-py3-none-any.whl.
File metadata
- Download URL: coldet-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
808efd5732089560ab91bec634f9017033a99ad0eff11def0263610b4c48b8b4
|
|
| MD5 |
b632a82176403ec7cf5b5649e07df021
|
|
| BLAKE2b-256 |
0f8daaac2c61c4ce2b7fa8e4e1863ed67fbb5bc21e81b452ab204187be3de728
|