title | emoji | colorFrom | colorTo | sdk | app_port |
---|---|---|---|---|---|
Img2Art Search |
🐳 |
purple |
gray |
docker |
7860 |
Demo Link hosted on Hugging Face
"Find real artwork that looks like your images"
This project fine-tunes a Vision Transformer (ViT) model, pre-trained with "google/vit-base-patch32-224-in21k" weights and fine tuned with an image to artwork dataset, to perform image-to-art search across 81k artworks made available by WikiArt.
This project leverages the Vision Transformer (ViT) model architecture for the task of image-to-art search. By fine-tuning the pre-trained ViT model on a custom images to artworks dataset, we aim to create a model capable of matching images (but not only) to corresponding artworks, being able to search for any of the images on WikiArt.
- Clone the repository:
git clone https://github.com/brunorosilva/img2art-search.git
cd img2art-search
- Install poetry:
pip install poetry
- Install using poetry:
poetry install
- Create a dataset matching images to artworks.
- Organize the images into appropriate directories for training and validation.
- Get a fine tuned model
- Create the gallery using WikiArt
Fine-tune the ViT model:
make train
I'll eventually publish the model weights.
Perform image-to-art search using the fine-tuned model:
make viz
make wikiart
If you want to index new images to search, use:
poetry run python main.py gallery --gallery_path <your_path>
The fine tuning dataset derives from 1k examples of images and artwork. Images are split into training, validation and test sets.
WikiArt is indexed using the same process, except that there's no expected result. So each artwork is mapped to itself and the model is used as a feature extractor and the gallery embeddings are saved to Pinecone.
The training script fine-tunes the ViT model on the prepared dataset. Key steps include:
- Loading the pre-trained "google/vit-base-patch32-224-in21k" weights.
- Preparing the dataset and data loaders.
- Fine-tuning the model using a custom training loop.
- Saving the model to the models folder
The recommended method is to use the Demo Link hosted on Hugging Face or self-host gradio as an interface running make viz
.
Search for contextual similarity
Search for expression similarity (yep, that's me)
There are some topics I'd appreciate help with:
- Increasing the gallery by embedding new painting datasets, the current one has 81k artworks because I just got a ready to go dataset, but the complete WikiArt catalog alone has 250k+ artworks, so I really want to up this number to a least 300k in the near future;
- Create optional search terms using CLIP;
- Video2art search?;
- Improve the search performance;
- Open issues with how this could be improved, new ideas will be considered.
The source code for the site is licensed under the MIT license, which you can find in the MIT-LICENSE.txt file.
All graphical assets are licensed under the Creative Commons Attribution 3.0 Unported License.