Chroma autoencoder (conv-64)
Team 8 Β· AI Methods hackathon, IAAC MaAI, Barcelona Β· November 2026
Code: github.com/iaac-maai/hackathon-team8-chroma (folder 01_autoencoder/)
A small convolutional autoencoder that turns a photo of a place into 64 numbers (its latent vector). Photos that look alike get close vectors. In Chroma, a user takes a photo of a place; the app finds the most similar scenes in a labelled library and turns their place, light and colours into a short piece of music.
What it does and for which use
- Input: an RGB photo, resized to 64 Γ 64, pixels scaled to 0β1, shape
(N, 3, 64, 64). - Outputs:
reconstruction(N, 3, 64, 64)andlatent(N, 64), L2-normalised. - Use: similarity search. Cosine similarity between a photo's latent and the 731 library
vectors in
library_latent.npy;library.csvholds the labels of each library scene (place, time of day, season, colour values, palette, music values). The library contains no photos.
Data
| Training | Places365 validation set (Zhou et al., 2017): 36,500 photos, 365 scene types, split 80 / 10 / 10 (seed 8) |
| Library | 731 scenes of six places (market, street, beach, mountains, metro, airport) from the same set, after removing close-ups of people, animals and objects |
| Licence | Places365 photos are for non-commercial research and teaching and belong to their owners. They are not redistributed here; the figures show small 64 px examples for documentation. This model is for non-commercial, educational use. |
Architecture and preprocessing
| Encoder | 4 Γ [Conv 4Γ4, stride 2 β BatchNorm β LeakyReLU 0.1], channels 32 / 64 / 128 / 256 (64 β 4 px), then Linear 4096 β 64 |
| Decoder | Linear 64 β 4096, 3 Γ [ConvTranspose 4Γ4, stride 2 β BatchNorm β LeakyReLU], ConvTranspose β 3 channels, Sigmoid |
| Parameters | 1.9 M Β· ONNX file 7.6 MB |
| Preprocessing | RGB, resize to 64 Γ 64 (bilinear), divide by 255 |
Training and comparison of setups
MSE loss, Adam (learning rate 1e-3), batch 128, 12 epochs, laptop CPU. Same split and seed for all.
| Setup | Latent | Parameters | Train time | Val MSE | Test MSE | Place precision@5 |
|---|---|---|---|---|---|---|
| A Β· dense-64 | 64 | 12.7 M | 7 min | 0.0195 | 0.0193 | 0.319 |
| B Β· conv-64 (this model) | 64 | 1.9 M | 20 min | 0.0129 | 0.0127 | 0.352 |
| C Β· conv-256 | 256 | 3.5 M | 22 min | 0.0079 | 0.0078 | 0.349 |
Place precision@5: of the 5 most similar library scenes, the share with the same place as the query (79 test photos). Chance = 0.218. The model never sees a place label.
Result
- Convolutions beat the dense model with 7 Γ fewer parameters (test MSE 0.0127 vs 0.0193).
- A larger code (256) reconstructs better but does not search better, so we use the 64-number code.
- The 5 nearest scenes share the query's place 1.6 Γ more often than chance.
- The latent space encodes light and setting: bright outdoor scenes on one side, indoor and night scenes on the other, warmth changing smoothly. A sunset at the beach finds other sunsets.
Limits: where it fails
- 0.35 precision means most neighbours are another place: the model groups by light and colour (a bright beach finds bright snowy mountains; old black-and-white photos find pale beaches). Chroma takes the place label from CLIP, not from this model.
- 64 Γ 64 px: small details (signs, doors, people) are lost in the reconstruction.
- Trained on Places365, photographed worldwide, not in Barcelona.
- Indoor scenes are fewer than outdoor ones; golden-hour and night photos are rare in the library.
Where it sits in Chroma
A visitor uploads a photo; the page sends it to the model server (Gradio + ONNX Runtime on Render,
code in 01_autoencoder/model_app/ of the GitHub repository). The server measures colours and gradient
from the pixels, uses this model to find the 10 most similar library scenes, lets them vote on place,
time and season, and returns one scene card (JSON). The music side turns the card into a 10-second piece.
How to use
import json, numpy as np, onnxruntime as ort, pandas as pd
from huggingface_hub import hf_hub_download
from PIL import Image
repo = "iaac-maai/hackathon-team8-chroma-ae"
sess = ort.InferenceSession(hf_hub_download(repo, "chroma_ae.onnx"))
lib_z = np.load(hf_hub_download(repo, "library_latent.npy"))
lib = pd.read_csv(hf_hub_download(repo, "library.csv"))
img = Image.open("my_photo.jpg").convert("RGB").resize((64, 64), Image.Resampling.BILINEAR)
x = (np.asarray(img, dtype=np.float32) / 255.0).transpose(2, 0, 1)[None] # (1, 3, 64, 64)
reconstruction, latent = sess.run(None, {"image": x})
scores = lib_z @ latent[0] # cosine similarity (both normalised)
top = np.argsort(-scores)[:5]
print(lib.loc[top, ["place", "time", "season", "scale"]].assign(similarity=scores[top].round(2)))
Model and figures are made by 01_autoencoder/notebook/autoencoder.ipynb in the GitHub repository.







