Publish Next-Match model
Browse files- .gitattributes +2 -0
- README.md +64 -0
- catalog.json +1 -0
- catalog.png +3 -0
- combined.safetensors +3 -0
- evaluation.json +1045 -0
- image.safetensors +3 -0
- inference.py +55 -0
- match_core.py +79 -0
- model.json +0 -0
- nlrt.py +226 -0
- preview.png +3 -0
- render.py +66 -0
- selftest.json +0 -0
- text.safetensors +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
catalog.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
preview.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
tags:
|
| 5 |
+
- composed-image-retrieval
|
| 6 |
+
- multimodal
|
| 7 |
+
- turkish
|
| 8 |
+
- next-lab
|
| 9 |
+
language:
|
| 10 |
+
- tr
|
| 11 |
+
- en
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Next Match
|
| 15 |
+
|
| 16 |
+
Next Match finds a catalog item from a **reference image plus a short edit in Turkish or English** —
|
| 17 |
+
*"bunun kırmızı olanı"*, *"çizgili olanı"*, *"same but a hat"*. The test catalog is built so that the image alone (it
|
| 18 |
+
finds look-alikes in the wrong colour) and the text alone (it finds red things of any kind) both fail; the fused query
|
| 19 |
+
succeeds. The catalog is **synthetic**: procedurally drawn product icons (8 categories × 8 colours × 3 patterns).
|
| 20 |
+
|
| 21 |
+
**Space:** https://huggingface.co/spaces/thelamapi/Next-Match — pick a product (or upload a picture), type a change, and compare the three rankings live.
|
| 22 |
+
|
| 23 |
+
## Results (1600 test queries, 192-item catalog, unseen renderings)
|
| 24 |
+
|
| 25 |
+
Recall@1 / Recall@5:
|
| 26 |
+
|
| 27 |
+
| Query group | n | Image + text (Next Match) | Image only | Text only |
|
| 28 |
+
|---|---:|---:|---:|---:|
|
| 29 |
+
| all | 1600 | 0.932 / 0.966 | 0.000 / 0.316 | 0.054 / 0.263 |
|
| 30 |
+
| edit=color | 648 | 0.994 / 1.000 | 0.000 / 0.358 | 0.051 / 0.218 |
|
| 31 |
+
| edit=pattern | 311 | 0.836 / 0.897 | 0.000 / 0.878 | 0.016 / 0.074 |
|
| 32 |
+
| edit=category | 322 | 1.000 / 1.000 | 0.000 / 0.000 | 0.031 / 0.183 |
|
| 33 |
+
| edit=color+pattern | 319 | 0.834 / 0.931 | 0.000 / 0.000 | 0.122 / 0.621 |
|
| 34 |
+
| lang=tr | 747 | 0.995 / 1.000 | 0.000 / 0.317 | 0.051 / 0.258 |
|
| 35 |
+
| lang=en | 853 | 0.878 / 0.937 | 0.000 / 0.314 | 0.057 / 0.267 |
|
| 36 |
+
| template=seen | 1104 | 1.000 / 1.000 | 0.000 / 0.323 | 0.057 / 0.251 |
|
| 37 |
+
| template=held-out | 496 | 0.782 / 0.891 | 0.000 / 0.298 | 0.048 / 0.290 |
|
| 38 |
+
| combo=seen | 1192 | 0.933 / 0.966 | 0.000 / 0.348 | 0.057 / 0.296 |
|
| 39 |
+
| combo=held-out | 408 | 0.931 / 0.966 | 0.000 / 0.221 | 0.047 / 0.167 |
|
| 40 |
+
|
| 41 |
+
*template=held-out*: phrasings never used in training (e.g. "show me the red one", "kırmızı olanını göster").
|
| 42 |
+
*combo=held-out*: the reference or target is one of 24 attribute combinations never rendered during training.
|
| 43 |
+
|
| 44 |
+

|
| 45 |
+
|
| 46 |
+
## Method
|
| 47 |
+
* Image encoder: 4 conv blocks (16/32/64/64 channels) + linear → 64-d. Catalog keys are L2-normalised image features.
|
| 48 |
+
* Text: Turkish-aware lower-casing and longest-prefix stemming over a 61-word vocabulary (so "kırmızısı" or "olanını" still match), mean word embedding → MLP.
|
| 49 |
+
* Fusion: q = normalise(f_img + MLP([f_img, f_text])) — the text predicts a residual edit of the image feature.
|
| 50 |
+
* Baselines: image-only (image encoder + MLP head) and text-only (text encoder vs its own image keys), same architecture budget, 6000 steps, batch 128, InfoNCE with τ = 0.1.
|
| 51 |
+
* The Space runs all three encoders with `nlrt.js` on exported weights; Node parity max abs difference 1.6653345369377348e-16.
|
| 52 |
+
|
| 53 |
+
## Usage
|
| 54 |
+
```python
|
| 55 |
+
from inference import load, search
|
| 56 |
+
spec = load()
|
| 57 |
+
ids = search(spec, ref_image, "bunun kırmızı olanı") # ref_image: (48, 48, 3) uint8; ids index catalog.json
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
## Limitations
|
| 61 |
+
* Toy domain: flat icons on plain backgrounds. Real product photos need a pretrained vision encoder and real catalog data.
|
| 62 |
+
* Vocabulary is closed: words outside it are ignored (the Space shows which words were understood).
|
| 63 |
+
* Uploaded photos are far outside the training distribution and are a curiosity, not a supported use.
|
| 64 |
+
* Trained on NVIDIA L4; profile full. Failure examples are in `evaluation.json`.
|
catalog.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"cols": 16, "items": [{"category": "tshirt", "color": "red", "pattern": "plain"}, {"category": "tshirt", "color": "red", "pattern": "striped"}, {"category": "tshirt", "color": "red", "pattern": "dotted"}, {"category": "tshirt", "color": "blue", "pattern": "plain"}, {"category": "tshirt", "color": "blue", "pattern": "striped"}, {"category": "tshirt", "color": "blue", "pattern": "dotted"}, {"category": "tshirt", "color": "green", "pattern": "plain"}, {"category": "tshirt", "color": "green", "pattern": "striped"}, {"category": "tshirt", "color": "green", "pattern": "dotted"}, {"category": "tshirt", "color": "yellow", "pattern": "plain"}, {"category": "tshirt", "color": "yellow", "pattern": "striped"}, {"category": "tshirt", "color": "yellow", "pattern": "dotted"}, {"category": "tshirt", "color": "black", "pattern": "plain"}, {"category": "tshirt", "color": "black", "pattern": "striped"}, {"category": "tshirt", "color": "black", "pattern": "dotted"}, {"category": "tshirt", "color": "white", "pattern": "plain"}, {"category": "tshirt", "color": "white", "pattern": "striped"}, {"category": "tshirt", "color": "white", "pattern": "dotted"}, {"category": "tshirt", "color": "purple", "pattern": "plain"}, {"category": "tshirt", "color": "purple", "pattern": "striped"}, {"category": "tshirt", "color": "purple", "pattern": "dotted"}, {"category": "tshirt", "color": "orange", "pattern": "plain"}, {"category": "tshirt", "color": "orange", "pattern": "striped"}, {"category": "tshirt", "color": "orange", "pattern": "dotted"}, {"category": "mug", "color": "red", "pattern": "plain"}, {"category": "mug", "color": "red", "pattern": "striped"}, {"category": "mug", "color": "red", "pattern": "dotted"}, {"category": "mug", "color": "blue", "pattern": "plain"}, {"category": "mug", "color": "blue", "pattern": "striped"}, {"category": "mug", "color": "blue", "pattern": "dotted"}, {"category": "mug", "color": "green", "pattern": "plain"}, {"category": "mug", "color": "green", "pattern": "striped"}, {"category": "mug", "color": "green", "pattern": "dotted"}, {"category": "mug", "color": "yellow", "pattern": "plain"}, {"category": "mug", "color": "yellow", "pattern": "striped"}, {"category": "mug", "color": "yellow", "pattern": "dotted"}, {"category": "mug", "color": "black", "pattern": "plain"}, {"category": "mug", "color": "black", "pattern": "striped"}, {"category": "mug", "color": "black", "pattern": "dotted"}, {"category": "mug", "color": "white", "pattern": "plain"}, {"category": "mug", "color": "white", "pattern": "striped"}, {"category": "mug", "color": "white", "pattern": "dotted"}, {"category": "mug", "color": "purple", "pattern": "plain"}, {"category": "mug", "color": "purple", "pattern": "striped"}, {"category": "mug", "color": "purple", "pattern": "dotted"}, {"category": "mug", "color": "orange", "pattern": "plain"}, {"category": "mug", "color": "orange", "pattern": "striped"}, {"category": "mug", "color": "orange", "pattern": "dotted"}, {"category": "sneaker", "color": "red", "pattern": "plain"}, {"category": "sneaker", "color": "red", "pattern": "striped"}, {"category": "sneaker", "color": "red", "pattern": "dotted"}, {"category": "sneaker", "color": "blue", "pattern": "plain"}, {"category": "sneaker", "color": "blue", "pattern": "striped"}, {"category": "sneaker", "color": "blue", "pattern": "dotted"}, {"category": "sneaker", "color": "green", "pattern": "plain"}, {"category": "sneaker", "color": "green", "pattern": "striped"}, {"category": "sneaker", "color": "green", "pattern": "dotted"}, {"category": "sneaker", "color": "yellow", "pattern": "plain"}, {"category": "sneaker", "color": "yellow", "pattern": "striped"}, {"category": "sneaker", "color": "yellow", "pattern": "dotted"}, {"category": "sneaker", "color": "black", "pattern": "plain"}, {"category": "sneaker", "color": "black", "pattern": "striped"}, {"category": "sneaker", "color": "black", "pattern": "dotted"}, {"category": "sneaker", "color": "white", "pattern": "plain"}, {"category": "sneaker", "color": "white", "pattern": "striped"}, {"category": "sneaker", "color": "white", "pattern": "dotted"}, {"category": "sneaker", "color": "purple", "pattern": "plain"}, {"category": "sneaker", "color": "purple", "pattern": "striped"}, {"category": "sneaker", "color": "purple", "pattern": "dotted"}, {"category": "sneaker", "color": "orange", "pattern": "plain"}, {"category": "sneaker", "color": "orange", "pattern": "striped"}, {"category": "sneaker", "color": "orange", "pattern": "dotted"}, {"category": "bag", "color": "red", "pattern": "plain"}, {"category": "bag", "color": "red", "pattern": "striped"}, {"category": "bag", "color": "red", "pattern": "dotted"}, {"category": "bag", "color": "blue", "pattern": "plain"}, {"category": "bag", "color": "blue", "pattern": "striped"}, {"category": "bag", "color": "blue", "pattern": "dotted"}, {"category": "bag", "color": "green", "pattern": "plain"}, {"category": "bag", "color": "green", "pattern": "striped"}, {"category": "bag", "color": "green", "pattern": "dotted"}, {"category": "bag", "color": "yellow", "pattern": "plain"}, {"category": "bag", "color": "yellow", "pattern": "striped"}, {"category": "bag", "color": "yellow", "pattern": "dotted"}, {"category": "bag", "color": "black", "pattern": "plain"}, {"category": "bag", "color": "black", "pattern": "striped"}, {"category": "bag", "color": "black", "pattern": "dotted"}, {"category": "bag", "color": "white", "pattern": "plain"}, {"category": "bag", "color": "white", "pattern": "striped"}, {"category": "bag", "color": "white", "pattern": "dotted"}, {"category": "bag", "color": "purple", "pattern": "plain"}, {"category": "bag", "color": "purple", "pattern": "striped"}, {"category": "bag", "color": "purple", "pattern": "dotted"}, {"category": "bag", "color": "orange", "pattern": "plain"}, {"category": "bag", "color": "orange", "pattern": "striped"}, {"category": "bag", "color": "orange", "pattern": "dotted"}, {"category": "hat", "color": "red", "pattern": "plain"}, {"category": "hat", "color": "red", "pattern": "striped"}, {"category": "hat", "color": "red", "pattern": "dotted"}, {"category": "hat", "color": "blue", "pattern": "plain"}, {"category": "hat", "color": "blue", "pattern": "striped"}, {"category": "hat", "color": "blue", "pattern": "dotted"}, {"category": "hat", "color": "green", "pattern": "plain"}, {"category": "hat", "color": "green", "pattern": "striped"}, {"category": "hat", "color": "green", "pattern": "dotted"}, {"category": "hat", "color": "yellow", "pattern": "plain"}, {"category": "hat", "color": "yellow", "pattern": "striped"}, {"category": "hat", "color": "yellow", "pattern": "dotted"}, {"category": "hat", "color": "black", "pattern": "plain"}, {"category": "hat", "color": "black", "pattern": "striped"}, {"category": "hat", "color": "black", "pattern": "dotted"}, {"category": "hat", "color": "white", "pattern": "plain"}, {"category": "hat", "color": "white", "pattern": "striped"}, {"category": "hat", "color": "white", "pattern": "dotted"}, {"category": "hat", "color": "purple", "pattern": "plain"}, {"category": "hat", "color": "purple", "pattern": "striped"}, {"category": "hat", "color": "purple", "pattern": "dotted"}, {"category": "hat", "color": "orange", "pattern": "plain"}, {"category": "hat", "color": "orange", "pattern": "striped"}, {"category": "hat", "color": "orange", "pattern": "dotted"}, {"category": "chair", "color": "red", "pattern": "plain"}, {"category": "chair", "color": "red", "pattern": "striped"}, {"category": "chair", "color": "red", "pattern": "dotted"}, {"category": "chair", "color": "blue", "pattern": "plain"}, {"category": "chair", "color": "blue", "pattern": "striped"}, {"category": "chair", "color": "blue", "pattern": "dotted"}, {"category": "chair", "color": "green", "pattern": "plain"}, {"category": "chair", "color": "green", "pattern": "striped"}, {"category": "chair", "color": "green", "pattern": "dotted"}, {"category": "chair", "color": "yellow", "pattern": "plain"}, {"category": "chair", "color": "yellow", "pattern": "striped"}, {"category": "chair", "color": "yellow", "pattern": "dotted"}, {"category": "chair", "color": "black", "pattern": "plain"}, {"category": "chair", "color": "black", "pattern": "striped"}, {"category": "chair", "color": "black", "pattern": "dotted"}, {"category": "chair", "color": "white", "pattern": "plain"}, {"category": "chair", "color": "white", "pattern": "striped"}, {"category": "chair", "color": "white", "pattern": "dotted"}, {"category": "chair", "color": "purple", "pattern": "plain"}, {"category": "chair", "color": "purple", "pattern": "striped"}, {"category": "chair", "color": "purple", "pattern": "dotted"}, {"category": "chair", "color": "orange", "pattern": "plain"}, {"category": "chair", "color": "orange", "pattern": "striped"}, {"category": "chair", "color": "orange", "pattern": "dotted"}, {"category": "lamp", "color": "red", "pattern": "plain"}, {"category": "lamp", "color": "red", "pattern": "striped"}, {"category": "lamp", "color": "red", "pattern": "dotted"}, {"category": "lamp", "color": "blue", "pattern": "plain"}, {"category": "lamp", "color": "blue", "pattern": "striped"}, {"category": "lamp", "color": "blue", "pattern": "dotted"}, {"category": "lamp", "color": "green", "pattern": "plain"}, {"category": "lamp", "color": "green", "pattern": "striped"}, {"category": "lamp", "color": "green", "pattern": "dotted"}, {"category": "lamp", "color": "yellow", "pattern": "plain"}, {"category": "lamp", "color": "yellow", "pattern": "striped"}, {"category": "lamp", "color": "yellow", "pattern": "dotted"}, {"category": "lamp", "color": "black", "pattern": "plain"}, {"category": "lamp", "color": "black", "pattern": "striped"}, {"category": "lamp", "color": "black", "pattern": "dotted"}, {"category": "lamp", "color": "white", "pattern": "plain"}, {"category": "lamp", "color": "white", "pattern": "striped"}, {"category": "lamp", "color": "white", "pattern": "dotted"}, {"category": "lamp", "color": "purple", "pattern": "plain"}, {"category": "lamp", "color": "purple", "pattern": "striped"}, {"category": "lamp", "color": "purple", "pattern": "dotted"}, {"category": "lamp", "color": "orange", "pattern": "plain"}, {"category": "lamp", "color": "orange", "pattern": "striped"}, {"category": "lamp", "color": "orange", "pattern": "dotted"}, {"category": "bottle", "color": "red", "pattern": "plain"}, {"category": "bottle", "color": "red", "pattern": "striped"}, {"category": "bottle", "color": "red", "pattern": "dotted"}, {"category": "bottle", "color": "blue", "pattern": "plain"}, {"category": "bottle", "color": "blue", "pattern": "striped"}, {"category": "bottle", "color": "blue", "pattern": "dotted"}, {"category": "bottle", "color": "green", "pattern": "plain"}, {"category": "bottle", "color": "green", "pattern": "striped"}, {"category": "bottle", "color": "green", "pattern": "dotted"}, {"category": "bottle", "color": "yellow", "pattern": "plain"}, {"category": "bottle", "color": "yellow", "pattern": "striped"}, {"category": "bottle", "color": "yellow", "pattern": "dotted"}, {"category": "bottle", "color": "black", "pattern": "plain"}, {"category": "bottle", "color": "black", "pattern": "striped"}, {"category": "bottle", "color": "black", "pattern": "dotted"}, {"category": "bottle", "color": "white", "pattern": "plain"}, {"category": "bottle", "color": "white", "pattern": "striped"}, {"category": "bottle", "color": "white", "pattern": "dotted"}, {"category": "bottle", "color": "purple", "pattern": "plain"}, {"category": "bottle", "color": "purple", "pattern": "striped"}, {"category": "bottle", "color": "purple", "pattern": "dotted"}, {"category": "bottle", "color": "orange", "pattern": "plain"}, {"category": "bottle", "color": "orange", "pattern": "striped"}, {"category": "bottle", "color": "orange", "pattern": "dotted"}], "heldout_combos": [["bag", "green", "dotted"], ["bag", "green", "plain"], ["bag", "green", "striped"], ["bag", "orange", "dotted"], ["bag", "white", "striped"], ["bottle", "yellow", "dotted"], ["chair", "black", "plain"], ["chair", "green", "dotted"], ["chair", "green", "plain"], ["hat", "green", "plain"], ["lamp", "black", "plain"], ["lamp", "purple", "dotted"], ["lamp", "red", "plain"], ["lamp", "red", "striped"], ["lamp", "white", "striped"], ["mug", "green", "dotted"], ["mug", "orange", "plain"], ["mug", "yellow", "plain"], ["sneaker", "black", "plain"], ["sneaker", "red", "plain"], ["sneaker", "white", "striped"], ["tshirt", "black", "dotted"], ["tshirt", "orange", "plain"], ["tshirt", "red", "striped"]]}
|
catalog.png
ADDED
|
Git LFS Details
|
combined.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d854903eb2fe83b774ca5d1dd66eea40115d822c49a8e6f8d51c8310f889657b
|
| 3 |
+
size 396512
|
evaluation.json
ADDED
|
@@ -0,0 +1,1045 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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+cu130",
|
| 11 |
+
"cuda": true,
|
| 12 |
+
"gpu": "NVIDIA L4",
|
| 13 |
+
"colab": true
|
| 14 |
+
},
|
| 15 |
+
"data": {
|
| 16 |
+
"type": "synthetic catalog rendered by render.py",
|
| 17 |
+
"combinations": 192,
|
| 18 |
+
"heldout_combinations": [
|
| 19 |
+
[
|
| 20 |
+
"bag",
|
| 21 |
+
"green",
|
| 22 |
+
"dotted"
|
| 23 |
+
],
|
| 24 |
+
[
|
| 25 |
+
"bag",
|
| 26 |
+
"green",
|
| 27 |
+
"plain"
|
| 28 |
+
],
|
| 29 |
+
[
|
| 30 |
+
"bag",
|
| 31 |
+
"green",
|
| 32 |
+
"striped"
|
| 33 |
+
],
|
| 34 |
+
[
|
| 35 |
+
"bag",
|
| 36 |
+
"orange",
|
| 37 |
+
"dotted"
|
| 38 |
+
],
|
| 39 |
+
[
|
| 40 |
+
"bag",
|
| 41 |
+
"white",
|
| 42 |
+
"striped"
|
| 43 |
+
],
|
| 44 |
+
[
|
| 45 |
+
"bottle",
|
| 46 |
+
"yellow",
|
| 47 |
+
"dotted"
|
| 48 |
+
],
|
| 49 |
+
[
|
| 50 |
+
"chair",
|
| 51 |
+
"black",
|
| 52 |
+
"plain"
|
| 53 |
+
],
|
| 54 |
+
[
|
| 55 |
+
"chair",
|
| 56 |
+
"green",
|
| 57 |
+
"dotted"
|
| 58 |
+
],
|
| 59 |
+
[
|
| 60 |
+
"chair",
|
| 61 |
+
"green",
|
| 62 |
+
"plain"
|
| 63 |
+
],
|
| 64 |
+
[
|
| 65 |
+
"hat",
|
| 66 |
+
"green",
|
| 67 |
+
"plain"
|
| 68 |
+
],
|
| 69 |
+
[
|
| 70 |
+
"lamp",
|
| 71 |
+
"black",
|
| 72 |
+
"plain"
|
| 73 |
+
],
|
| 74 |
+
[
|
| 75 |
+
"lamp",
|
| 76 |
+
"purple",
|
| 77 |
+
"dotted"
|
| 78 |
+
],
|
| 79 |
+
[
|
| 80 |
+
"lamp",
|
| 81 |
+
"red",
|
| 82 |
+
"plain"
|
| 83 |
+
],
|
| 84 |
+
[
|
| 85 |
+
"lamp",
|
| 86 |
+
"red",
|
| 87 |
+
"striped"
|
| 88 |
+
],
|
| 89 |
+
[
|
| 90 |
+
"lamp",
|
| 91 |
+
"white",
|
| 92 |
+
"striped"
|
| 93 |
+
],
|
| 94 |
+
[
|
| 95 |
+
"mug",
|
| 96 |
+
"green",
|
| 97 |
+
"dotted"
|
| 98 |
+
],
|
| 99 |
+
[
|
| 100 |
+
"mug",
|
| 101 |
+
"orange",
|
| 102 |
+
"plain"
|
| 103 |
+
],
|
| 104 |
+
[
|
| 105 |
+
"mug",
|
| 106 |
+
"yellow",
|
| 107 |
+
"plain"
|
| 108 |
+
],
|
| 109 |
+
[
|
| 110 |
+
"sneaker",
|
| 111 |
+
"black",
|
| 112 |
+
"plain"
|
| 113 |
+
],
|
| 114 |
+
[
|
| 115 |
+
"sneaker",
|
| 116 |
+
"red",
|
| 117 |
+
"plain"
|
| 118 |
+
],
|
| 119 |
+
[
|
| 120 |
+
"sneaker",
|
| 121 |
+
"white",
|
| 122 |
+
"striped"
|
| 123 |
+
],
|
| 124 |
+
[
|
| 125 |
+
"tshirt",
|
| 126 |
+
"black",
|
| 127 |
+
"dotted"
|
| 128 |
+
],
|
| 129 |
+
[
|
| 130 |
+
"tshirt",
|
| 131 |
+
"orange",
|
| 132 |
+
"plain"
|
| 133 |
+
],
|
| 134 |
+
[
|
| 135 |
+
"tshirt",
|
| 136 |
+
"red",
|
| 137 |
+
"striped"
|
| 138 |
+
]
|
| 139 |
+
],
|
| 140 |
+
"train_instances_per_combo": 10,
|
| 141 |
+
"gallery": "1 unseen rendering per combination (seed 2)",
|
| 142 |
+
"references": "unseen renderings (seed 3)",
|
| 143 |
+
"templates": {
|
| 144 |
+
"train": {
|
| 145 |
+
"color": {
|
| 146 |
+
"tr": [
|
| 147 |
+
"bunun {c} olanı",
|
| 148 |
+
"{c} renklisi",
|
| 149 |
+
"aynısının {c} olanı",
|
| 150 |
+
"{c} olsun",
|
| 151 |
+
"rengi {c} olsun"
|
| 152 |
+
],
|
| 153 |
+
"en": [
|
| 154 |
+
"the {c} one",
|
| 155 |
+
"make it {c}",
|
| 156 |
+
"same but {c}",
|
| 157 |
+
"in {c}"
|
| 158 |
+
]
|
| 159 |
+
},
|
| 160 |
+
"pattern": {
|
| 161 |
+
"tr": [
|
| 162 |
+
"{p} olanı",
|
| 163 |
+
"{p} olsun",
|
| 164 |
+
"aynısı ama {p}"
|
| 165 |
+
],
|
| 166 |
+
"en": [
|
| 167 |
+
"the {p} one",
|
| 168 |
+
"make it {p}",
|
| 169 |
+
"same but {p}"
|
| 170 |
+
]
|
| 171 |
+
},
|
| 172 |
+
"category": {
|
| 173 |
+
"tr": [
|
| 174 |
+
"aynısı ama {k}",
|
| 175 |
+
"bunun {k} olanı",
|
| 176 |
+
"aynı desende {k}"
|
| 177 |
+
],
|
| 178 |
+
"en": [
|
| 179 |
+
"same but a {k}",
|
| 180 |
+
"a {k} like this",
|
| 181 |
+
"same style {k}"
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
"color+pattern": {
|
| 185 |
+
"tr": [
|
| 186 |
+
"{c} ve {p} olanı",
|
| 187 |
+
"{p} ve {c} olsun"
|
| 188 |
+
],
|
| 189 |
+
"en": [
|
| 190 |
+
"{c} and {p}",
|
| 191 |
+
"make it {p} and {c}"
|
| 192 |
+
]
|
| 193 |
+
}
|
| 194 |
+
},
|
| 195 |
+
"heldout": {
|
| 196 |
+
"color": {
|
| 197 |
+
"tr": [
|
| 198 |
+
"{c} olanını göster",
|
| 199 |
+
"bundan {c} var mı"
|
| 200 |
+
],
|
| 201 |
+
"en": [
|
| 202 |
+
"show me the {c} one",
|
| 203 |
+
"do you have it in {c}"
|
| 204 |
+
]
|
| 205 |
+
},
|
| 206 |
+
"pattern": {
|
| 207 |
+
"tr": [
|
| 208 |
+
"{p} modelini göster"
|
| 209 |
+
],
|
| 210 |
+
"en": [
|
| 211 |
+
"show a {p} version"
|
| 212 |
+
]
|
| 213 |
+
},
|
| 214 |
+
"category": {
|
| 215 |
+
"tr": [
|
| 216 |
+
"bunun gibi bir {k} istiyorum"
|
| 217 |
+
],
|
| 218 |
+
"en": [
|
| 219 |
+
"I want a {k} like this"
|
| 220 |
+
]
|
| 221 |
+
},
|
| 222 |
+
"color+pattern": {
|
| 223 |
+
"tr": [
|
| 224 |
+
"{c} renkli ve {p} göster"
|
| 225 |
+
],
|
| 226 |
+
"en": [
|
| 227 |
+
"show it {p} in {c}"
|
| 228 |
+
]
|
| 229 |
+
}
|
| 230 |
+
}
|
| 231 |
+
},
|
| 232 |
+
"vocabulary_size": 61
|
| 233 |
+
},
|
| 234 |
+
"training": {
|
| 235 |
+
"combined": {
|
| 236 |
+
"seconds": 161.6,
|
| 237 |
+
"final_loss": 0.5543771022558213,
|
| 238 |
+
"steps": 6000,
|
| 239 |
+
"batch": 128
|
| 240 |
+
},
|
| 241 |
+
"image": {
|
| 242 |
+
"seconds": 158.2,
|
| 243 |
+
"final_loss": 3.290284743309021,
|
| 244 |
+
"steps": 6000,
|
| 245 |
+
"batch": 128
|
| 246 |
+
},
|
| 247 |
+
"text": {
|
| 248 |
+
"seconds": 138.7,
|
| 249 |
+
"final_loss": 2.8225105476379393,
|
| 250 |
+
"steps": 6000,
|
| 251 |
+
"batch": 128
|
| 252 |
+
}
|
| 253 |
+
},
|
| 254 |
+
"budget": "same encoder architecture, batch, steps, optimiser and schedule for all three models",
|
| 255 |
+
"results": {
|
| 256 |
+
"all": {
|
| 257 |
+
"n": 1600,
|
| 258 |
+
"combined": {
|
| 259 |
+
"R@1": 0.9325,
|
| 260 |
+
"R@5": 0.96625,
|
| 261 |
+
"R@10": 0.979375
|
| 262 |
+
},
|
| 263 |
+
"image": {
|
| 264 |
+
"R@1": 0.0,
|
| 265 |
+
"R@5": 0.315625,
|
| 266 |
+
"R@10": 0.578125
|
| 267 |
+
},
|
| 268 |
+
"text": {
|
| 269 |
+
"R@1": 0.054375,
|
| 270 |
+
"R@5": 0.263125,
|
| 271 |
+
"R@10": 0.47125
|
| 272 |
+
}
|
| 273 |
+
},
|
| 274 |
+
"edit=color": {
|
| 275 |
+
"n": 648,
|
| 276 |
+
"combined": {
|
| 277 |
+
"R@1": 0.9938271604938271,
|
| 278 |
+
"R@5": 1.0,
|
| 279 |
+
"R@10": 1.0
|
| 280 |
+
},
|
| 281 |
+
"image": {
|
| 282 |
+
"R@1": 0.0,
|
| 283 |
+
"R@5": 0.35802469135802467,
|
| 284 |
+
"R@10": 0.9583333333333334
|
| 285 |
+
},
|
| 286 |
+
"text": {
|
| 287 |
+
"R@1": 0.05092592592592592,
|
| 288 |
+
"R@5": 0.2175925925925926,
|
| 289 |
+
"R@10": 0.39197530864197533
|
| 290 |
+
}
|
| 291 |
+
},
|
| 292 |
+
"edit=pattern": {
|
| 293 |
+
"n": 311,
|
| 294 |
+
"combined": {
|
| 295 |
+
"R@1": 0.8360128617363344,
|
| 296 |
+
"R@5": 0.8971061093247589,
|
| 297 |
+
"R@10": 0.9356913183279743
|
| 298 |
+
},
|
| 299 |
+
"image": {
|
| 300 |
+
"R@1": 0.0,
|
| 301 |
+
"R@5": 0.8778135048231511,
|
| 302 |
+
"R@10": 0.9678456591639871
|
| 303 |
+
},
|
| 304 |
+
"text": {
|
| 305 |
+
"R@1": 0.01607717041800643,
|
| 306 |
+
"R@5": 0.07395498392282958,
|
| 307 |
+
"R@10": 0.19614147909967847
|
| 308 |
+
}
|
| 309 |
+
},
|
| 310 |
+
"edit=category": {
|
| 311 |
+
"n": 322,
|
| 312 |
+
"combined": {
|
| 313 |
+
"R@1": 1.0,
|
| 314 |
+
"R@5": 1.0,
|
| 315 |
+
"R@10": 1.0
|
| 316 |
+
},
|
| 317 |
+
"image": {
|
| 318 |
+
"R@1": 0.0,
|
| 319 |
+
"R@5": 0.0,
|
| 320 |
+
"R@10": 0.0
|
| 321 |
+
},
|
| 322 |
+
"text": {
|
| 323 |
+
"R@1": 0.031055900621118012,
|
| 324 |
+
"R@5": 0.18322981366459629,
|
| 325 |
+
"R@10": 0.37267080745341613
|
| 326 |
+
}
|
| 327 |
+
},
|
| 328 |
+
"edit=color+pattern": {
|
| 329 |
+
"n": 319,
|
| 330 |
+
"combined": {
|
| 331 |
+
"R@1": 0.8338557993730408,
|
| 332 |
+
"R@5": 0.9310344827586207,
|
| 333 |
+
"R@10": 0.9592476489028213
|
| 334 |
+
},
|
| 335 |
+
"image": {
|
| 336 |
+
"R@1": 0.0,
|
| 337 |
+
"R@5": 0.0,
|
| 338 |
+
"R@10": 0.009404388714733543
|
| 339 |
+
},
|
| 340 |
+
"text": {
|
| 341 |
+
"R@1": 0.12225705329153605,
|
| 342 |
+
"R@5": 0.6206896551724138,
|
| 343 |
+
"R@10": 1.0
|
| 344 |
+
}
|
| 345 |
+
},
|
| 346 |
+
"lang=tr": {
|
| 347 |
+
"n": 747,
|
| 348 |
+
"combined": {
|
| 349 |
+
"R@1": 0.9946452476572959,
|
| 350 |
+
"R@5": 1.0,
|
| 351 |
+
"R@10": 1.0
|
| 352 |
+
},
|
| 353 |
+
"image": {
|
| 354 |
+
"R@1": 0.0,
|
| 355 |
+
"R@5": 0.3172690763052209,
|
| 356 |
+
"R@10": 0.570281124497992
|
| 357 |
+
},
|
| 358 |
+
"text": {
|
| 359 |
+
"R@1": 0.050870147255689425,
|
| 360 |
+
"R@5": 0.2583668005354752,
|
| 361 |
+
"R@10": 0.47523427041499333
|
| 362 |
+
}
|
| 363 |
+
},
|
| 364 |
+
"lang=en": {
|
| 365 |
+
"n": 853,
|
| 366 |
+
"combined": {
|
| 367 |
+
"R@1": 0.8780773739742087,
|
| 368 |
+
"R@5": 0.936694021101993,
|
| 369 |
+
"R@10": 0.9613130128956624
|
| 370 |
+
},
|
| 371 |
+
"image": {
|
| 372 |
+
"R@1": 0.0,
|
| 373 |
+
"R@5": 0.3141852286049238,
|
| 374 |
+
"R@10": 0.5849941383352872
|
| 375 |
+
},
|
| 376 |
+
"text": {
|
| 377 |
+
"R@1": 0.05744431418522861,
|
| 378 |
+
"R@5": 0.2672919109026964,
|
| 379 |
+
"R@10": 0.46776084407971863
|
| 380 |
+
}
|
| 381 |
+
},
|
| 382 |
+
"template=seen": {
|
| 383 |
+
"n": 1104,
|
| 384 |
+
"combined": {
|
| 385 |
+
"R@1": 1.0,
|
| 386 |
+
"R@5": 1.0,
|
| 387 |
+
"R@10": 1.0
|
| 388 |
+
},
|
| 389 |
+
"image": {
|
| 390 |
+
"R@1": 0.0,
|
| 391 |
+
"R@5": 0.3233695652173913,
|
| 392 |
+
"R@10": 0.5769927536231884
|
| 393 |
+
},
|
| 394 |
+
"text": {
|
| 395 |
+
"R@1": 0.057065217391304345,
|
| 396 |
+
"R@5": 0.2509057971014493,
|
| 397 |
+
"R@10": 0.45742753623188404
|
| 398 |
+
}
|
| 399 |
+
},
|
| 400 |
+
"template=held-out": {
|
| 401 |
+
"n": 496,
|
| 402 |
+
"combined": {
|
| 403 |
+
"R@1": 0.782258064516129,
|
| 404 |
+
"R@5": 0.8911290322580645,
|
| 405 |
+
"R@10": 0.9334677419354839
|
| 406 |
+
},
|
| 407 |
+
"image": {
|
| 408 |
+
"R@1": 0.0,
|
| 409 |
+
"R@5": 0.29838709677419356,
|
| 410 |
+
"R@10": 0.5806451612903226
|
| 411 |
+
},
|
| 412 |
+
"text": {
|
| 413 |
+
"R@1": 0.04838709677419355,
|
| 414 |
+
"R@5": 0.2903225806451613,
|
| 415 |
+
"R@10": 0.5020161290322581
|
| 416 |
+
}
|
| 417 |
+
},
|
| 418 |
+
"combo=seen": {
|
| 419 |
+
"n": 1192,
|
| 420 |
+
"combined": {
|
| 421 |
+
"R@1": 0.9328859060402684,
|
| 422 |
+
"R@5": 0.9664429530201343,
|
| 423 |
+
"R@10": 0.9773489932885906
|
| 424 |
+
},
|
| 425 |
+
"image": {
|
| 426 |
+
"R@1": 0.0,
|
| 427 |
+
"R@5": 0.34815436241610737,
|
| 428 |
+
"R@10": 0.5956375838926175
|
| 429 |
+
},
|
| 430 |
+
"text": {
|
| 431 |
+
"R@1": 0.05704697986577181,
|
| 432 |
+
"R@5": 0.2961409395973154,
|
| 433 |
+
"R@10": 0.5016778523489933
|
| 434 |
+
}
|
| 435 |
+
},
|
| 436 |
+
"combo=held-out": {
|
| 437 |
+
"n": 408,
|
| 438 |
+
"combined": {
|
| 439 |
+
"R@1": 0.9313725490196079,
|
| 440 |
+
"R@5": 0.9656862745098039,
|
| 441 |
+
"R@10": 0.9852941176470589
|
| 442 |
+
},
|
| 443 |
+
"image": {
|
| 444 |
+
"R@1": 0.0,
|
| 445 |
+
"R@5": 0.22058823529411764,
|
| 446 |
+
"R@10": 0.5269607843137255
|
| 447 |
+
},
|
| 448 |
+
"text": {
|
| 449 |
+
"R@1": 0.04656862745098039,
|
| 450 |
+
"R@5": 0.16666666666666666,
|
| 451 |
+
"R@10": 0.38235294117647056
|
| 452 |
+
}
|
| 453 |
+
}
|
| 454 |
+
},
|
| 455 |
+
"failure_examples_combined": [
|
| 456 |
+
{
|
| 457 |
+
"ref": [
|
| 458 |
+
"lamp",
|
| 459 |
+
"black",
|
| 460 |
+
"striped"
|
| 461 |
+
],
|
| 462 |
+
"target": [
|
| 463 |
+
"lamp",
|
| 464 |
+
"black",
|
| 465 |
+
"plain"
|
| 466 |
+
],
|
| 467 |
+
"text": "show a plain version",
|
| 468 |
+
"kind": "pattern",
|
| 469 |
+
"lang": "en",
|
| 470 |
+
"heldout_template": true,
|
| 471 |
+
"unseen_combo": true,
|
| 472 |
+
"rank_combined": 15
|
| 473 |
+
},
|
| 474 |
+
{
|
| 475 |
+
"ref": [
|
| 476 |
+
"mug",
|
| 477 |
+
"blue",
|
| 478 |
+
"dotted"
|
| 479 |
+
],
|
| 480 |
+
"target": [
|
| 481 |
+
"mug",
|
| 482 |
+
"blue",
|
| 483 |
+
"striped"
|
| 484 |
+
],
|
| 485 |
+
"text": "show a striped version",
|
| 486 |
+
"kind": "pattern",
|
| 487 |
+
"lang": "en",
|
| 488 |
+
"heldout_template": true,
|
| 489 |
+
"unseen_combo": false,
|
| 490 |
+
"rank_combined": 53
|
| 491 |
+
},
|
| 492 |
+
{
|
| 493 |
+
"ref": [
|
| 494 |
+
"hat",
|
| 495 |
+
"yellow",
|
| 496 |
+
"dotted"
|
| 497 |
+
],
|
| 498 |
+
"target": [
|
| 499 |
+
"hat",
|
| 500 |
+
"black",
|
| 501 |
+
"striped"
|
| 502 |
+
],
|
| 503 |
+
"text": "show it striped in black",
|
| 504 |
+
"kind": "color+pattern",
|
| 505 |
+
"lang": "en",
|
| 506 |
+
"heldout_template": true,
|
| 507 |
+
"unseen_combo": false,
|
| 508 |
+
"rank_combined": 16
|
| 509 |
+
},
|
| 510 |
+
{
|
| 511 |
+
"ref": [
|
| 512 |
+
"mug",
|
| 513 |
+
"blue",
|
| 514 |
+
"dotted"
|
| 515 |
+
],
|
| 516 |
+
"target": [
|
| 517 |
+
"mug",
|
| 518 |
+
"blue",
|
| 519 |
+
"striped"
|
| 520 |
+
],
|
| 521 |
+
"text": "show a striped version",
|
| 522 |
+
"kind": "pattern",
|
| 523 |
+
"lang": "en",
|
| 524 |
+
"heldout_template": true,
|
| 525 |
+
"unseen_combo": false,
|
| 526 |
+
"rank_combined": 53
|
| 527 |
+
},
|
| 528 |
+
{
|
| 529 |
+
"ref": [
|
| 530 |
+
"bag",
|
| 531 |
+
"black",
|
| 532 |
+
"dotted"
|
| 533 |
+
],
|
| 534 |
+
"target": [
|
| 535 |
+
"bag",
|
| 536 |
+
"orange",
|
| 537 |
+
"striped"
|
| 538 |
+
],
|
| 539 |
+
"text": "show it striped in orange",
|
| 540 |
+
"kind": "color+pattern",
|
| 541 |
+
"lang": "en",
|
| 542 |
+
"heldout_template": true,
|
| 543 |
+
"unseen_combo": false,
|
| 544 |
+
"rank_combined": 8
|
| 545 |
+
},
|
| 546 |
+
{
|
| 547 |
+
"ref": [
|
| 548 |
+
"bottle",
|
| 549 |
+
"green",
|
| 550 |
+
"plain"
|
| 551 |
+
],
|
| 552 |
+
"target": [
|
| 553 |
+
"bottle",
|
| 554 |
+
"white",
|
| 555 |
+
"striped"
|
| 556 |
+
],
|
| 557 |
+
"text": "show it striped in white",
|
| 558 |
+
"kind": "color+pattern",
|
| 559 |
+
"lang": "en",
|
| 560 |
+
"heldout_template": true,
|
| 561 |
+
"unseen_combo": false,
|
| 562 |
+
"rank_combined": 50
|
| 563 |
+
},
|
| 564 |
+
{
|
| 565 |
+
"ref": [
|
| 566 |
+
"bag",
|
| 567 |
+
"red",
|
| 568 |
+
"plain"
|
| 569 |
+
],
|
| 570 |
+
"target": [
|
| 571 |
+
"bag",
|
| 572 |
+
"red",
|
| 573 |
+
"striped"
|
| 574 |
+
],
|
| 575 |
+
"text": "show a striped version",
|
| 576 |
+
"kind": "pattern",
|
| 577 |
+
"lang": "en",
|
| 578 |
+
"heldout_template": true,
|
| 579 |
+
"unseen_combo": false,
|
| 580 |
+
"rank_combined": 64
|
| 581 |
+
},
|
| 582 |
+
{
|
| 583 |
+
"ref": [
|
| 584 |
+
"hat",
|
| 585 |
+
"purple",
|
| 586 |
+
"striped"
|
| 587 |
+
],
|
| 588 |
+
"target": [
|
| 589 |
+
"hat",
|
| 590 |
+
"purple",
|
| 591 |
+
"plain"
|
| 592 |
+
],
|
| 593 |
+
"text": "show a plain version",
|
| 594 |
+
"kind": "pattern",
|
| 595 |
+
"lang": "en",
|
| 596 |
+
"heldout_template": true,
|
| 597 |
+
"unseen_combo": false,
|
| 598 |
+
"rank_combined": 25
|
| 599 |
+
},
|
| 600 |
+
{
|
| 601 |
+
"ref": [
|
| 602 |
+
"bottle",
|
| 603 |
+
"green",
|
| 604 |
+
"plain"
|
| 605 |
+
],
|
| 606 |
+
"target": [
|
| 607 |
+
"bottle",
|
| 608 |
+
"white",
|
| 609 |
+
"striped"
|
| 610 |
+
],
|
| 611 |
+
"text": "show it striped in white",
|
| 612 |
+
"kind": "color+pattern",
|
| 613 |
+
"lang": "en",
|
| 614 |
+
"heldout_template": true,
|
| 615 |
+
"unseen_combo": false,
|
| 616 |
+
"rank_combined": 50
|
| 617 |
+
},
|
| 618 |
+
{
|
| 619 |
+
"ref": [
|
| 620 |
+
"bag",
|
| 621 |
+
"purple",
|
| 622 |
+
"dotted"
|
| 623 |
+
],
|
| 624 |
+
"target": [
|
| 625 |
+
"bag",
|
| 626 |
+
"green",
|
| 627 |
+
"striped"
|
| 628 |
+
],
|
| 629 |
+
"text": "show it striped in green",
|
| 630 |
+
"kind": "color+pattern",
|
| 631 |
+
"lang": "en",
|
| 632 |
+
"heldout_template": true,
|
| 633 |
+
"unseen_combo": true,
|
| 634 |
+
"rank_combined": 6
|
| 635 |
+
},
|
| 636 |
+
{
|
| 637 |
+
"ref": [
|
| 638 |
+
"mug",
|
| 639 |
+
"red",
|
| 640 |
+
"dotted"
|
| 641 |
+
],
|
| 642 |
+
"target": [
|
| 643 |
+
"mug",
|
| 644 |
+
"red",
|
| 645 |
+
"striped"
|
| 646 |
+
],
|
| 647 |
+
"text": "show a striped version",
|
| 648 |
+
"kind": "pattern",
|
| 649 |
+
"lang": "en",
|
| 650 |
+
"heldout_template": true,
|
| 651 |
+
"unseen_combo": false,
|
| 652 |
+
"rank_combined": 28
|
| 653 |
+
},
|
| 654 |
+
{
|
| 655 |
+
"ref": [
|
| 656 |
+
"sneaker",
|
| 657 |
+
"white",
|
| 658 |
+
"plain"
|
| 659 |
+
],
|
| 660 |
+
"target": [
|
| 661 |
+
"sneaker",
|
| 662 |
+
"white",
|
| 663 |
+
"striped"
|
| 664 |
+
],
|
| 665 |
+
"text": "show a striped version",
|
| 666 |
+
"kind": "pattern",
|
| 667 |
+
"lang": "en",
|
| 668 |
+
"heldout_template": true,
|
| 669 |
+
"unseen_combo": true,
|
| 670 |
+
"rank_combined": 60
|
| 671 |
+
},
|
| 672 |
+
{
|
| 673 |
+
"ref": [
|
| 674 |
+
"hat",
|
| 675 |
+
"red",
|
| 676 |
+
"dotted"
|
| 677 |
+
],
|
| 678 |
+
"target": [
|
| 679 |
+
"hat",
|
| 680 |
+
"black",
|
| 681 |
+
"striped"
|
| 682 |
+
],
|
| 683 |
+
"text": "show it striped in black",
|
| 684 |
+
"kind": "color+pattern",
|
| 685 |
+
"lang": "en",
|
| 686 |
+
"heldout_template": true,
|
| 687 |
+
"unseen_combo": false,
|
| 688 |
+
"rank_combined": 5
|
| 689 |
+
},
|
| 690 |
+
{
|
| 691 |
+
"ref": [
|
| 692 |
+
"bottle",
|
| 693 |
+
"purple",
|
| 694 |
+
"dotted"
|
| 695 |
+
],
|
| 696 |
+
"target": [
|
| 697 |
+
"bottle",
|
| 698 |
+
"purple",
|
| 699 |
+
"striped"
|
| 700 |
+
],
|
| 701 |
+
"text": "show a striped version",
|
| 702 |
+
"kind": "pattern",
|
| 703 |
+
"lang": "en",
|
| 704 |
+
"heldout_template": true,
|
| 705 |
+
"unseen_combo": false,
|
| 706 |
+
"rank_combined": 8
|
| 707 |
+
},
|
| 708 |
+
{
|
| 709 |
+
"ref": [
|
| 710 |
+
"bag",
|
| 711 |
+
"blue",
|
| 712 |
+
"dotted"
|
| 713 |
+
],
|
| 714 |
+
"target": [
|
| 715 |
+
"bag",
|
| 716 |
+
"blue",
|
| 717 |
+
"plain"
|
| 718 |
+
],
|
| 719 |
+
"text": "show a plain version",
|
| 720 |
+
"kind": "pattern",
|
| 721 |
+
"lang": "en",
|
| 722 |
+
"heldout_template": true,
|
| 723 |
+
"unseen_combo": false,
|
| 724 |
+
"rank_combined": 22
|
| 725 |
+
},
|
| 726 |
+
{
|
| 727 |
+
"ref": [
|
| 728 |
+
"sneaker",
|
| 729 |
+
"red",
|
| 730 |
+
"striped"
|
| 731 |
+
],
|
| 732 |
+
"target": [
|
| 733 |
+
"sneaker",
|
| 734 |
+
"red",
|
| 735 |
+
"plain"
|
| 736 |
+
],
|
| 737 |
+
"text": "show a plain version",
|
| 738 |
+
"kind": "pattern",
|
| 739 |
+
"lang": "en",
|
| 740 |
+
"heldout_template": true,
|
| 741 |
+
"unseen_combo": true,
|
| 742 |
+
"rank_combined": 6
|
| 743 |
+
},
|
| 744 |
+
{
|
| 745 |
+
"ref": [
|
| 746 |
+
"mug",
|
| 747 |
+
"red",
|
| 748 |
+
"striped"
|
| 749 |
+
],
|
| 750 |
+
"target": [
|
| 751 |
+
"mug",
|
| 752 |
+
"red",
|
| 753 |
+
"plain"
|
| 754 |
+
],
|
| 755 |
+
"text": "show a plain version",
|
| 756 |
+
"kind": "pattern",
|
| 757 |
+
"lang": "en",
|
| 758 |
+
"heldout_template": true,
|
| 759 |
+
"unseen_combo": false,
|
| 760 |
+
"rank_combined": 73
|
| 761 |
+
},
|
| 762 |
+
{
|
| 763 |
+
"ref": [
|
| 764 |
+
"mug",
|
| 765 |
+
"purple",
|
| 766 |
+
"dotted"
|
| 767 |
+
],
|
| 768 |
+
"target": [
|
| 769 |
+
"mug",
|
| 770 |
+
"purple",
|
| 771 |
+
"plain"
|
| 772 |
+
],
|
| 773 |
+
"text": "show a plain version",
|
| 774 |
+
"kind": "pattern",
|
| 775 |
+
"lang": "en",
|
| 776 |
+
"heldout_template": true,
|
| 777 |
+
"unseen_combo": false,
|
| 778 |
+
"rank_combined": 125
|
| 779 |
+
},
|
| 780 |
+
{
|
| 781 |
+
"ref": [
|
| 782 |
+
"mug",
|
| 783 |
+
"red",
|
| 784 |
+
"dotted"
|
| 785 |
+
],
|
| 786 |
+
"target": [
|
| 787 |
+
"mug",
|
| 788 |
+
"red",
|
| 789 |
+
"plain"
|
| 790 |
+
],
|
| 791 |
+
"text": "show a plain version",
|
| 792 |
+
"kind": "pattern",
|
| 793 |
+
"lang": "en",
|
| 794 |
+
"heldout_template": true,
|
| 795 |
+
"unseen_combo": false,
|
| 796 |
+
"rank_combined": 89
|
| 797 |
+
},
|
| 798 |
+
{
|
| 799 |
+
"ref": [
|
| 800 |
+
"sneaker",
|
| 801 |
+
"green",
|
| 802 |
+
"striped"
|
| 803 |
+
],
|
| 804 |
+
"target": [
|
| 805 |
+
"sneaker",
|
| 806 |
+
"green",
|
| 807 |
+
"dotted"
|
| 808 |
+
],
|
| 809 |
+
"text": "show a dotted version",
|
| 810 |
+
"kind": "pattern",
|
| 811 |
+
"lang": "en",
|
| 812 |
+
"heldout_template": true,
|
| 813 |
+
"unseen_combo": false,
|
| 814 |
+
"rank_combined": 8
|
| 815 |
+
},
|
| 816 |
+
{
|
| 817 |
+
"ref": [
|
| 818 |
+
"lamp",
|
| 819 |
+
"red",
|
| 820 |
+
"dotted"
|
| 821 |
+
],
|
| 822 |
+
"target": [
|
| 823 |
+
"lamp",
|
| 824 |
+
"black",
|
| 825 |
+
"striped"
|
| 826 |
+
],
|
| 827 |
+
"text": "show it striped in black",
|
| 828 |
+
"kind": "color+pattern",
|
| 829 |
+
"lang": "en",
|
| 830 |
+
"heldout_template": true,
|
| 831 |
+
"unseen_combo": false,
|
| 832 |
+
"rank_combined": 5
|
| 833 |
+
},
|
| 834 |
+
{
|
| 835 |
+
"ref": [
|
| 836 |
+
"tshirt",
|
| 837 |
+
"white",
|
| 838 |
+
"plain"
|
| 839 |
+
],
|
| 840 |
+
"target": [
|
| 841 |
+
"tshirt",
|
| 842 |
+
"white",
|
| 843 |
+
"striped"
|
| 844 |
+
],
|
| 845 |
+
"text": "show a striped version",
|
| 846 |
+
"kind": "pattern",
|
| 847 |
+
"lang": "en",
|
| 848 |
+
"heldout_template": true,
|
| 849 |
+
"unseen_combo": false,
|
| 850 |
+
"rank_combined": 15
|
| 851 |
+
},
|
| 852 |
+
{
|
| 853 |
+
"ref": [
|
| 854 |
+
"sneaker",
|
| 855 |
+
"black",
|
| 856 |
+
"dotted"
|
| 857 |
+
],
|
| 858 |
+
"target": [
|
| 859 |
+
"sneaker",
|
| 860 |
+
"black",
|
| 861 |
+
"striped"
|
| 862 |
+
],
|
| 863 |
+
"text": "show a striped version",
|
| 864 |
+
"kind": "pattern",
|
| 865 |
+
"lang": "en",
|
| 866 |
+
"heldout_template": true,
|
| 867 |
+
"unseen_combo": false,
|
| 868 |
+
"rank_combined": 80
|
| 869 |
+
},
|
| 870 |
+
{
|
| 871 |
+
"ref": [
|
| 872 |
+
"bottle",
|
| 873 |
+
"black",
|
| 874 |
+
"plain"
|
| 875 |
+
],
|
| 876 |
+
"target": [
|
| 877 |
+
"bottle",
|
| 878 |
+
"blue",
|
| 879 |
+
"striped"
|
| 880 |
+
],
|
| 881 |
+
"text": "show it striped in blue",
|
| 882 |
+
"kind": "color+pattern",
|
| 883 |
+
"lang": "en",
|
| 884 |
+
"heldout_template": true,
|
| 885 |
+
"unseen_combo": false,
|
| 886 |
+
"rank_combined": 23
|
| 887 |
+
},
|
| 888 |
+
{
|
| 889 |
+
"ref": [
|
| 890 |
+
"chair",
|
| 891 |
+
"black",
|
| 892 |
+
"striped"
|
| 893 |
+
],
|
| 894 |
+
"target": [
|
| 895 |
+
"chair",
|
| 896 |
+
"black",
|
| 897 |
+
"plain"
|
| 898 |
+
],
|
| 899 |
+
"text": "show a plain version",
|
| 900 |
+
"kind": "pattern",
|
| 901 |
+
"lang": "en",
|
| 902 |
+
"heldout_template": true,
|
| 903 |
+
"unseen_combo": true,
|
| 904 |
+
"rank_combined": 6
|
| 905 |
+
},
|
| 906 |
+
{
|
| 907 |
+
"ref": [
|
| 908 |
+
"sneaker",
|
| 909 |
+
"blue",
|
| 910 |
+
"plain"
|
| 911 |
+
],
|
| 912 |
+
"target": [
|
| 913 |
+
"sneaker",
|
| 914 |
+
"blue",
|
| 915 |
+
"striped"
|
| 916 |
+
],
|
| 917 |
+
"text": "show a striped version",
|
| 918 |
+
"kind": "pattern",
|
| 919 |
+
"lang": "en",
|
| 920 |
+
"heldout_template": true,
|
| 921 |
+
"unseen_combo": false,
|
| 922 |
+
"rank_combined": 57
|
| 923 |
+
},
|
| 924 |
+
{
|
| 925 |
+
"ref": [
|
| 926 |
+
"chair",
|
| 927 |
+
"orange",
|
| 928 |
+
"striped"
|
| 929 |
+
],
|
| 930 |
+
"target": [
|
| 931 |
+
"chair",
|
| 932 |
+
"orange",
|
| 933 |
+
"plain"
|
| 934 |
+
],
|
| 935 |
+
"text": "show a plain version",
|
| 936 |
+
"kind": "pattern",
|
| 937 |
+
"lang": "en",
|
| 938 |
+
"heldout_template": true,
|
| 939 |
+
"unseen_combo": false,
|
| 940 |
+
"rank_combined": 10
|
| 941 |
+
},
|
| 942 |
+
{
|
| 943 |
+
"ref": [
|
| 944 |
+
"bag",
|
| 945 |
+
"green",
|
| 946 |
+
"dotted"
|
| 947 |
+
],
|
| 948 |
+
"target": [
|
| 949 |
+
"bag",
|
| 950 |
+
"green",
|
| 951 |
+
"plain"
|
| 952 |
+
],
|
| 953 |
+
"text": "show a plain version",
|
| 954 |
+
"kind": "pattern",
|
| 955 |
+
"lang": "en",
|
| 956 |
+
"heldout_template": true,
|
| 957 |
+
"unseen_combo": true,
|
| 958 |
+
"rank_combined": 11
|
| 959 |
+
},
|
| 960 |
+
{
|
| 961 |
+
"ref": [
|
| 962 |
+
"sneaker",
|
| 963 |
+
"yellow",
|
| 964 |
+
"dotted"
|
| 965 |
+
],
|
| 966 |
+
"target": [
|
| 967 |
+
"sneaker",
|
| 968 |
+
"orange",
|
| 969 |
+
"striped"
|
| 970 |
+
],
|
| 971 |
+
"text": "show it striped in orange",
|
| 972 |
+
"kind": "color+pattern",
|
| 973 |
+
"lang": "en",
|
| 974 |
+
"heldout_template": true,
|
| 975 |
+
"unseen_combo": false,
|
| 976 |
+
"rank_combined": 24
|
| 977 |
+
},
|
| 978 |
+
{
|
| 979 |
+
"ref": [
|
| 980 |
+
"hat",
|
| 981 |
+
"orange",
|
| 982 |
+
"dotted"
|
| 983 |
+
],
|
| 984 |
+
"target": [
|
| 985 |
+
"hat",
|
| 986 |
+
"white",
|
| 987 |
+
"striped"
|
| 988 |
+
],
|
| 989 |
+
"text": "show it striped in white",
|
| 990 |
+
"kind": "color+pattern",
|
| 991 |
+
"lang": "en",
|
| 992 |
+
"heldout_template": true,
|
| 993 |
+
"unseen_combo": false,
|
| 994 |
+
"rank_combined": 12
|
| 995 |
+
}
|
| 996 |
+
],
|
| 997 |
+
"tests": {
|
| 998 |
+
"reload": {
|
| 999 |
+
"returncode": 0,
|
| 1000 |
+
"seconds": 0.24,
|
| 1001 |
+
"process": "fresh python -E subprocess, cwd = temporary copy of the model folder",
|
| 1002 |
+
"passed": true,
|
| 1003 |
+
"cases": 6,
|
| 1004 |
+
"mismatches": []
|
| 1005 |
+
},
|
| 1006 |
+
"node_parity": {
|
| 1007 |
+
"cases": 6,
|
| 1008 |
+
"failed": 0,
|
| 1009 |
+
"maxDiff": 1.6653345369377348e-16,
|
| 1010 |
+
"results": [
|
| 1011 |
+
{
|
| 1012 |
+
"name": "28:bunun kırmızı olanı",
|
| 1013 |
+
"maxDiff": 1.3877787807814457e-17
|
| 1014 |
+
},
|
| 1015 |
+
{
|
| 1016 |
+
"name": "17:çizgili olanı",
|
| 1017 |
+
"maxDiff": 5.551115123125783e-17
|
| 1018 |
+
},
|
| 1019 |
+
{
|
| 1020 |
+
"name": "102:same but a lamp",
|
| 1021 |
+
"maxDiff": 2.7755575615628914e-17
|
| 1022 |
+
},
|
| 1023 |
+
{
|
| 1024 |
+
"name": "84:make it dotted and yellow",
|
| 1025 |
+
"maxDiff": 1.249000902703301e-16
|
| 1026 |
+
},
|
| 1027 |
+
{
|
| 1028 |
+
"name": "190:İSTİYORUM, mor!",
|
| 1029 |
+
"maxDiff": 2.949029909160572e-17
|
| 1030 |
+
},
|
| 1031 |
+
{
|
| 1032 |
+
"name": "122:",
|
| 1033 |
+
"maxDiff": 1.6653345369377348e-16
|
| 1034 |
+
}
|
| 1035 |
+
],
|
| 1036 |
+
"ms": 749,
|
| 1037 |
+
"runtime": "node v22.23.4",
|
| 1038 |
+
"status": "passed"
|
| 1039 |
+
},
|
| 1040 |
+
"browser": {
|
| 1041 |
+
"status": "skipped",
|
| 1042 |
+
"reason": "playwright not installed"
|
| 1043 |
+
}
|
| 1044 |
+
}
|
| 1045 |
+
}
|
image.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78938b999126b7e88a9a90d8aebefc7099fba62a351be66f6876a67b222e4460
|
| 3 |
+
size 297432
|
inference.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Next Match inference (NumPy only): rank catalog items for a reference image plus a text edit.
|
| 2 |
+
|
| 3 |
+
Usage:
|
| 4 |
+
python inference.py --selftest
|
| 5 |
+
from inference import load, search
|
| 6 |
+
ids = search(spec, ref_image_uint8_hwc, "bunun kırmızı olanı")
|
| 7 |
+
"""
|
| 8 |
+
import json
|
| 9 |
+
import os
|
| 10 |
+
import sys
|
| 11 |
+
|
| 12 |
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 13 |
+
sys.path.insert(0, HERE)
|
| 14 |
+
|
| 15 |
+
import numpy as np # noqa: E402
|
| 16 |
+
|
| 17 |
+
import match_core as mc # noqa: E402
|
| 18 |
+
from nlrt import load_model # noqa: E402
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def load(path=os.path.join(HERE, "model.json")):
|
| 22 |
+
return load_model(path)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def to_chw(img_uint8_hwc):
|
| 26 |
+
return np.asarray(img_uint8_hwc, dtype=np.float64).transpose(2, 0, 1) / 255.0
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def search(spec, ref_image, text, mode="combined", top=10, keys=None):
|
| 30 |
+
"""ref_image: (48, 48, 3) uint8. Returns catalog indices (into the released catalog) best first."""
|
| 31 |
+
q = mc.encode_query(spec, to_chw(ref_image), text, mode)
|
| 32 |
+
name = {"combined": "gallery_keys", "image": "gallery_keys_img_only", "text": "gallery_keys_txt_only"}[mode]
|
| 33 |
+
K = spec["tensors"][name] if keys is None else keys
|
| 34 |
+
s = K @ q
|
| 35 |
+
return sorted(range(len(s)), key=lambda i: (-s[i], i))[:top]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def _selftest():
|
| 39 |
+
spec = load()
|
| 40 |
+
with open(os.path.join(HERE, "selftest.json"), encoding="utf-8") as f:
|
| 41 |
+
cases = json.load(f)["cases"]
|
| 42 |
+
bad = []
|
| 43 |
+
for c in cases:
|
| 44 |
+
img = np.asarray(c["pixels"], dtype=np.uint8).reshape(3, 48, 48).transpose(1, 2, 0)
|
| 45 |
+
got = {m: search(spec, img, c["text"], m, 5) for m in ("combined", "image", "text")}
|
| 46 |
+
if got != c["expected"]:
|
| 47 |
+
bad.append({"text": c["text"], "got": got, "expected": c["expected"]})
|
| 48 |
+
print(json.dumps({"passed": not bad, "cases": len(cases), "mismatches": bad[:2]}, ensure_ascii=False))
|
| 49 |
+
return not bad
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
if __name__ == "__main__":
|
| 53 |
+
if "--selftest" in sys.argv:
|
| 54 |
+
sys.exit(0 if _selftest() else 1)
|
| 55 |
+
print(__doc__)
|
match_core.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Next Match: search a catalog with a reference image plus a text edit ("bunun kirmizi olani", "same but striped").
|
| 2 |
+
|
| 3 |
+
Shared by the notebook, inference.py and (ported) web/core.js:
|
| 4 |
+
* tokenize: Turkish-aware lower-casing, punctuation removal, longest-prefix stem matching against a fixed vocabulary
|
| 5 |
+
* encode_query: image features + text features -> fused, L2-normalised query vector
|
| 6 |
+
* encode_item: catalog image -> L2-normalised key vector
|
| 7 |
+
The catalog is synthetic: procedurally drawn product icons (8 categories x 8 colours x 3 patterns), rendered in the notebook.
|
| 8 |
+
"""
|
| 9 |
+
import numpy as np
|
| 10 |
+
|
| 11 |
+
from nlrt import forward
|
| 12 |
+
|
| 13 |
+
CATEGORIES = ["tshirt", "mug", "sneaker", "bag", "hat", "chair", "lamp", "bottle"]
|
| 14 |
+
COLORS = ["red", "blue", "green", "yellow", "black", "white", "purple", "orange"]
|
| 15 |
+
PATTERNS = ["plain", "striped", "dotted"]
|
| 16 |
+
RGB = {"red": (214, 40, 40), "blue": (40, 90, 210), "green": (40, 160, 70), "yellow": (240, 200, 30),
|
| 17 |
+
"black": (30, 30, 34), "white": (250, 250, 250), "purple": (130, 60, 170), "orange": (245, 130, 30)}
|
| 18 |
+
TR = {"red": "kırmızı", "blue": "mavi", "green": "yeşil", "yellow": "sarı", "black": "siyah", "white": "beyaz", "purple": "mor",
|
| 19 |
+
"orange": "turuncu", "plain": "düz", "striped": "çizgili", "dotted": "puantiyeli", "tshirt": "tişört", "mug": "kupa",
|
| 20 |
+
"sneaker": "ayakkabı", "bag": "çanta", "hat": "şapka", "chair": "sandalye", "lamp": "lamba", "bottle": "şişe"}
|
| 21 |
+
EN = {"tshirt": "t-shirt", "mug": "mug", "sneaker": "sneaker", "bag": "bag", "hat": "hat", "chair": "chair", "lamp": "lamp", "bottle": "bottle",
|
| 22 |
+
"plain": "plain", "striped": "striped", "dotted": "dotted"}
|
| 23 |
+
SYNONYMS = {"tshirt": ["tshirt", "shirt", "tee"], "dotted": ["dotted", "dots", "polka"], "striped": ["striped", "stripes", "stripe"],
|
| 24 |
+
"sneaker": ["sneaker", "shoe", "shoes"], "plain": ["plain", "solid"]}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def lower_tr(s):
|
| 28 |
+
return s.replace("I", "ı").replace("İ", "i").lower()
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def tokenize(text, vocab):
|
| 32 |
+
"""Return token ids (unknown words dropped). Matches whole words, then the longest vocabulary prefix of >= 4 letters."""
|
| 33 |
+
clean = "".join(ch if (ch.isalnum() or ch == " ") else " " for ch in lower_tr(text).replace("-", ""))
|
| 34 |
+
ids = []
|
| 35 |
+
for w in clean.split():
|
| 36 |
+
if w in vocab:
|
| 37 |
+
ids.append(vocab[w])
|
| 38 |
+
continue
|
| 39 |
+
best = None
|
| 40 |
+
for k in range(len(w) - 1, 3, -1):
|
| 41 |
+
if w[:k] in vocab:
|
| 42 |
+
best = vocab[w[:k]]
|
| 43 |
+
break
|
| 44 |
+
if best is not None:
|
| 45 |
+
ids.append(best)
|
| 46 |
+
return ids
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def text_vector(ids, emb):
|
| 50 |
+
if not ids:
|
| 51 |
+
return np.zeros(emb.shape[1])
|
| 52 |
+
return np.mean(emb[ids], axis=0)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def l2n(x):
|
| 56 |
+
return x / max(float(np.linalg.norm(x)), 1e-12)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def image_features(spec, images, net="img"):
|
| 60 |
+
"""images: (N, 3, 48, 48) floats in [0, 1]."""
|
| 61 |
+
return forward(spec["nets"][net], np.asarray(images, dtype=np.float64))
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def encode_item(spec, images, net="img"):
|
| 65 |
+
f = image_features(spec, images, net)
|
| 66 |
+
return f / np.maximum(np.linalg.norm(f, axis=1, keepdims=True), 1e-12)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def encode_query(spec, image, text, mode="combined"):
|
| 70 |
+
"""mode: combined | image | text. image: (3, 48, 48) in [0, 1]."""
|
| 71 |
+
vocab = spec["meta"]["vocab"]
|
| 72 |
+
if mode == "combined":
|
| 73 |
+
fi = image_features(spec, image[None], "img")[0]
|
| 74 |
+
ft = forward(spec["nets"]["txt"], text_vector(tokenize(text, vocab), spec["tensors"]["emb"])[None])[0]
|
| 75 |
+
return l2n(fi + forward(spec["nets"]["fuse"], np.concatenate([fi, ft])[None])[0])
|
| 76 |
+
if mode == "image":
|
| 77 |
+
return l2n(forward(spec["nets"]["img_only_head"], image_features(spec, image[None], "img_only")[0][None])[0])
|
| 78 |
+
ft = forward(spec["nets"]["txt_only"], text_vector(tokenize(text, vocab), spec["tensors"]["emb_only"])[None])[0]
|
| 79 |
+
return l2n(ft)
|
model.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
nlrt.py
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""nlrt: tiny portable runtime shared by Next Lab models.
|
| 2 |
+
|
| 3 |
+
The same layer list runs in NumPy (this file) and in the browser (nlrt.js).
|
| 4 |
+
Weights are stored as base64 little-endian float32 inside model.json.
|
| 5 |
+
Only NumPy is required to load and run a model.
|
| 6 |
+
"""
|
| 7 |
+
import base64
|
| 8 |
+
import json
|
| 9 |
+
import math
|
| 10 |
+
|
| 11 |
+
import numpy as np
|
| 12 |
+
|
| 13 |
+
__all__ = ["b64e", "b64d", "forward", "load_model", "Mulberry32", "export_sequential"]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def b64e(a):
|
| 17 |
+
return base64.b64encode(np.ascontiguousarray(a, dtype="<f4").tobytes()).decode("ascii")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def b64d(s, shape=None):
|
| 21 |
+
a = np.frombuffer(base64.b64decode(s), dtype="<f4").astype(np.float64)
|
| 22 |
+
return a.reshape(shape) if shape is not None else a
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def load_model(path):
|
| 26 |
+
with open(path, "r", encoding="utf-8") as f:
|
| 27 |
+
spec = json.load(f)
|
| 28 |
+
for net in spec.get("nets", {}).values():
|
| 29 |
+
_decode(net)
|
| 30 |
+
for k, v in list(spec.get("tensors", {}).items()):
|
| 31 |
+
spec["tensors"][k] = b64d(v["data"], v["shape"])
|
| 32 |
+
return spec
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def _decode(layers):
|
| 36 |
+
for L in layers:
|
| 37 |
+
for key in ("w", "b"):
|
| 38 |
+
if key in L and isinstance(L[key], str):
|
| 39 |
+
L[key] = b64d(L[key], L.get(key + "_shape"))
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class Mulberry32:
|
| 43 |
+
"""Deterministic PRNG with an identical JavaScript twin in nlrt.js."""
|
| 44 |
+
|
| 45 |
+
def __init__(self, seed):
|
| 46 |
+
self.a = seed & 0xFFFFFFFF
|
| 47 |
+
|
| 48 |
+
def random(self):
|
| 49 |
+
self.a = (self.a + 0x6D2B79F5) & 0xFFFFFFFF
|
| 50 |
+
t = self.a
|
| 51 |
+
t = ((t ^ (t >> 15)) * (t | 1)) & 0xFFFFFFFF
|
| 52 |
+
t ^= (t + (((t ^ (t >> 7)) * (t | 61)) & 0xFFFFFFFF)) & 0xFFFFFFFF
|
| 53 |
+
return ((t ^ (t >> 14)) & 0xFFFFFFFF) / 4294967296.0
|
| 54 |
+
|
| 55 |
+
def uniform(self, lo, hi):
|
| 56 |
+
return lo + (hi - lo) * self.random()
|
| 57 |
+
|
| 58 |
+
def randint(self, n):
|
| 59 |
+
return int(math.floor(self.random() * n))
|
| 60 |
+
|
| 61 |
+
def normal(self):
|
| 62 |
+
u = max(self.random(), 1e-12)
|
| 63 |
+
v = self.random()
|
| 64 |
+
return math.sqrt(-2.0 * math.log(u)) * math.cos(2.0 * math.pi * v)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def _pair(v):
|
| 68 |
+
return list(v) if isinstance(v, (list, tuple)) else [v, v]
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def _conv2d(x, w, b, stride, pad):
|
| 72 |
+
n, c, h, wd = x.shape
|
| 73 |
+
o, _, kh, kw = w.shape
|
| 74 |
+
sh, sw = stride
|
| 75 |
+
ph, pw = pad
|
| 76 |
+
xp = np.pad(x, ((0, 0), (0, 0), (ph, ph), (pw, pw)))
|
| 77 |
+
oh = (h + 2 * ph - kh) // sh + 1
|
| 78 |
+
ow = (wd + 2 * pw - kw) // sw + 1
|
| 79 |
+
cols = np.empty((n, c, kh, kw, oh, ow), dtype=x.dtype)
|
| 80 |
+
for i in range(kh):
|
| 81 |
+
for j in range(kw):
|
| 82 |
+
cols[:, :, i, j] = xp[:, :, i:i + sh * oh:sh, j:j + sw * ow:sw]
|
| 83 |
+
out = np.tensordot(cols, w, axes=([1, 2, 3], [1, 2, 3])) # n, oh, ow, o
|
| 84 |
+
out = out.transpose(0, 3, 1, 2)
|
| 85 |
+
if b is not None:
|
| 86 |
+
out = out + b[None, :, None, None]
|
| 87 |
+
return out
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def _maxpool(x, k):
|
| 91 |
+
kh, kw = k
|
| 92 |
+
n, c, h, w = x.shape
|
| 93 |
+
oh, ow = h // kh, w // kw
|
| 94 |
+
x = x[:, :, :oh * kh, :ow * kw].reshape(n, c, oh, kh, ow, kw)
|
| 95 |
+
return x.max(axis=(3, 5))
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def forward(layers, x):
|
| 99 |
+
"""Run a layer list on a batch. x: (N, D) or (N, C, H, W) or (N, C, L)."""
|
| 100 |
+
x = np.asarray(x, dtype=np.float64)
|
| 101 |
+
for L in layers:
|
| 102 |
+
t = L["type"]
|
| 103 |
+
if t == "linear":
|
| 104 |
+
x = x @ L["w"].T + L["b"]
|
| 105 |
+
elif t == "conv2d":
|
| 106 |
+
squeeze = x.ndim == 3
|
| 107 |
+
if squeeze:
|
| 108 |
+
x = x[:, :, None, :]
|
| 109 |
+
x = _conv2d(x, L["w"], L["b"], _pair(L["stride"]), _pair(L["pad"]))
|
| 110 |
+
if squeeze:
|
| 111 |
+
x = x[:, :, 0, :]
|
| 112 |
+
elif t == "relu":
|
| 113 |
+
x = np.maximum(x, 0)
|
| 114 |
+
elif t == "tanh":
|
| 115 |
+
x = np.tanh(x)
|
| 116 |
+
elif t == "sigmoid":
|
| 117 |
+
x = 1 / (1 + np.exp(-x))
|
| 118 |
+
elif t == "maxpool":
|
| 119 |
+
squeeze = x.ndim == 3
|
| 120 |
+
if squeeze:
|
| 121 |
+
x = x[:, :, None, :]
|
| 122 |
+
x = _maxpool(x, _pair(L["k"]))
|
| 123 |
+
if squeeze:
|
| 124 |
+
x = x[:, :, 0, :]
|
| 125 |
+
elif t == "gap":
|
| 126 |
+
x = x.reshape(x.shape[0], x.shape[1], -1).mean(axis=2)
|
| 127 |
+
elif t == "flatten":
|
| 128 |
+
x = x.reshape(x.shape[0], -1)
|
| 129 |
+
elif t == "upsample":
|
| 130 |
+
x = x.repeat(L["s"], axis=-1)
|
| 131 |
+
if x.ndim == 4:
|
| 132 |
+
x = x.repeat(L["s"], axis=-2)
|
| 133 |
+
elif t == "l2norm":
|
| 134 |
+
x = x / np.maximum(np.linalg.norm(x, axis=1, keepdims=True), 1e-12)
|
| 135 |
+
elif t == "reshape":
|
| 136 |
+
x = x.reshape([x.shape[0]] + list(L["shape"]))
|
| 137 |
+
else:
|
| 138 |
+
raise ValueError("unknown layer " + t)
|
| 139 |
+
return x
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def export_sequential(seq):
|
| 143 |
+
"""Convert a torch nn.Sequential into a portable layer list (BatchNorm folded)."""
|
| 144 |
+
import torch.nn as nn
|
| 145 |
+
|
| 146 |
+
mods = list(seq.modules())[1:] if not isinstance(seq, (list, tuple)) else list(seq)
|
| 147 |
+
mods = [m for m in mods if not isinstance(m, nn.Sequential)]
|
| 148 |
+
layers = []
|
| 149 |
+
|
| 150 |
+
def tensor(t):
|
| 151 |
+
return t.detach().cpu().double().numpy()
|
| 152 |
+
|
| 153 |
+
for m in mods:
|
| 154 |
+
if isinstance(m, nn.Linear):
|
| 155 |
+
b = tensor(m.bias) if m.bias is not None else np.zeros(m.out_features)
|
| 156 |
+
layers.append({"type": "linear", "w": tensor(m.weight), "b": b})
|
| 157 |
+
elif isinstance(m, (nn.Conv2d, nn.Conv1d)):
|
| 158 |
+
w = tensor(m.weight)
|
| 159 |
+
b = tensor(m.bias) if m.bias is not None else np.zeros(w.shape[0])
|
| 160 |
+
if isinstance(m, nn.Conv1d):
|
| 161 |
+
w = w[:, :, None, :]
|
| 162 |
+
stride, pad = [1, m.stride[0]], [0, m.padding[0]]
|
| 163 |
+
else:
|
| 164 |
+
stride, pad = list(m.stride), list(m.padding)
|
| 165 |
+
layers.append({"type": "conv2d", "w": w, "b": b, "stride": stride, "pad": pad})
|
| 166 |
+
elif isinstance(m, (nn.BatchNorm1d, nn.BatchNorm2d)):
|
| 167 |
+
prev = layers[-1]
|
| 168 |
+
assert prev["type"] in ("conv2d", "linear"), "BatchNorm must follow conv/linear"
|
| 169 |
+
scale = tensor(m.weight) / np.sqrt(tensor(m.running_var) + m.eps)
|
| 170 |
+
shift = tensor(m.bias) - tensor(m.running_mean) * scale
|
| 171 |
+
if prev["type"] == "conv2d":
|
| 172 |
+
prev["w"] = prev["w"] * scale[:, None, None, None]
|
| 173 |
+
else:
|
| 174 |
+
prev["w"] = prev["w"] * scale[:, None]
|
| 175 |
+
prev["b"] = prev["b"] * scale + shift
|
| 176 |
+
elif isinstance(m, nn.ReLU):
|
| 177 |
+
layers.append({"type": "relu"})
|
| 178 |
+
elif isinstance(m, nn.Tanh):
|
| 179 |
+
layers.append({"type": "tanh"})
|
| 180 |
+
elif isinstance(m, nn.Sigmoid):
|
| 181 |
+
layers.append({"type": "sigmoid"})
|
| 182 |
+
elif isinstance(m, nn.MaxPool2d):
|
| 183 |
+
layers.append({"type": "maxpool", "k": _pair(m.kernel_size)})
|
| 184 |
+
elif isinstance(m, nn.MaxPool1d):
|
| 185 |
+
k = m.kernel_size if isinstance(m, int) else m.kernel_size
|
| 186 |
+
layers.append({"type": "maxpool", "k": [1, k if isinstance(k, int) else k[0]]})
|
| 187 |
+
elif isinstance(m, (nn.AdaptiveAvgPool2d, nn.AdaptiveAvgPool1d)):
|
| 188 |
+
layers.append({"type": "gap"})
|
| 189 |
+
elif isinstance(m, nn.Flatten):
|
| 190 |
+
layers.append({"type": "flatten"})
|
| 191 |
+
elif isinstance(m, nn.Upsample):
|
| 192 |
+
layers.append({"type": "upsample", "s": int(m.scale_factor)})
|
| 193 |
+
elif isinstance(m, nn.Dropout):
|
| 194 |
+
continue
|
| 195 |
+
elif m.__class__.__name__ == "L2Norm":
|
| 196 |
+
layers.append({"type": "l2norm"})
|
| 197 |
+
elif m.__class__.__name__ == "Reshape":
|
| 198 |
+
layers.append({"type": "reshape", "shape": list(m.shape)})
|
| 199 |
+
else:
|
| 200 |
+
raise ValueError("cannot export " + m.__class__.__name__)
|
| 201 |
+
return layers
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def encode_layers(layers):
|
| 205 |
+
out = []
|
| 206 |
+
for L in layers:
|
| 207 |
+
L2 = dict(L)
|
| 208 |
+
for key in ("w", "b"):
|
| 209 |
+
if key in L2:
|
| 210 |
+
arr = np.asarray(L2[key])
|
| 211 |
+
L2[key + "_shape"] = list(arr.shape)
|
| 212 |
+
L2[key] = b64e(arr)
|
| 213 |
+
out.append(L2)
|
| 214 |
+
return out
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
def save_model(path, nets=None, tensors=None, meta=None):
|
| 218 |
+
spec = {"format": "nlrt-1", "meta": meta or {}, "nets": {}, "tensors": {}}
|
| 219 |
+
for name, layers in (nets or {}).items():
|
| 220 |
+
spec["nets"][name] = encode_layers(layers)
|
| 221 |
+
for name, arr in (tensors or {}).items():
|
| 222 |
+
arr = np.asarray(arr)
|
| 223 |
+
spec["tensors"][name] = {"shape": list(arr.shape), "data": b64e(arr)}
|
| 224 |
+
with open(path, "w", encoding="utf-8") as f:
|
| 225 |
+
json.dump(spec, f, separators=(",", ":"))
|
| 226 |
+
return spec
|
preview.png
ADDED
|
Git LFS Details
|
render.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Procedural product icons for the synthetic Next Match catalog (48x48 RGB, uint8)."""
|
| 2 |
+
import numpy as np
|
| 3 |
+
from PIL import Image, ImageDraw
|
| 4 |
+
|
| 5 |
+
from match_core import RGB
|
| 6 |
+
|
| 7 |
+
S = 48
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _shape(draw, cat, k, ox, oy):
|
| 11 |
+
"""Draw category silhouette (fill=255) into an L-mode mask. k = scale, (ox, oy) = offset."""
|
| 12 |
+
P = lambda pts: [(ox + k * x, oy + k * y) for x, y in pts] # noqa: E731
|
| 13 |
+
if cat == "tshirt":
|
| 14 |
+
draw.polygon(P([(8, 10), (17, 6), (31, 6), (40, 10), (44, 19), (36, 22), (35, 42), (13, 42), (12, 22), (4, 19)]), fill=255)
|
| 15 |
+
elif cat == "mug":
|
| 16 |
+
draw.rectangle(P([(10, 12), (32, 42)]), fill=255)
|
| 17 |
+
draw.ellipse(P([(26, 18), (42, 34)]), fill=255)
|
| 18 |
+
draw.ellipse(P([(30, 22), (38, 30)]), fill=0)
|
| 19 |
+
elif cat == "sneaker":
|
| 20 |
+
draw.polygon(P([(4, 34), (6, 22), (16, 20), (24, 28), (40, 31), (44, 36), (44, 41), (4, 41)]), fill=255)
|
| 21 |
+
elif cat == "bag":
|
| 22 |
+
draw.rectangle(P([(8, 18), (40, 42)]), fill=255)
|
| 23 |
+
draw.arc(P([(15, 6), (33, 30)]), 180, 360, fill=255, width=max(1, int(3 * k)))
|
| 24 |
+
elif cat == "hat":
|
| 25 |
+
draw.ellipse(P([(4, 30), (44, 40)]), fill=255)
|
| 26 |
+
draw.pieslice(P([(12, 10), (36, 46)]), 180, 360, fill=255)
|
| 27 |
+
elif cat == "chair":
|
| 28 |
+
draw.rectangle(P([(12, 6), (18, 42)]), fill=255)
|
| 29 |
+
draw.rectangle(P([(12, 24), (38, 30)]), fill=255)
|
| 30 |
+
draw.rectangle(P([(32, 28), (37, 42)]), fill=255)
|
| 31 |
+
elif cat == "lamp":
|
| 32 |
+
draw.polygon(P([(14, 8), (34, 8), (40, 22), (8, 22)]), fill=255)
|
| 33 |
+
draw.rectangle(P([(22, 22), (26, 38)]), fill=255)
|
| 34 |
+
draw.rectangle(P([(14, 38), (34, 42)]), fill=255)
|
| 35 |
+
elif cat == "bottle":
|
| 36 |
+
draw.rectangle(P([(20, 4), (28, 12)]), fill=255)
|
| 37 |
+
draw.polygon(P([(20, 12), (28, 12), (34, 20), (34, 43), (14, 43), (14, 20)]), fill=255)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def render(cat, color, pattern, rng):
|
| 41 |
+
"""rng: numpy RandomState for jitter (position, scale, background, pattern phase, noise)."""
|
| 42 |
+
k = rng.uniform(0.82, 1.0)
|
| 43 |
+
ox, oy = rng.uniform(0, S - 48 * k + 1e-6), rng.uniform(0, S - 48 * k + 1e-6)
|
| 44 |
+
mask = Image.new("L", (S, S), 0)
|
| 45 |
+
_shape(ImageDraw.Draw(mask), cat, k, ox, oy)
|
| 46 |
+
m = np.asarray(mask, dtype=np.float64) / 255.0
|
| 47 |
+
bg = rng.uniform(214, 240)
|
| 48 |
+
img = np.ones((S, S, 3)) * np.array([bg, bg - rng.uniform(0, 8), bg - rng.uniform(0, 8)])
|
| 49 |
+
base = np.array(RGB[color], dtype=np.float64)
|
| 50 |
+
accent = np.where(base > 128, base * 0.45, np.minimum(255, base + 150))
|
| 51 |
+
yy, xx = np.mgrid[0:S, 0:S]
|
| 52 |
+
if pattern == "striped":
|
| 53 |
+
phase = rng.uniform(0, 6)
|
| 54 |
+
sel = ((xx + yy + phase) % 7) < 3
|
| 55 |
+
elif pattern == "dotted":
|
| 56 |
+
px, py = rng.uniform(0, 6), rng.uniform(0, 6)
|
| 57 |
+
sel = (((xx + px) % 7 - 3.5) ** 2 + ((yy + py) % 7 - 3.5) ** 2) < 3.2
|
| 58 |
+
else:
|
| 59 |
+
sel = np.zeros((S, S), bool)
|
| 60 |
+
fill = np.where(sel[:, :, None], accent, base)
|
| 61 |
+
img = img * (1 - m[:, :, None]) + fill * m[:, :, None]
|
| 62 |
+
# dark outline so white items stay visible
|
| 63 |
+
edge = (np.abs(np.diff(np.pad(m, 1), axis=0))[:-1, 1:-1] + np.abs(np.diff(np.pad(m, 1), axis=1))[1:-1, :-1]) > 0.3
|
| 64 |
+
img[edge] = img[edge] * 0.35
|
| 65 |
+
img += rng.normal(0, 3.0, img.shape)
|
| 66 |
+
return np.clip(np.round(img), 0, 255).astype(np.uint8)
|
selftest.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
text.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc1059e6665f011f5139d272a35384b9705073095e91c86ca5757239c3b17ffa
|
| 3 |
+
size 297112
|