Semantic Art Search lets you search open museum collections by describing what you're looking for, or by uploading an image. It covers seven museums and also plots every artwork on a map of visual similarity.
To use the site, or to read how it works in plain language and which museums it covers, see the About page. The rest of this README is for developers.
Jina CLIP v2 embeds images and text into a shared 256-dimensional vector space, and Qdrant ranks artworks by vector similarity to the query:
- Visual Search (the default) compares the query with image vectors, so it can find a cat in a painting whose record never mentions one.
- Title Search compares the query with vectors of the titles.
- Similar artworks and image upload search use the same image vectors.
- The art map is a precomputed UMAP projection of the image vectors, drawn with deck.gl.
Filters for museum, work type and production year run on stored metadata.
- Django 5.1 with HTMX, Alpine.js and Tailwind CSS
- PostgreSQL for raw and transformed museum data, statistics and logs
- Qdrant for vector search
- S3-compatible object storage for thumbnails
- Jina API for embeddings, OpenAI API for the artwork descriptions generated on request
| Directory | Contents |
|---|---|
artsearch/ |
The web app: search, artwork pages, art map and REST API |
etl/ |
The pipeline: museum APIs → raw metadata → transformed data → thumbnails → embeddings |
theme/ |
Tailwind configuration and compiled CSS |
djangoconfig/ |
Django project settings |
You need Docker, plus accounts for the Jina and OpenAI APIs and an S3-compatible bucket.
-
Create
.env.devin the repository root with the settings listed inartsearch/src/config.py. -
Build and start the stack, which includes PostgreSQL and Qdrant:
make build make develop
-
In another terminal, apply the migrations:
make migrate
The site runs at http://localhost:8000, but it has no artworks until you run the pipeline. Run make help to see all commands.
Each museum has its own targets for each pipeline step, for example for SMK:
make extract-smk
make transform-smk
make load-images-smk
make load-embeddings-smkThen build the tables and data that the site reads:
make load-artwork-stats # statistics for browsing and filter counts
make compute-colorfulness # scores for the default home page view
make art-map # coordinates for the art mapmake test # everything
make test-app # the web app
make test-etl # the pipelineThe tests run with pytest inside the dev container, so the stack needs to be running.
A JSON API is available at /api/. No key is needed, and search, similar and random requests are rate limited to 30 a minute and 200 an hour per IP.
| Endpoint | Description |
|---|---|
GET /api/museums/ |
List museums |
GET /api/work-types/ |
List searchable work types |
GET /api/search/?query=... |
Search artworks |
POST /api/search/image/ |
Find artworks resembling an uploaded image (multipart field image, max 10 MB; limited to 10 a minute and 100 an hour) |
GET /api/random/ |
Random artworks (optional seed) |
GET /api/artworks/<museum_slug>/<object_number>/ |
One artwork |
GET /api/artworks/<museum_slug>/<object_number>/similar/ |
Visually similar artworks |
Search, random and similar accept offset, limit (max 24), museums and work_types (both repeatable), year_from and year_to. Search also accepts model (image or title, default image).
The code is under the MIT License. The artworks and their data come from the museums' open data programmes, and only works they have released as public domain or open access are included. The About page lists and links to each museum.
Questions, ideas or corrections are welcome: open an issue or message me on LinkedIn.