Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Fine-tuning image classification models from image search

Sign upSign InSign upSign InMarkus StollFollowITNEXT--4ListenShareThe use of pre-trained models on large datasets, such as ImageNet, followed by fine-tuning on specific target datasets, has become the default approach in image classification. This has radically simplified the task of image classification.In this article, we’ll assemble an image Dataset using a customizable search that can integrate our own data with Bing, then fine-tune a Model, and evaluate and debug it using Spotlight for interactive visualization — all in just five lines of code.Create a customizable image dataset, train a model and evaluate and debug it — in five lines of code:First we install the dependencies:Then we run the following code to create a dataset from Bing search and fine-tune a ViT model for image classification:Explore the results with Spotlight:You can create your own dataset using BING image search. Adapting it is straightforward; just modify the class_names in the list. Internally, Sliceguard employs bing-image-downloader to asynchronously search and download images, but it's enhanced to filter images by license. For this example, we're using images that are "Free to share and use".Afterward, the df comprises data for 25 images from each class. Each row provides the path to the image on your storage, the label in text, the label as a numeral, and specifies whether the entry belongs to the training or test split:Once the dataset is ready, we employ sliceguard for fine-tuning, encapsulating the procedure as detailed in the Hugging Face Documentation usingOn a GeForce RTX 4070 Ti with 12 GB, this process takes less than 2 minutes. While we use the google/vit-base-patch16–224-in21k Vision Transformer (ViT) model [1] here, you have the option to select different models from the Hugging Face hub.Using the command:We enrich our dataset with embeddings and classification results with:We’ll utilize the enriched data in the next step.Finally, we use Spotlight, a tool that assists in understanding and visualizing your data effectively, to examine the results and detect problematic clusters. It is started with:Executing this command pops open a new browser window with the Spotlight GUI:We can interactively explore the dataset using this tool. By selecting image clusters in the similarity map, we can closely inspect them. Doing so reveals four key insights:To enhance the dataset’s quality, it’s advisable to remove these outliers and substitute them with better images.Image classification has been made easier with the use of pre-trained models and tools like Spotlight that enhance the data science workflow. Give the code a try with different classes and let us know your results in the comments!I am a professional with expertise in creating advanced software solutions for the interactive exploration of unstructured data. I write about unstructured data and use powerful visualization tools to analyze and make informed decisions.[1] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby, An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale (2020), arXiv----4ITNEXTPhD in Computer Science | Machine Learning Engineer | CTO, Co-Founder at Renumics | Hands-On: Unleashing Data's PotentialMarkus StollinITNEXT--4Jacob FerusinITNEXT--8Mahdi MallakiinITNEXT--4Markus Stoll--1Everton Gomede, PhD--Abhishek k--1Ilias Papastratis--3AL Anany--455Gathnex--2Rayyan Shaikh--12HelpStatusAboutCareersBlogPrivacyTermsText to speechTeams



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Fine-tuning image classification models from image search

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×