<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Markus Stoll</title>
    <description>The latest articles on Forem by Markus Stoll (@markusstoll).</description>
    <link>https://forem.com/markusstoll</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1110648%2F58c91185-7335-4808-9c32-47879f9d272b.jpeg</url>
      <title>Forem: Markus Stoll</title>
      <link>https://forem.com/markusstoll</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/markusstoll"/>
    <language>en</language>
    <item>
      <title>How to build an interactive HF 🤗 Space to visualize an Image Dataset</title>
      <dc:creator>Markus Stoll</dc:creator>
      <pubDate>Mon, 18 Dec 2023 13:30:57 +0000</pubDate>
      <link>https://forem.com/markusstoll/how-to-build-an-interactive-hf-space-to-visualize-an-image-dataset-3mng</link>
      <guid>https://forem.com/markusstoll/how-to-build-an-interactive-hf-space-to-visualize-an-image-dataset-3mng</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s99I5nmy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/N4VecZlbX1whma5CGdLeX.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s99I5nmy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/N4VecZlbX1whma5CGdLeX.gif" alt="image/gif" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Interactive visualization of CIFAR-10[2] with &lt;a href="https://github.com/Renumics/spotlight"&gt; Spotlight&lt;/a&gt;; Source: created by the author.&lt;br&gt;
  &lt;/p&gt;

&lt;p&gt;The &lt;a href="https://huggingface.co/"&gt;Hugging Face&lt;/a&gt; ecosystem provides a rich range of datasets, including unstructured data types like images, videos, and audio. These datasets are widely used for the training and validation of many models available inside and outside Hugging Face Hub.&lt;/p&gt;

&lt;p&gt;Many datasets with unstructured data can be overwhelming due to their extensive size, often containing numerous images that are impossible to review individually. Using foundation models to create embeddings brings structure to this data. By employing dimension reduction techniques like t-SNE or UMAP, you can generate similarity maps, making it easier to navigate through the data.&lt;/p&gt;

&lt;p&gt;This article offers a tutorial on creating a Hugging Face space with an interactive visualization of an image dataset using &lt;a href="https://github.com/Renumics/spotlight"&gt;Renumics Spotlight&lt;/a&gt;. The visualization includes a similarity map, filters, and statistics to navigate the data along with the ability to review each image in detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  1 Load the dataset
&lt;/h2&gt;

&lt;p&gt;First install the required dependencies:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!pip install renumics-spotlight datasets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now you can load the image dataset for which you wish to create the visualization. As an example, here &lt;a href="https://www.cs.toronto.edu/~kriz/cifar.html"&gt;CIFAR-10&lt;/a&gt; [1] is used. The CIFAR-10 dataset is a benchmark dataset in computer vision for image classification. It consists of 10 different classes. The dataset contains 60,000 small color images with dimensions of 32x32 pixels. For our analysis, we will focus on the 10,000 test images. You can choose your own dataset or any &lt;a href="https://huggingface.co/datasets?task_categories=task_categories:image-classification&amp;amp;sort=trending"&gt;image classification datasets from Hugging Face&lt;/a&gt; here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datasets&lt;/span&gt;
    &lt;span class="c1"&gt;# load dataset containing raw data (images and labels)
&lt;/span&gt;    &lt;span class="n"&gt;ds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datasets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load_dataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cifar10&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;test&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2 Create embeddings for the dataset
&lt;/h2&gt;

&lt;p&gt;Embeddings created using foundation models bring structure to unstructured image data. They offer semantic information for tasks like data exploration, generating insights, and detecting outliers. By converting images into a lower-dimensional space, these embeddings allow the exploration of similarities in the data with the creation of similarity maps by techniques like &lt;a href="https://medium.com/towards-data-science/tsne-vs-umap-global-structure-4d8045acba17"&gt;t-SNE or UMAP&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AcDLAxVg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/qStfY_pcR5XQnSZcu4Kod.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AcDLAxVg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/qStfY_pcR5XQnSZcu4Kod.png" alt="image/png" width="800" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;UMAP of CIFAR-10 with selected clusters of similar images; Source: created by the author.&lt;br&gt;
  &lt;/p&gt;

&lt;p&gt;We recommend storing your embeddings directly in a second Hugging Face dataset, separate from the first original image dataset. You can use the &lt;a href="https://huggingface.co/docs/transformers"&gt;transformers library&lt;/a&gt; to compute the embeddings using e.g.,  the &lt;a href="https://huggingface.co/google/vit-base-patch16-224-in21k"&gt;google/vit-base-patch16–224-in21k&lt;/a&gt; [2] model. Utilize the infer  function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="c1"&gt;# load model and define inference functions
&lt;/span&gt;    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;transformers&lt;/span&gt;

    &lt;span class="n"&gt;device&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;device&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cuda:0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cuda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_available&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cpu&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;model_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;google/vit-base-patch16-224-in21k&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;processor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transformers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ViTImageProcessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cls_model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transformers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ViTForImageClassification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;device&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;fe_model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transformers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ViTModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_name&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;infer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;images&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;RGB&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;inputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;processor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;return_tensors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pt&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;no_grad&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;outputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cls_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;probs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;functional&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;softmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outputs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dim&lt;/span&gt;&lt;span class="o"&gt;=-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;numpy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fe_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;last_hidden_state&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;numpy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;embedding&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to extract embeddings. The embeddings are stored in the new dataset ds_enrichments with a single column embedding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="c1"&gt;# enrich dataset with predictions and embeddings
&lt;/span&gt;    &lt;span class="n"&gt;ds_enrichments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;infer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input_columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;img&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batched&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batch_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;remove_columns&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;img&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;label&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3 Try the visualization locally
&lt;/h2&gt;

&lt;p&gt;Before publishing the embeddings we can review results in Spotlight:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;renumics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;spotlight&lt;/span&gt;
    &lt;span class="n"&gt;ds_enriched&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datasets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;concatenate_datasets&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;ds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ds_enrichments&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;spotlight&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ds_enriched&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;embedding&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;spotlight&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Embedding&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open a new browser window:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8t7BIOF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/J7p-hwQ_FUUzDp1bvMNIN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8t7BIOF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/J7p-hwQ_FUUzDp1bvMNIN.png" alt="image/png" width="800" height="650"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the visualization section, the top left displays a table showing all the fields present in the dataset. On the top right, you can observe the UMAP representation represents the embeddings generated from the foundation model. At the bottom the selected images are displayed. &lt;/p&gt;

&lt;h2&gt;
  
  
  4 Publish the embeddings on the Hugging Face Hub
&lt;/h2&gt;

&lt;p&gt;When you are satisfied with the results, you can publish the embeddings as a new dataset on Hugging Face:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;huggingface_hub&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;login&lt;/span&gt;
    &lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;huggingface_hub&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;create_repo&lt;/span&gt;
    &lt;span class="n"&gt;USERNAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;YOUR_ACCOUNT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="nf"&gt;create_repo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;USERNAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/cifar10-enrichments&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;repo_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dataset&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;ds_enrichments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push_to_hub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;USERNAME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;/cifar10-enrichments&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5 Create a Hugging Face Space
&lt;/h2&gt;

&lt;p&gt;To showcase your dataset together with the embeddings on the Hugging Face Hub, you can use Hugging Face spaces to launch a Spotlight visualization for it. You can use the prepared &lt;a href="https://huggingface.co/spaces/renumics/spotlight-mnist"&gt;example&lt;/a&gt; space for the MNIST Image dataset on the hub, duplicate it and  specify your datasets in the HF_DATASET and HF_ENRICHMENT  variables:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wVL57kCE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/lM_VzSUo5k4OsKxuzc3kX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wVL57kCE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/lM_VzSUo5k4OsKxuzc3kX.png" alt="image/png" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a few minutes the space will be ready:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nd0iK11y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/jDJR0f1rMvABQLzqkoLG-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nd0iK11y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-uploads.huggingface.co/production/uploads/645e27fa0c5080bd7750a315/jDJR0f1rMvABQLzqkoLG-.png" alt="image/png" width="800" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6 Summary
&lt;/h2&gt;

&lt;p&gt;The article demonstrates how foundation models can structure large, unstructured image datasets like CIFAR-10 with embeddings. The use of &lt;a href="https://github.com/Renumics/spotlight"&gt;Renumics Spotlight&lt;/a&gt; in a Hugging Face space allows an interactive visualization of image datasets. This includes creating similarity maps using dimension reduction techniques like t-SNE or UMAP, enabling easier analysis and navigation of the data.&lt;/p&gt;

&lt;p&gt;Try this workflow on your own image dataset and explore the possibilities. After applying these techniques, feel free to &lt;a href="https://github.com/Renumics/spotlight"&gt;share your experience and feedback&lt;/a&gt; with us.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;[1] Alex Krizhevsky, &lt;a href="https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf"&gt;Learning Multiple Layers of Features from Tiny Images&lt;/a&gt; (2009), University Toronto&lt;/p&gt;

&lt;p&gt;[2] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, Neil Houlsby &lt;a href="https://arxiv.org/abs/2010.11929"&gt;An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale&lt;/a&gt; (2020), arXiv&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Hacktoberfest Machine Learning Projects for JS/TS Developers 🎃</title>
      <dc:creator>Markus Stoll</dc:creator>
      <pubDate>Fri, 20 Oct 2023 05:27:52 +0000</pubDate>
      <link>https://forem.com/markusstoll/hacktoberfest-machine-learning-projects-for-jsts-developers-58cb</link>
      <guid>https://forem.com/markusstoll/hacktoberfest-machine-learning-projects-for-jsts-developers-58cb</guid>
      <description>&lt;p&gt;Finding machine learning projects that are suitable for JS/TS developers during &lt;a href="https://hacktoberfest.com/"&gt;Hacktoberfest&lt;/a&gt; can be daunting due to the overwhelming abundance of open-source projects. We’ve simplified this process, offering you a refined selection of opportunities where your coding skills can shine and make a real impact.&lt;/p&gt;

&lt;p&gt;Welcome to our curated list of open-source machine learning GUI projects built with JavaScript and TypeScript, all of which are currently open to contributions! If you are interested in visualization and GUI for machine learning and proficient in JavaScript or TypeScript, you’re in for a treat! Each project listed is not only aligned with Hacktoberfest but is also actively maintained and has a handful of issues for you to tackle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selection Criteria:
&lt;/h3&gt;

&lt;p&gt;To guarantee the quality and relevance of the projects, we’ve applied a selection process. Each repository in this list meets the following criteria:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Repo Topics:&lt;/strong&gt; The projects are centered around machine learning and are participating in Hacktoberfest. They are developed using JavaScript or TypeScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Recent Activity:&lt;/strong&gt; We’ve ensured that each listed project has had activity within the last 7 days.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Availability of Issues:&lt;/strong&gt; Each project has more than 3 open issues that are suitable for contributors to tackle during Hacktoberfest.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these criteria in mind, we present to you a handpicked selection of projects where your contributions can make a significant impact. Not only will you be contributing to meaningful projects, but you’ll also be honing your skills and learning more about machine learning and web development. So, let’s dive into these exciting opportunities!&lt;/p&gt;

&lt;h2&gt;
  
  
  Renumics Spotlight — Explore Unstructured ML Data
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/Renumics/spotlight"&gt;Renumics Spotlight&lt;/a&gt; is a powerful tool for intuitively exploring unstructured datasets directly from dataframes. It’s designed to simplify data comprehension, allowing users to create interactive visualizations and leverage data enrichments like embeddings, predictions, and uncertainties to identify critical data clusters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jDx1sLUQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/2664/0%2AtZerHFMB-ehrpZg5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jDx1sLUQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/2664/0%2AtZerHFMB-ehrpZg5.gif" alt="Renumics Spotlight GUI, Source: [https://github.com/Renumics/spotlight](https://github.com/Renumics/spotlight)" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Diverse Data Support:&lt;/strong&gt; Seamlessly handles various unstructured data types, including images, audio, text, videos, time-series, and geometric data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interactive Visualizations:&lt;/strong&gt; Enables the quick generation of interactive visuals for enhanced data understanding and communication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Python Integration:&lt;/strong&gt; Offers easy integration and usage with intuitive Python commands and compatibility with pandas DataFrames.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Recent Issues
&lt;/h3&gt;

&lt;p&gt;Renumics is currently participating in the running &lt;a href="https://hacktoberfest.com/"&gt;Hacktoberfest 2023&lt;/a&gt;. If you would like to contribute to Spotlight, the easiest way is to have a look at the &lt;a href="https://renumics.com/docs/development"&gt;Contribution Docs&lt;/a&gt; and the &lt;a href="https://github.com/Renumics/spotlight/blob/main/CONTRIBUTING.md"&gt;CONTRIBUTING.md&lt;/a&gt;. Every accepted PR earns you a limited-edition T-Shirt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FyTmXYvu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AYxPxgatsAYB7D9C8HUyvCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FyTmXYvu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/1%2AYxPxgatsAYB7D9C8HUyvCQ.png" alt="Every accepted PR [earns you a limited-edition T-Shirt](https://renumics.com/blog/hacktoberfest_2023#-whats-in-store)." width="709" height="858"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some current issues include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Renumics/spotlight/issues/283"&gt;Support sequnces in spectrogram lens&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Renumics/spotlight/issues/280"&gt;Support Windows in Sequence(s) Lens&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/Renumics/spotlight/issues/279"&gt;ROUGE Score Lens&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  CML (Continuous Machine Learning)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/iterative/cml"&gt;Continuous Machine Learning (CML)&lt;/a&gt; is an open-source command-line interface tool designed to enhance continuous integration and delivery (CI/CD) workflows, with a focus on Machine Learning Operations (MLOps). The tool facilitates automated development workflows, including machine provisioning, model training and evaluation, comparing machine learning experiments across your project’s history, and monitoring changing datasets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qRQTY_vR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2400/0%2Al3nMgbur0sppScBs" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qRQTY_vR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2400/0%2Al3nMgbur0sppScBs" alt="*An example report for a [neural style transfer model](https://github.com/iterative/cml_cloud_case) (source [*https://github.com/iterative/cml](https://github.com/iterative/cml))" width="800" height="754"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Core Features and Principles
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GitFlow for Data Science:&lt;/strong&gt; CML encourages data scientists and engineers to leverage GitLab or GitHub for managing ML experiments. Track modifications in data, monitor who trained models, and when, and codify data and models with DVC.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Auto Reports for ML Experiments:&lt;/strong&gt; Automatically generate visual reports containing metrics and plots with each pull request to make informed, data-driven decisions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Self-contained:&lt;/strong&gt; Build your customized ML platform using existing resources without the need for additional databases, services, or complex setups.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Recent Issues
&lt;/h3&gt;

&lt;p&gt;With 67 active issues, the community and contributors have ample opportunities to contribute during this Hacktoberfest. Some current issues include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/iterative/cml/issues/1369"&gt;cml publish ignores paths with spaces&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/iterative/cml/issues/1282"&gt;Be able to create arm-based CML runners on AWS&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/iterative/cml/issues/1167"&gt;Allow -cloud-startup-script to specify a file&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Inclusive Code Reviews: Browser Extension
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/jonathanpeppers/inclusive-code-reviews-browser"&gt;Inclusive Code Reviews&lt;/a&gt; is a prototype Chrome and Edge web extension aimed at improving the quality and inclusivity of online comments, particularly in the context of code reviews on platforms like GitHub or Azure DevOps. The extension prompts users with suggestions before they post a comment, allowing developers an opportunity to reevaluate and refine their phrasing to ensure it is constructive and inclusive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6dUwgdsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AB9PxFB_evQYD5AIB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6dUwgdsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/2000/0%2AB9PxFB_evQYD5AIB.png" alt="Inclusive Code Reviews: Browser Extension, source: [https://github.com/jonathanpeppers/inclusive-code-reviews-browser](https://github.com/jonathanpeppers/inclusive-code-reviews-browser)" width="450" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Word and Terminology Suggestions:&lt;/strong&gt; The extension provides alternative terms that are more inclusive, fostering a positive and welcoming environment for collaborators.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sentiment Analysis:&lt;/strong&gt; Empowered by a custom machine learning model, the extension classifies comments to identify and moderate negative sentiments, ensuring communications are respectful and encouraging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OpenAI Integration:&lt;/strong&gt; An experimental feature that allows the utilization of OpenAI API for enhancing the identification and suggestion process of negative sentiments.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;p&gt;As you draft a comment or code review, the extension evaluates the content and provides real-time feedback. For instance, if you use the term “whitelist,” the extension will suggest the more inclusive term “allowlist.” Furthermore, it employs a custom machine learning model that runs within the browser extension to classify comments and ensure they are positive and constructive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contribution Opportunities
&lt;/h3&gt;

&lt;p&gt;With 27 open issues, there are ample opportunities for developers to contribute and refine the extension’s functionalities. Some highlighted issues include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/jonathanpeppers/inclusive-code-reviews-browser/issues/246"&gt;Sometimes bad sentences at end of line are not underlined?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/jonathanpeppers/inclusive-code-reviews-browser/issues/245"&gt;New PC, privacy policy?&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/jonathanpeppers/inclusive-code-reviews-browser/issues/216"&gt;Add ability only opt into certain websites&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  BeatBridge — A Music Player with a Recommendation Engine
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/pooranjoyb/BeatBridge"&gt;BeatBridge&lt;/a&gt; is a dynamic web application, a music player that not only allows users to enjoy their favorite tunes but also offers personalized song recommendations, enhancing the musical experience. Developed with React and TailwindCSS, and empowered by the Spotify API, BeatBridge is a convergence of aesthetic design, seamless user experience, and intelligent recommendations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Spotify API Integration:&lt;/strong&gt; Fetch and play songs directly via the highly reliable and extensive Spotify API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interactive GUI:&lt;/strong&gt; A user-friendly and intuitive graphical user interface ensuring an enjoyable user experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Recommendation Engine:&lt;/strong&gt; A clustering-based recommendation engine that suggests songs tailored to the users’ musical taste.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Getting Involved
&lt;/h3&gt;

&lt;p&gt;BeatBridge invites developers and music enthusiasts to contribute and enhance the app’s features and functionalities. Here are some current open issues you can work on:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/pooranjoyb/BeatBridge/issues/27"&gt;Create a Footer&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/pooranjoyb/BeatBridge/issues/24"&gt;Music Player UI breaks in Full Screen&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/pooranjoyb/BeatBridge/issues/33"&gt;Using Framer-motion’s whileInView prop&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Your Next Steps Forward
&lt;/h2&gt;

&lt;p&gt;Each project offers a unique blend of challenges and learning opportunities, inviting you to contribute and grow your skills and knowledge in the dynamic world of open source. Choose a project that resonates with you, select an issue, and make an impact 🚀.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>machinelearning</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How I Created an Animation Of the Embeddings During Fine-Tuning</title>
      <dc:creator>Markus Stoll</dc:creator>
      <pubDate>Thu, 05 Oct 2023 10:32:02 +0000</pubDate>
      <link>https://forem.com/markusstoll/how-i-created-an-animation-of-the-embeddings-during-fine-tuning-17ln</link>
      <guid>https://forem.com/markusstoll/how-i-created-an-animation-of-the-embeddings-during-fine-tuning-17ln</guid>
      <description>&lt;h2&gt;
  
  
  How I Created an Animation Of the Embeddings During Fine-Tuning
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Using Cleanlab, PCA, and Procrustes to visualize ViT fine-tuning on CIFAR-10
&lt;/h3&gt;

&lt;p&gt;In the field of machine learning, &lt;a href="https://medium.com/analytics-vidhya/vision-transformers-bye-bye-convolutions-e929d022e4ab" rel="noopener noreferrer"&gt;Vision Transformers&lt;/a&gt; (ViT) are a type of model used for image classification. Unlike traditional convolutional neural networks, ViTs use the transformer architecture, which was originally designed for natural language processing tasks, to process images. Fine-tuning these models, for optimal performance can be a complex process.&lt;/p&gt;

&lt;p&gt;In a &lt;a href="https://dev.to/markusstoll/changes-of-embeddings-during-fine-tuning-of-transformers-4e2i"&gt;previous article&lt;/a&gt;, I used an animation to demonstrate changes in the embeddings during the fine-tuning process. This was achieved by performing Principal Component Analysis (PCA) on the embeddings. These embeddings were generated from models at various stages of fine-tuning and their corresponding checkpoints.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2320%2F1%2AjYdWl_8UM6ecV1ux8_qr1Q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2320%2F1%2AjYdWl_8UM6ecV1ux8_qr1Q.gif"&gt;&lt;/a&gt;&lt;br&gt;Projection of embeddings with PCA during fine-tuning of a Vision Transformer (ViT) model [1] on CIFAR10 [3]; Source: created by the author
  &lt;/p&gt;

&lt;p&gt;The animation received over 200,000 impressions. It was well-received, with many readers expressing interest in how it was created. This article is here to support those readers and anyone else interested in creating similar visualizations.&lt;/p&gt;

&lt;p&gt;In this article, I aim to provide a comprehensive guide on how to create such an animation, detailing the steps involved: fine-tuning, creation of embeddings, outlier detection, PCA, Procrustes, review, and creation of the animation.&lt;/p&gt;

&lt;p&gt;The complete code for the animation is also available in &lt;a href="https://github.com/Renumics/spotlight/blob/main/playbook/stories/making_of_embeddings_animation.ipynb" rel="noopener noreferrer"&gt;the accompanying notebook on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparation: Fine-tuning
&lt;/h2&gt;

&lt;p&gt;The first step is to fine-tune the &lt;a href="https://huggingface.co/google/vit-base-patch16-224-in21k" rel="noopener noreferrer"&gt;google/vit-base-patch16–224-in21k&lt;/a&gt; Vision Transformer (ViT) model [1], which is pre-trained. We use the &lt;a href="https://www.cs.toronto.edu/~kriz/cifar.html" rel="noopener noreferrer"&gt;CIFAR-10 dataset&lt;/a&gt; [2] for this, containing 60,000 images classified into ten different classes: airplanes, cars, birds, cats, deer, dogs, frogs, horses, ships, and trucks.&lt;/p&gt;

&lt;p&gt;You can follow the steps outlined in the &lt;a href="https://huggingface.co/docs/transformers/tasks/image_classification" rel="noopener noreferrer"&gt;Hugging Face tutorial for image classification with transformers&lt;/a&gt; to execute the fine-tuning process also for CIFAR-10. Additionally, we utilize a TrainerCallback to store the loss values during training into a CSV file for later use in the animation.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from transformers import TrainerCallback

class PrinterCallback(TrainerCallback):
    def on_log(self, args, state, control, logs=None, **kwargs):
        _ = logs.pop("total_flos", None)
        if state.is_local_process_zero:
            if len(logs) == 3:  # skip last row
                with open("log.csv", "a") as f:
                    f.write(",".join(map(str, logs.values())) + "\n")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It’s important to increase the save interval for checkpoints by setting save_strategy="step" and a low value for save_step in TrainingArguments to ensure enough checkpoints for the animation. Each frame in the animation corresponds to one checkpoint. A folder for each checkpoint and the CSV file are created during the training and are ready for further use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creation of the Embeddings
&lt;/h2&gt;

&lt;p&gt;We use the AutoFeatureExtractor and AutoModel from the Transformers library to generate embeddings from the CIFAR-10 dataset’s test split using different model checkpoints.&lt;/p&gt;

&lt;p&gt;Each embedding is a 768-dimensional vector representing one of the 10,000 test images for one model checkpoint. These embeddings can be stored in the same folder as the checkpoints to maintain a good overview.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extracting Outliers
&lt;/h2&gt;

&lt;p&gt;We can use the OutOfDistribution class provided by the &lt;a href="https://github.com/cleanlab/cleanlab" rel="noopener noreferrer"&gt;Cleanlab&lt;/a&gt; library to identify outliers based on the embeddings for each checkpoint. The resulting scores can then identify the top 10 outliers for the animation.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from cleanlab.outlier import OutOfDistribution

&lt;p&gt;def get_ood(sorted_checkpoint_folder, df):&lt;br&gt;
  ...&lt;br&gt;
  ood = OutOfDistribution()&lt;br&gt;
  ood_train_feature_scores = ood.fit_score(features=embedding_np)&lt;br&gt;
  df["scores"] = ood_train_feature_scores&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Applying PCA and Procrustes Analysis&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;With a &lt;a href="https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html" rel="noopener noreferrer"&gt;Principal Component Analysis (PCA)&lt;/a&gt; for the scikit-learn package, we visualize the embeddings in a 2D space by reducing the 768-dimensional vectors to 2 dimensions. When recalculating PCA for each timestep, large jumps in the animation due to axis-flips or rotations can occur. To address this issue, we apply an additional &lt;a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.procrustes.html" rel="noopener noreferrer"&gt;Procrustes Analysis&lt;/a&gt; [3] from the SciPy package to geometrically transform each frame onto the last frame, which involves only translation, rotation, and uniform scaling. This enables smoother transitions in the animation.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.decomposition import PCA&lt;br&gt;
from scipy.spatial import procrustes

&lt;p&gt;def make_pca(sorted_checkpoint_folder, pca_np):&lt;br&gt;
  ...&lt;br&gt;
  embedding_np_flat = embedding_np.reshape(-1, 768)&lt;br&gt;
  pca = PCA(n_components=2)&lt;br&gt;
  pca_np_new = pca.fit_transform(embedding_np_flat)&lt;br&gt;
  _, pca_np_new, disparity = procrustes(pca_np, pca_np_new)&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Review in Spotlight&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Before finalizing the entire animation, we conduct a review in Spotlight. In this process, we utilize the first and last checkpoints to perform embedding generation, PCA, and outlier detection. We load the resulting DataFrame in Spotlight:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2512%2F1%2AJaL0nOH7W_OYOoCHXynjFw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2512%2F1%2AJaL0nOH7W_OYOoCHXynjFw.png"&gt;&lt;/a&gt;&lt;br&gt;Embeddings for CIFAR-10: PCA and 8 worst outliers for the first and the last checkpoint of a short fine-tuning— visualized with spotlight, source: created by the author
  &lt;/p&gt;

&lt;p&gt;Spotlight provides a comprehensive table in the top left, showcasing all the fields present in the dataset. On the top right, two PCA representations are displayed: one for the embeddings generated using the first checkpoint and one for the last checkpoint. Finally, in the bottom section, selected images are presented.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclaimer: The author of this article is also one of the developers of Spotlight.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the animation
&lt;/h2&gt;

&lt;p&gt;For each checkpoint, we create an image, which we then store alongside its corresponding checkpoint.&lt;/p&gt;

&lt;p&gt;This is achieved through the utilization of the make_pca(...) and get_ood(...) functions, which generate the 2D points representing the embedding and extract the top 8 outliers, respectively. The 2D points are plotted with colors corresponding to their respective classes.The outliers are sorted based on their score, and their corresponding images are displayed in a highscore leaderboard. The training loss is loaded from a CSV file and plotted as a line graph.&lt;/p&gt;

&lt;p&gt;Finally, all the images can be compiled into a GIF using libraries such as imageio or similar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2ADt6ahw5N9PMTEgzIvdDtsw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2ADt6ahw5N9PMTEgzIvdDtsw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2A0Parw7i8X05l39S5-oK1vg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2A0Parw7i8X05l39S5-oK1vg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2AaTxbgtVql9zxntpcTYmtZQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3200%2F1%2AaTxbgtVql9zxntpcTYmtZQ.png" alt="Three generated frames from the initial three written checkpoints of the fine-tuning process show slight clustering. It is expected that more pronounced clustering will occur in later steps. source: created by the author"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article has provided a detailed guide on how to create an animation that visualizes the fine-tuning process of a Vision Transformer (ViT) model. We’ve walked through the steps of generating and analyzing embeddings, visualizing the results, and creating an animation that brings these elements together.&lt;/p&gt;

&lt;p&gt;Creating such an animation not only helps in understanding the complex process of fine-tuning a ViT model but also serves as a powerful tool for communicating these concepts to others.&lt;/p&gt;

&lt;p&gt;The complete code for the animation is available in the &lt;a href="https://github.com/Renumics/spotlight/tree/main/playbook/stories/making_of_embeddings_animation.ipynb" rel="noopener noreferrer"&gt;accompanying notebook on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;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.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;[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, &lt;a href="https://arxiv.org/abs/2010.11929" rel="noopener noreferrer"&gt;An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale&lt;/a&gt; (2020), arXiv&lt;/p&gt;

&lt;p&gt;[2] Alex Krizhevsky, &lt;a href="https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf" rel="noopener noreferrer"&gt;Learning Multiple Layers of Features from Tiny Images&lt;/a&gt; (2009), University Toronto&lt;/p&gt;

&lt;p&gt;[3] Gower, John C. &lt;a href="https://link.springer.com/article/10.1007/BF02291478" rel="noopener noreferrer"&gt;Generalized procrustes analysis &lt;/a&gt;(1975), Psychometrika&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>github</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Changes of Embeddings during Fine-Tuning of Transformers</title>
      <dc:creator>Markus Stoll</dc:creator>
      <pubDate>Fri, 14 Jul 2023 14:59:55 +0000</pubDate>
      <link>https://forem.com/markusstoll/changes-of-embeddings-during-fine-tuning-of-transformers-4e2i</link>
      <guid>https://forem.com/markusstoll/changes-of-embeddings-during-fine-tuning-of-transformers-4e2i</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qjbP132W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/2320/1%2AjYdWl_8UM6ecV1ux8_qr1Q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qjbP132W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cdn-images-1.medium.com/max/2320/1%2AjYdWl_8UM6ecV1ux8_qr1Q.gif" alt="Projection of embeddings with PCA during fine-tuning of a Vision Transformer (ViT) model [1] on CIFAR10 [3]; Source: created by the author." width="800" height="806"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Fine-tuning significantly influences embeddings in image classification. Pre-fine-tuning embeddings offer general-purpose representations, whereas post-fine-tuning embeddings capture task-specific features. This distinction can lead to varying outcomes in outlier detection and other tasks. Both pre-fine-tuning and post-fine-tuning embeddings have their unique strengths and should be used in combination to achieve a comprehensive analysis in image classification and analysis tasks.&lt;/p&gt;

&lt;p&gt;Checkout out one of the online Demos of the &lt;a href="https://huggingface.co/datasets/renumics/cifar10-outlier"&gt;CIFAR-10&lt;/a&gt; dataset [3] for this article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://huggingface.co/spaces/renumics/cifar10-outlier"&gt;https://huggingface.co/spaces/renumics/cifar10-outlier&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1 Introduction
&lt;/h2&gt;

&lt;p&gt;The use of pre-trained models on large datasets, such as &lt;a href="https://www.image-net.org/"&gt;ImageNet&lt;/a&gt;, followed by fine-tuning on specific target datasets, has become the default approach in image classification. However, when dealing with real-world target datasets, it is important to consider their inherent noise, which includes outliers, label errors, and other anomalies. Interactive exploration of datasets plays a crucial role in gaining a comprehensive understanding of the data, enabling the identification and resolution of critical data segments through the utilization of data enrichments.&lt;/p&gt;

&lt;p&gt;Embeddings play a crucial role in analyzing unstructured image data. They provide high-level semantic information and support various tasks such as data analysis, insight generation and outlier detection. By representing images in a lower-dimensional space, embeddings make it easier to explore similarities and differences within the data and allows for the creation of similarity maps using techniques like &lt;a href="https://medium.com/towards-data-science/tsne-vs-umap-global-structure-4d8045acba17"&gt;t-SNE or UMAP&lt;/a&gt;. We will use &lt;a href="https://github.com/Renumics/spotlight"&gt;Spotlight&lt;/a&gt; to interactively explore the enriched datasets we create:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclaimer: The author of this article is also one of the developers of Spotlight. Some of the code snippets in this article are also available in the Spotlight repository.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this article, we will delve into the differences between pre and post fine-tuning embeddings, with an additonal focus on outlier detection. While it is important to note that using embeddings from fine-tuned models may not always yield the best results for &lt;a href="https://docs.cleanlab.ai/stable/tutorials/outliers.html"&gt;outlier detection as we could also use the probabilities&lt;/a&gt;, it still presents an intriguing approach. The visualization of embeddings adds a visually appealing dimension to the analysis process.&lt;/p&gt;

&lt;p&gt;To assess the performance and effectiveness of embeddings in outlier detection tasks, we will examine exemplary datasets that are widely used in image classification. Moreover, we will utilize two common foundation model. Through this exploration, we aim to gain insights into the effect of Model Fine-tuning on the embeddings, providing a better understanding of their capabilities and limitations.&lt;/p&gt;

&lt;h2&gt;
  
  
  2 Preparations
&lt;/h2&gt;

&lt;p&gt;Install the required Python Packages:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!pip install renumics-spotlight datasets torch pandas cleanlab annoy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  2.1 Extract Embeddings
&lt;/h2&gt;

&lt;p&gt;We will use the following models based on &lt;a href="https://huggingface.co/google/vit-base-patch16-224-in21k"&gt;google/vit-base-patch16–224-in21k&lt;/a&gt; [1] and &lt;a href="https://huggingface.co/microsoft/swin-base-patch4-window7-224"&gt;microsoft/swin-base-patch4-window7–224&lt;/a&gt; [2] available on Hugging Faces to extract pre-fine-tuning embeddings and the best-liked fine-tuned models for each dataset: &lt;a href="https://huggingface.co/aaraki/vit-base-patch16-224-in21k-finetuned-cifar10"&gt;araki/vit-base-patch16–224-in21k-finetuned-cifar10&lt;/a&gt;, &lt;a href="https://huggingface.co/MazenAmria/swin-tiny-finetuned-cifar100"&gt;MazenAmria/swin-tiny-finetuned-cifar100&lt;/a&gt;, &lt;a href="https://huggingface.co/nateraw/vit-base-beans"&gt;nateraw/vit-base-beans&lt;/a&gt;, &lt;a href="https://huggingface.co/farleyknight/mnist-digit-classification-2022-09-04"&gt;farleyknight/mnist-digit-classification-2022–09–04&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;case = {
    "cifar10": {
        "base_model_name": "google/vit-base-patch16-224-in21k",
        "ft_model_name": "aaraki/vit-base-patch16-224-in21k-finetuned-cifar10",
    },
    "beans": {
        "base_model_name": "google/vit-base-patch16-224-in21k",
        "ft_model_name": "nateraw/vit-base-beans",
    },
    "mnist": {
        "base_model_name": "google/vit-base-patch16-224-in21k",
        "ft_model_name": "farleyknight/mnist-digit-classification-2022-09-04",
    },
    "cifar100": {
        "base_model_name": "microsoft/swin-base-patch4-window7-224",
        "ft_model_name": "MazenAmria/swin-tiny-finetuned-cifar100",
    },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To load the dataset, we utilize the load_dataset function from the datasets module and prepare it for the image classification task. You can choose from the tested and reported dataset of this article &lt;a href="https://huggingface.co/datasets/cifar10"&gt;CIFAR-10&lt;/a&gt; [3], &lt;a href="https://huggingface.co/datasets/cifar100"&gt;CIFAR-100&lt;/a&gt; [3], &lt;a href="https://huggingface.co/datasets/mnist"&gt;MNIST&lt;/a&gt; [4] and &lt;a href="https://huggingface.co/datasets/beans"&gt;Beans&lt;/a&gt; [5] or try different &lt;a href="https://huggingface.co/models?pipeline_tag=image-classification"&gt;image classification datasets from Hugging Face&lt;/a&gt; with corresponding models.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import datasets
# choose from cifar10, cifar100, mnist or beans.
# corresponding model will be selected automatically
DATASET = "cifar10"
ds = datasets.load_dataset(DATASET, split="train").prepare_for_task(
    "image-classification"
)
df = ds.to_pandas()
# df = df.iloc[:1000] # uncomment to limit the dataset size for testing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We define the huggingface_embedding function to extract embeddings from both the fine-tuned model and the base/foundation model. The embeddings are stored in separate columns ("embedding_ft" and "embedding_foundation") in the original dataframe (df):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import datasets
from transformers import AutoFeatureExtractor, AutoModel
import torch
import pandas as pd

ft_model_name = case[DATASET]["ft_model_name"]
base_model_name = case[DATASET]["base_model_name"]
def extract_embeddings(model, feature_extractor, image_name="image"):
    """
    Utility to compute embeddings.
    Args:
        model: huggingface model
        feature_extractor: huggingface feature extractor
        image_name: name of the image column in the dataset
    Returns:
        function to compute embeddings
    """
    device = model.device
    def pp(batch):
        images = batch[image_name]
        inputs = feature_extractor(
            images=[x.convert("RGB") for x in images], return_tensors="pt"
        ).to(device)
        embeddings = model(**inputs).last_hidden_state[:, 0].cpu()
        return {"embedding": embeddings}
    return pp

def huggingface_embedding(
    df,
    image_name="image",
    modelname="google/vit-base-patch16-224",
    batched=True,
    batch_size=24,
):
    """
    Compute embeddings using huggingface models.
    Args:
        df: dataframe with images
        image_name: name of the image column in the dataset
        modelname: huggingface model name
        batched: whether to compute embeddings in batches
        batch_size: batch size
    Returns:
        new dataframe with embeddings
    """
    # initialize huggingface model
    feature_extractor = AutoFeatureExtractor.from_pretrained(modelname)
    model = AutoModel.from_pretrained(modelname, output_hidden_states=True)
    # create huggingface dataset from df
    dataset = datasets.Dataset.from_pandas(df).cast_column(image_name, datasets.Image())
    # compute embedding
    device = "cuda" if torch.cuda.is_available() else "cpu"
    extract_fn = extract_embeddings(model.to(device), feature_extractor, image_name)
    updated_dataset = dataset.map(extract_fn, batched=batched, batch_size=batch_size)
    df_temp = updated_dataset.to_pandas()
    df_emb = pd.DataFrame()
    df_emb["embedding"] = df_temp["embedding"]
    return df_emb

embeddings_df = huggingface_embedding(
    df,
    modelname=ft_model_name,
    batched=True,
    batch_size=24,
)
embeddings_df_found = huggingface_embedding(
    df, modelname=base_model_name, batched=True, batch_size=24
)
df["embedding_ft"] = embeddings_df["embedding"]
df["embedding_foundation"] = embeddings_df_found["embedding"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  2.2 Calculate outlier score
&lt;/h2&gt;

&lt;p&gt;Next we use [Cleanlab] &lt;a href="https://github.com/cleanlab/cleanlab"&gt;https://github.com/cleanlab/cleanlab&lt;/a&gt;) to calculate outlier scores both the fine-tuned model and the base/foundation based on the embeddings. We utilize the OutOfDistribution class to compute the outlier scores. The resulting outlier scores are stored in the original dataframe (df):&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from cleanlab.outlier import OutOfDistribution
import numpy as np
import pandas as pd
def outlier_score_by_embeddings_cleanlab(df, embedding_name="embedding"):
    """
    Calculate outlier score by embeddings using cleanlab
        Args:
            df: dataframe with embeddings
            embedding_name: name of the column with embeddings
        Returns:
            new df_out: dataframe with outlier score
    """
    embs = np.stack(df[embedding_name].to_numpy())
    ood = OutOfDistribution()
    ood_train_feature_scores = ood.fit_score(features=np.stack(embs))
    df_out = pd.DataFrame()
    df_out["outlier_score_embedding"] = ood_train_feature_scores
    return df_out

df["outlier_score_ft"] = outlier_score_by_embeddings_cleanlab(
    df, embedding_name="embedding_ft"
)["outlier_score_embedding"]
df["outlier_score_found"] = outlier_score_by_embeddings_cleanlab(
    df, embedding_name="embedding_foundation"
)["outlier_score_embedding"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  2.3 Find nearest neighbor
&lt;/h2&gt;

&lt;p&gt;To evaluate the outliers, we calculate the nearest neighbor image with the &lt;a href="https://github.com/spotify/annoy"&gt;Annoy library &lt;/a&gt;using the fine-tuned model only. The resulting images are stored in the original DataFrame (df):&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from annoy import AnnoyIndex
import pandas as pd
def nearest_neighbor_annoy(
    df, embedding_name="embedding", threshold=0.3, tree_size=100
):
    """
    Find nearest neighbor using annoy.
    Args:
        df: dataframe with embeddings
        embedding_name: name of the embedding column
        threshold: threshold for outlier detection
        tree_size: tree size for annoy
    Returns:
        new dataframe with nearest neighbor information
    """
    embs = df[embedding_name]
    t = AnnoyIndex(len(embs[0]), "angular")
    for idx, x in enumerate(embs):
        t.add_item(idx, x)
    t.build(tree_size)
    images = df["image"]
    df_nn = pd.DataFrame()
    nn_id = [t.get_nns_by_item(i, 2)[1] for i in range(len(embs))]
    df_nn["nn_id"] = nn_id
    df_nn["nn_image"] = [images[i] for i in nn_id]
    df_nn["nn_distance"] = [t.get_distance(i, nn_id[i]) for i in range(len(embs))]
    df_nn["nn_flag"] = df_nn.nn_distance &amp;lt; threshold
    return df_nn

df_nn = nearest_neighbor_annoy(
    df, embedding_name="embedding_ft", threshold=0.3, tree_size=100
)
df["nn_image"] = df_nn["nn_image"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  2.4 Visualize
&lt;/h2&gt;

&lt;p&gt;For visualization with &lt;a href="https://github.com/Renumics/spotlight"&gt;Spotlight&lt;/a&gt; purposes, a new “label_str” column is created in the DataFrame by mapping integer labels to their string representations using a lambda function. The dtypes dictionary is used to specify the data type of each column to get the proper visualization, while the layout determines the arrangement and displayed columns in the visualization:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from renumics import spotlight
df["label_str"] = df["labels"].apply(lambda x: ds.features["labels"].int2str(x))
dtypes = {
    "nn_image": spotlight.Image,
    "image": spotlight.Image,
    "embedding_ft": spotlight.Embedding,
    "embedding_foundation": spotlight.Embedding,
}
spotlight.show(
    df,
    dtype=dtypes,
    layout="https://spotlight.renumics.com/resources//layout_pre_post_ft.json",
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will open a new browser window:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2uvSXQ_2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/4966/1%2ALY0o_i9H6AFRCIAO9hNp4A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2uvSXQ_2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/4966/1%2ALY0o_i9H6AFRCIAO9hNp4A.png" alt="Pre and post fine-tuning embeddings for CIFAR-10: UMAP and 8 worst outliers and their nearest neighbor in the dataset— visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight), source: created by the author." width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the visualization section, the top left displays a comprehensive table showing all the fields present in the dataset. Images classified as outlier by embeddings from the foundations model are selected. On the top right, you can observe two UMAP representations: the first represents the embeddings generated from the foundation model, while the second represents the embeddings from the fine-tuned model. In the Bottom the selected images are display together with their nearest neigbor in den dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  3 Results
&lt;/h2&gt;

&lt;p&gt;Now lets check the results for all datasets. You can go through all steps of section 2 using different input datasets to reproduce the results, or you can load preprocessed datasets using the code snippets below. Or you can checkout the linked online demos.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. 1 CIFAR-10
&lt;/h2&gt;

&lt;p&gt;Load the &lt;a href="https://huggingface.co/datasets/renumics/cifar10-outlier"&gt;prepared CIFAR-10 dataset&lt;/a&gt; [3] with&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from renumics import spotlight
import datasets
ds = datasets.load_dataset("renumics/cifar10-outlier", split="train")
df = ds.rename_columns({"img": "image", "label": "labels"}).to_pandas()
df["label_str"] = df["labels"].apply(lambda x: ds.features["label"].int2str(x))
dtypes = {
    "nn_image": spotlight.Image,
    "image": spotlight.Image,
    "embedding_ft": spotlight.Embedding,
    "embedding_foundation": spotlight.Embedding,
}
spotlight.show(
    df,
    dtype=dtypes,
    layout="https://spotlight.renumics.com/resources/layout_pre_post_ft.json",
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;or checkout the online demo at &lt;a href="https://huggingface.co/spaces/renumics/cifar10-outlier"&gt;https://huggingface.co/spaces/renumics/cifar10-outlier&lt;/a&gt; to examine the outliers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5Xo29js4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2APkpnDzxFX0EppIVGKtDldw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5Xo29js4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2APkpnDzxFX0EppIVGKtDldw.png" alt="Pre fine-tuning embeddings for cifar 10: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight), source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sF6-IGj3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AljtZ5LxIht8nR8ECVvKNWw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sF6-IGj3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AljtZ5LxIht8nR8ECVvKNWw.png" alt="Post fine-tuning embeddings for cifar10: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight); source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The UMAP visualization of the embeddings after fine-tuning reveals distinct patterns where certain classes are completely separated from all others, while some may be connected to only one or two other classes.&lt;/p&gt;

&lt;p&gt;The outliers detected in CIFAR-10 using pre-fine-tuning embeddings do not appear to be significantly uncommon, as they have relatively similar neighboring images. In contrast, the outliers identified with post-fine-tuning embeddings are distinct and highly uncommon within the dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.2 CIFAR-100
&lt;/h2&gt;

&lt;p&gt;Load the &lt;a href="https://huggingface.co/datasets/renumics/cifar100-outlier"&gt;prepared CIFAR-100 dataset&lt;/a&gt; [3] with&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from renumics import spotlight
import datasets
ds = datasets.load_dataset("renumics/cifar100-outlier", split="train")
df = ds.rename_columns({"img": "image", "fine_label": "labels"}).to_pandas()
df["label_str"] = df["labels"].apply(lambda x: ds.features["fine_label"].int2str(x))
dtypes = {
    "nn_image": spotlight.Image,
    "image": spotlight.Image,
    "embedding_ft": spotlight.Embedding,
    "embedding_foundation": spotlight.Embedding,
}
spotlight.show(
    df,
    dtype=dtypes,
    layout="https://spotlight.renumics.com/resources/layout_pre_post_ft.json",
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;or checkout the online demo at &lt;a href="https://huggingface.co/spaces/renumics/cifar100-outlier"&gt;huggingface.co/spaces/renumics/cifar100-outlier&lt;/a&gt; to examine the outliers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qrED_Jlv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AEbiUlzXdL5_KpBM1mH4eBQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qrED_Jlv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AEbiUlzXdL5_KpBM1mH4eBQ.png" alt="Pre fine-tuning embeddings for cifar100: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight); source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jfGrIH79--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2Abr9-uLDC41rsVlD7VpwDEw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jfGrIH79--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2Abr9-uLDC41rsVlD7VpwDEw.png" alt="Post fine-tuning embeddings for cifar100: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight); source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When examining the embeddings of CIFAR-100, which consists of 100 classes, we observe that even after fine-tuning, there are still more connected classes compared to the pre-fine-tuning embeddings. However, the structure within the embedding space becomes noticeably more defined and organized&lt;/p&gt;

&lt;p&gt;The pre-fine-tuning embeddings do not show clear outliers that stand out from their neighboring images, indicating limited effectiveness in outlier detection. However, when utilizing post-fine-tuning embeddings, the performance improves. Out of the six outliers identified, the first three are effectively detected as uncommon within the dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.3 MNIST
&lt;/h2&gt;

&lt;p&gt;Load the &lt;a href="https://huggingface.co/datasets/renumics/mnist-outlier"&gt;prepared MNIST dataset&lt;/a&gt; [4] with&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from renumics import spotlight
import datasets
ds = datasets.load_dataset("renumics/mnist-outlier", split="train")
df = ds.rename_columns({"label": "labels"}).to_pandas()
df["label_str"] = df["labels"].apply(lambda x: ds.features["label"].int2str(x))
dtypes = {
    "nn_image": spotlight.Image,
    "image": spotlight.Image,
    "embedding_ft": spotlight.Embedding,
    "embedding_foundation": spotlight.Embedding,
}
spotlight.show(
    df,
    dtype=dtypes,
    layout="https://spotlight.renumics.com/resources/layout_pre_post_ft.json",
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;or checkout the online demo at &lt;a href="https://huggingface.co/spaces/renumics/mnist-outlier"&gt;huggingface.co/spaces/renumics/mnist-outlier&lt;/a&gt; to examine the outliers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vh1ZI3Es--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2ASdiv-7gOdkhvXt4wZjG-BA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vh1ZI3Es--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2ASdiv-7gOdkhvXt4wZjG-BA.png" alt="Pre fine-tuning embeddings for mnist: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight); source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NSiilvAM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2Arn85yW6nO3OZ_P1vsvcuug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NSiilvAM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2Arn85yW6nO3OZ_P1vsvcuug.png" alt="Post fine-tuning embeddings for mnist: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight); source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During the fine-tuning of MNIST, the embeddings experience significant changes. Pre-fine-tuning, there may be overlapping regions between different digit classes, making it challenging to distinguish them based on embedding proximity alone. However, after fine-tuning, the embeddings exhibit clearer separations between the digit classes.&lt;/p&gt;

&lt;p&gt;The pre-fine-tuning embeddings reveal only one outlier that stands out from the neighboring images, indicating a moderate performance in outlier detection. However, when utilizing post-fine-tuning embeddings, the detection of outliers improves. Approximately 3 to 4 outliers could be identified as highly uncommon within the dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.4 Beans
&lt;/h2&gt;

&lt;p&gt;Load the &lt;a href="https://huggingface.co/datasets/renumics/beans-outlier"&gt;prepared beans dataset&lt;/a&gt; [3] with&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from renumics import spotlight
import datasets
ds = datasets.load_dataset("renumics/beans-outlier", split="train")
df = ds.to_pandas()
df["label_str"] = df["labels"].apply(lambda x: ds.features["labels"].int2str(x))
dtypes = {
    "nn_image": spotlight.Image,
    "image": spotlight.Image,
    "embedding_ft": spotlight.Embedding,
    "embedding_foundation": spotlight.Embedding,
}
spotlight.show(
    df,
    dtype=dtypes,
    layout="https://spotlight.renumics.com/resources/layout_pre_post_ft.json",
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;or checkout the online demo at &lt;a href="https://huggingface.co/spaces/renumics/beans-outlier"&gt;huggingface.co/spaces/renumics/beans-outlier&lt;/a&gt; to examine the outliers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5ZVWypDv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AQJLkk0o_Js7hmWLp92aCXQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5ZVWypDv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AQJLkk0o_Js7hmWLp92aCXQ.png" alt="Pre fine-tuning embeddings for beans: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight); source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0PB8smak--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AM96J8JZhLfUb--OAdCuhsQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0PB8smak--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/3768/1%2AM96J8JZhLfUb--OAdCuhsQ.png" alt="Post fine-tuning embeddings for beans: UMAP and 6 worst outliers — visualized with [github.com/renumics/spotlight](http://github.com/renumics/spotlight); source: created by the author." width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Beans dataset, after fine-tuning, most of the embeddings exhibit complete separation between the three classes. However, a few cases still show slight overlaps, possibly due to similarities between certain types of beans or misclassifications.&lt;/p&gt;

&lt;p&gt;The outlier detection using both pre-fine-tuning and post-fine-tuning embeddings does not yield significant outliers that deviate from the norm. The identified outliers are not distinct or uncommon within the dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  4 Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, fine-tuning has a significant impact on embeddings in image classification. Before fine-tuning, embeddings provide general-purpose representations, while after fine-tuning, they capture specific features for the task at hand.&lt;/p&gt;

&lt;p&gt;This distinction is clearly reflected in the UMAP visualizations, where post-fine-tuning embeddings exhibit more structured patterns, with certain classes completely separated from others.&lt;/p&gt;

&lt;p&gt;For outlier detection, using post-fine-tuning embeddings can be more effective. However, it’s worth noting that calculating outliers based on the probabilities obtained from fine-tuning might yield even better results compared to relying solely on the embeddings.&lt;/p&gt;

&lt;p&gt;Both pre-fine-tuning and post-fine-tuning embeddings have their unique strengths and should be used in combination to achieve a comprehensive analysis in image classification and analysis tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;[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 &lt;a href="https://arxiv.org/abs/2010.11929"&gt;An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale&lt;/a&gt; (2020), arXiv&lt;/p&gt;

&lt;p&gt;[2] Ze Liu, Yutong Lin, Yue Cao, Han Hu, Yixuan Wei, Zheng Zhang, Stephen Lin, Baining Guo &lt;a href="https://arxiv.org/abs/2103.14030"&gt;Swin Transformer: Hierarchical Vision Transformer using Shifted Windows&lt;/a&gt; (2021), arXiv&lt;/p&gt;

&lt;p&gt;[3] Alex Krizhevsky, &lt;a href="https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf"&gt;Learning Multiple Layers of Features from Tiny Images&lt;/a&gt; (2009), University Toronto&lt;/p&gt;

&lt;p&gt;[4] Yann LeCun, Corinna Cortes, Christopher J.C. Burges, &lt;a href="http://yann.lecun.com/exdb/mnist/"&gt;MNIST handwritten digit database&lt;/a&gt; (2010), ATT Labs [Online]&lt;/p&gt;

&lt;p&gt;[5] Makerere AI Lab, &lt;a href="http://github.com/AI-Lab-Makerere/ibean/"&gt;Bean disease dataset&lt;/a&gt; (2020), AIR Lab Makerere University&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
