Tech stack tags: mongodb mongodb-atlas mongodb-vector-search python jupyter-notebook pymongo torchvision computer-vision image-similarity insurance-claims
This repository demonstrates how to build an insurance claims image similarity workflow with MongoDB Vector Search. It embeds vehicle damage photos with a pretrained computer vision model, stores the image vectors and metadata in MongoDB, and retrieves visually similar claims images for faster triage and review.
- Generate image embeddings from vehicle damage photos with a pretrained TorchVision model.
- Store image binaries, filenames, and embedding vectors in MongoDB Atlas.
- Query similar insurance claim photos with MongoDB Vector Search.
- Visualize the query image and top matches directly in a Jupyter notebook.
- Use a documented MongoDB data model for agent-friendly maintenance.
- Vector storage and similarity search: MongoDB Vector Search stores image embeddings with the source image documents and retrieves visually similar vehicle damage photos with cosine similarity.
- Flexible document model: MongoDB stores image metadata, binary image payloads and model-generated vectors in a single collection without requiring a rigid relational schema.
- Notebook interface: Jupyter Notebook for interactive data loading, embedding generation, querying, and visualization.
- Language: Python for data processing, model inference, and MongoDB access.
- Machine learning: TorchVision SqueezeNet for image embedding generation.
- Database: MongoDB Atlas for storing image documents and vectors.
- Search: MongoDB Vector Search for nearest-neighbor retrieval over image embeddings.
- Driver: PyMongo for connecting to MongoDB Atlas.
flowchart LR
A["Vehicle damage image dataset"] --> B["Jupyter notebook"]
B --> C["TorchVision SqueezeNet image embedder"]
C --> D["1000-dimension image embedding"]
B --> E["MongoDB Atlas: claim_resolution.car_damage_photos"]
D --> E
E --> F["MongoDB Vector Search index on embedding"]
G["Query image"] --> C
C --> H["$vectorSearch aggregation"]
F --> H
H --> I["Top similar claim images"]
Before running this demo, install or configure:
- Python 3.10 or above
- MongoDB Atlas cluster
- Atlas database user credentials with read/write access
- Network access from your local environment to the Atlas cluster
git clone https://github.com/mongodb-industry-solutions/Insurance-image-search.git
cd Insurance-image-searchpython3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txtCreate a free or dedicated MongoDB Atlas cluster, then set your connection string as an environment variable:
export MONGODB_URI="mongodb+srv://<username>:<password>@<cluster-name>/?retryWrites=true&w=majority"jupyter notebook image_similarity.ipynbRun the cells in order. The notebook downloads a sample car damage image dataset, writes images to car_damage/, inserts image documents into MongoDB Atlas, builds a vector search index and queries for similar images.
The notebook writes documents to:
Database: claim_resolution
Collection: car_damage_photos
Each document stores:
filename: source image filename.data: image binary data.embedding: 1000-dimension image vector generated by TorchVision SqueezeNet.
See EDD.md for the full entity document diagram, field definitions, index contract, and Mermaid schema diagram.
Run the default notebook contract tests:
python -m pip install -r requirements-dev.txt
pytest -m "not integration"Run the Atlas-backed end-to-end notebook test when you have a test cluster and matching Vector Search index:
export MONGODB_URI="mongodb+srv://<username>:<password>@<cluster-name>/?retryWrites=true&w=majority"
export NOTEBOOK_MAX_DATASET_IMAGES=5
export NOTEBOOK_CLEAR_COLLECTION=true
python -m pip install -r requirements.txt -r requirements-dev.txt
pytest -m integrationNOTEBOOK_CLEAR_COLLECTION=true clears claim_resolution.car_damage_photos before loading the test data. Use it only with a disposable test database.
Example query image:
Example top-5 similar image output:
- MongoDB Vector Search documentation
- PyMongo driver documentation
- TorchVision model documentation
- MongoDB aggregation documentation
This repository is for educational use and is not a supported MongoDB product.

