---
title: "Image search with 🤗 datasets"
description: "A text-to-image search over 10,000 British Library book embellishments can be built by loading the images with the 🤗 datasets ImageFolder loader and embedding them with the CLIP ViT-B/32 model via sentence_transformers."
url: "https://swe.quest/articles/image-search-with-datasets-7a6fd7ae6c6c63ce"
canonical: "https://huggingface.co/blog/image-search-datasets"
source: "Hugging Face"
published: "2022-03-16"
difficulty: "medium"
kind: "How-to"
reading_minutes: 12
tags: ["vector-search","computer-vision","python","search"]
---

# Image search with 🤗 datasets

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-03-16, 12 min read, How-to. Original: [https://huggingface.co/blog/image-search-datasets](https://huggingface.co/blog/image-search-datasets)

## Summary

A text-to-image search over 10,000 British Library book embellishments can be built by loading the images with the 🤗 datasets ImageFolder loader and embedding them with the CLIP ViT-B/32 model via sentence\_transformers. The embeddings are indexed with datasets' built-in add\_faiss\_index, and text prompts are queried with get\_nearest\_examples. push\_to\_hub stores intermediate datasets so work can move between machines, such as a laptop and a Colab GPU. Results for prompts like "a steam engine" or "a musical instrument" are not always correct but are usually reasonable, which is enough to search images by semantic content.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)

## Prerequisites

- Python basics ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))

## Keywords

Hugging Face datasets, CLIP, FAISS, sentence-transformers, Hugging Face Hub, British Library

## Related posts

- [Image Similarity with Hugging Face Datasets and Transformers](https://swe.quest/articles/image-similarity-with-hugging-face-datasets-and-transformers-cfa579cfca74f44c.md): Hugging Face · 2023-01-16 · Medium · 7 min read · Computer vision, Vector search, Search, Python
  An image similarity system can be built by embedding images with a fine-tuned Vision Transformer (CLS token from the last hidden state) and ranking candidates by cosine similarity against a query embedding.
- [Getting Started With Embeddings](https://swe.quest/articles/getting-started-with-embeddings-f83c278b13779a68.md): Hugging Face · 2022-06-23 · Medium · 11 min read · Search, Machine learning, Python, Vector search
  Embeddings turn text or images into fixed-length vectors that capture meaning, so semantic similarity becomes a distance calculation.
- [Image replacement in Canva designs using reverse image search](https://swe.quest/articles/image-replacement-in-canva-designs-using-reverse-image-search-03653e5b614fb037.md): Canva Engineering · 2025-01-28 · Medium · 9 min read · Vector search, Computer vision, Search, System design
  Canva built a reverse image search system to replace IP-restricted images in templates, after ruling out its recommendation engine, perceptual hashing, metadata text search and AI-generated images.
- [Implementing semantic image search with Amazon Titan and Supabase Vector](https://swe.quest/articles/implementing-semantic-image-search-with-amazon-titan-and-supabase-vector-07c13eba94b53a82.md): Supabase · 2024-03-26 · Medium · 5 min read · Vector search, PostgreSQL, Python, Computer vision, Cloud platforms
  Semantic image search can be built in Python by generating 1024-dimensional embeddings for images with the Amazon Titan multimodal embedding model (amazon.titan-embed-image-v1) via Amazon Bedrock, then storing and querying them in Supabase Vector (Postgres with pgvector) using the vecs client.
- [Generate embeddings with Neon AI Gateway](https://swe.quest/articles/generate-embeddings-with-neon-ai-gateway-8da1f214a3b9e4fc.md): Neon · 2026-10-02 · Medium · 7 min read · RAG & retrieval, Vector search, PostgreSQL, LLMs
  Neon AI Gateway now serves embedding models on its OpenAI-compatible /v1/embeddings endpoint using the same branch-scoped credential as chat, accepting up to 150 inputs per request.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
