Upload README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: scikit-learn
|
| 4 |
+
tags:
|
| 5 |
+
- color-classification
|
| 6 |
+
- random-forest
|
| 7 |
+
- tabular-classification
|
| 8 |
+
- scikit-learn
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# Color AI β chroma classifiers
|
| 12 |
+
|
| 13 |
+
Three trained color-naming classifiers: given a color, they name it β
|
| 14 |
+
"red", "navy", "charcoal", etc. Each is a `scikit-learn`
|
| 15 |
+
`RandomForestClassifier`, trained entirely on synthetic labeled data (no
|
| 16 |
+
photos, no dataset needed to build them) β see
|
| 17 |
+
[color-ai-core](https://pypi.org/project/color-ai-core/) on PyPI for the
|
| 18 |
+
code that trained these and the functions to use them correctly.
|
| 19 |
+
|
| 20 |
+
## Files
|
| 21 |
+
|
| 22 |
+
| File | Code name | Colors | Trees | Samples/class | Validation accuracy |
|
| 23 |
+
|---|---|---|---|---|---|
|
| 24 |
+
| `color_classifier_nano.joblib` | `chromav1n-clf` | 12 | 60 | 400 | 92.4% |
|
| 25 |
+
| `color_classifier_micro.joblib` | `chromav1u-clf` | 24 | 80 | 500 | 82.7% |
|
| 26 |
+
| `color_classifier_microsuper.joblib` | `chromav1us-clf` | 24 | 80 | 800 | 84.4% |
|
| 27 |
+
|
| 28 |
+
**Nano** covers the basics: red, orange, yellow, green, teal, blue,
|
| 29 |
+
purple, pink, brown, black, gray, white.
|
| 30 |
+
|
| 31 |
+
**Micro** and **Micro Super** add 12 more: maroon, navy, olive, lime,
|
| 32 |
+
cyan, magenta, indigo, coral, mint, lavender, beige, charcoal. Micro
|
| 33 |
+
Super is the same 24 classes as Micro, just trained on more samples per
|
| 34 |
+
class (800 vs 500), which measurably improves accuracy β same anchors,
|
| 35 |
+
same architecture, purely more training evidence.
|
| 36 |
+
|
| 37 |
+
Micro and Micro Super also support a **two-stage fallback**: when the
|
| 38 |
+
model isn't confident (below 50%) in its specific pick, it's meant to
|
| 39 |
+
report the broader Nano-family color instead of guessing between two
|
| 40 |
+
close options (e.g. "brown" instead of a shaky call between beige and
|
| 41 |
+
charcoal). This logic lives in the `color-ai-core` package, not baked
|
| 42 |
+
into the `.joblib` file itself β see Usage below.
|
| 43 |
+
|
| 44 |
+
## Usage
|
| 45 |
+
|
| 46 |
+
β οΈ These models do **not** take raw RGB as input. They were trained on a
|
| 47 |
+
4-value feature vector β `[sin(hue), cos(hue), saturation, value]` β not
|
| 48 |
+
`[R, G, B]` directly. Feeding raw RGB straight to `.predict()` will run
|
| 49 |
+
without error but give meaningless results. Use the matching feature
|
| 50 |
+
function from `color-ai-core` rather than hand-rolling it:
|
| 51 |
+
|
| 52 |
+
```bash
|
| 53 |
+
pip install color-ai-core huggingface_hub
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from huggingface_hub import hf_hub_download
|
| 58 |
+
from color_ai_core import load_model, predict_color
|
| 59 |
+
|
| 60 |
+
path = hf_hub_download(repo_id="YOUR_USERNAME/YOUR_REPO_NAME",
|
| 61 |
+
filename="color_classifier_micro.joblib")
|
| 62 |
+
clf = load_model(path)
|
| 63 |
+
|
| 64 |
+
name, confidence, used_fallback = predict_color(clf, [220, 40, 30], tier="micro")
|
| 65 |
+
print(name) # "red"
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
`predict_color()` handles the RGB β feature conversion and the two-stage
|
| 69 |
+
fallback correctly β that's why it's the supported way to use these
|
| 70 |
+
files rather than calling `clf.predict()` directly.
|
| 71 |
+
|
| 72 |
+
## Training
|
| 73 |
+
|
| 74 |
+
All three were trained on jittered synthetic data generated around fixed
|
| 75 |
+
HSV anchor points per color (e.g. red β hue 0Β°, high saturation, high
|
| 76 |
+
value) β noise is added to hue, saturation, value, and the final RGB to
|
| 77 |
+
simulate lighting and camera variation, so each model learns a color's
|
| 78 |
+
*range* rather than one exact shade. No photos were used to train these
|
| 79 |
+
specific files. `color-ai-core` also includes `train_from_images()` for
|
| 80 |
+
training a classifier on your own labeled photos instead, if you'd
|
| 81 |
+
rather have that.
|
| 82 |
+
|
| 83 |
+
## License
|
| 84 |
+
|
| 85 |
+
MIT
|