From dbe3b9b99ecd21dcffa2493ae56d1381d6113186 Mon Sep 17 00:00:00 2001 From: Sayak Paul Date: Tue, 7 Feb 2023 09:53:34 +0530 Subject: [PATCH] add: example on fine-tuning for image classification. --- examples/image_classification/README.md | 7 + .../image_classification_peft_lora.ipynb | 2678 +++++++++++++++++ 2 files changed, 2685 insertions(+) create mode 100644 examples/image_classification/README.md create mode 100644 examples/image_classification/image_classification_peft_lora.ipynb diff --git a/examples/image_classification/README.md b/examples/image_classification/README.md new file mode 100644 index 0000000..b0756b3 --- /dev/null +++ b/examples/image_classification/README.md @@ -0,0 +1,7 @@ +# Fine-tuning for image classification using LoRA and 🤗 PEFT + +[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/sayakpaul/peft/blob/example/img-cls/examples/image_classification/image_classification_peft_lora.ipynb) + +We provide a notebook (`image_classification_peft_lora.ipynb`) where we learn how to use [LoRA](https://arxiv.org/abs/2106.09685) from 🤗 PEFT to fine-tune an image classification modelby ONLY using **0.6%** of the original trainable parameters of the model. + +LoRA adds low-rank "update matrices" to certain blocks in the underlying model (in this case the attention blocks) and ONLY trains those matrices during fine-tuning. During inference, these update matrices are _merged_ with the original model parameters. For more details, check out the [original LoRA paper](https://arxiv.org/abs/2106.09685). \ No newline at end of file diff --git a/examples/image_classification/image_classification_peft_lora.ipynb b/examples/image_classification/image_classification_peft_lora.ipynb new file mode 100644 index 0000000..9c25771 --- /dev/null +++ b/examples/image_classification/image_classification_peft_lora.ipynb @@ -0,0 +1,2678 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "71GTxOD71mEn" + }, + "source": [ + "## Introduction\n", + "\n", + "In this notebook, we will learn how to use [LoRA](https://arxiv.org/abs/2106.09685) from 🤗 PEFT to fine-tune an image classification modelby ONLY using **0.6%** of the original trainable parameters of the model. \n", + "\n", + "LoRA adds low-rank \"update matrices\" to certain blocks in the underlying model (in this case the attention blocks) and ONLY trains those matrices during fine-tuning. During inference, these update matrices are _merged_ with the original model parameters. For more details, check out the [original LoRA paper](https://arxiv.org/abs/2106.09685). \n", + "\n", + "Let's get started by installing the dependencies. " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "0a_bETbqv4P7" + }, + "source": [ + "## Install dependencies\n", + "\n", + "Here we're installing `peft` from source to ensure we have access to all the bleeding edge features of `peft`. " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Z0_5BYt8hobv", + "outputId": "50729fe8-b68e-4d3b-e713-d79ee39d4792" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n", + " Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n", + " Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.3/6.3 MB\u001b[0m \u001b[31m55.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m199.7/199.7 KB\u001b[0m \u001b[31m25.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m81.4/81.4 KB\u001b[0m \u001b[31m12.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m462.8/462.8 KB\u001b[0m \u001b[31m41.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.6/7.6 MB\u001b[0m \u001b[31m105.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m190.3/190.3 KB\u001b[0m \u001b[31m23.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m213.0/213.0 KB\u001b[0m \u001b[31m27.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m132.0/132.0 KB\u001b[0m \u001b[31m17.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.3/76.3 MB\u001b[0m \u001b[31m22.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m140.6/140.6 KB\u001b[0m \u001b[31m19.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25h Building wheel for peft (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n" + ] + } + ], + "source": [ + "!pip install transformers accelerate evaluate datasets loralib git+https://github.com/huggingface/peft -q" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Y8dSVHoIv7HC" + }, + "source": [ + "## Authentication\n", + "\n", + "We will share our fine-tuned model at the end of training. So, to do that we just authenticate using our 🤗 token. This token is available from [here](https://huggingface.co/settings/tokens). If you don't have a 🤗 account already, we highly encourage you to do so; it's free!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "31Zv6rFYr37d" + }, + "outputs": [], + "source": [ + "from huggingface_hub import notebook_login\n", + "\n", + "notebook_login()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "AX7aJaIKjbCF" + }, + "source": [ + "## Check the library versions" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ejkn8GBzh_DB", + "outputId": "7b0f3a4a-381a-4399-ff30-8e2db0112f47" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "===================================BUG REPORT===================================\n", + "Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues\n", + "================================================================================\n" + ] + } + ], + "source": [ + "import transformers \n", + "import accelerate\n", + "import peft" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "A833xxo3ir28", + "outputId": "f8aa39f1-6497-403c-a1d1-4b55b5786c51" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Transformers version: 4.26.0\n", + "Accelerate version: 0.16.0\n", + "PEFT version: 0.1.0.dev0\n" + ] + } + ], + "source": [ + "print(f\"Transformers version: {transformers.__version__}\")\n", + "print(f\"Accelerate version: {accelerate.__version__}\")\n", + "print(f\"PEFT version: {peft.__version__}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Po1Ve9u5v_Ul" + }, + "source": [ + "## Select a model checkpoint to fine-tune" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "id": "vhvCQpP-isJr" + }, + "outputs": [], + "source": [ + "model_checkpoint = (\n", + " \"google/vit-base-patch16-224-in21k\" # pre-trained model from which to fine-tune\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "UKN3rMAsjgEz" + }, + "source": [ + "## Load a dataset\n", + "\n", + "We're only loading the first 5000 instances from the training set of the [Food-101 dataset](https://huggingface.co/datasets/food101) to keep this example runtime short. " + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "rI0d2_liitUr", + "outputId": "8363e871-54f1-42fc-e7e9-61f215cf8ac5" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:datasets.builder:Found cached dataset food101 (/root/.cache/huggingface/datasets/food101/default/0.0.0/7cebe41a80fb2da3f08fcbef769c8874073a86346f7fb96dc0847d4dfc318295)\n" + ] + } + ], + "source": [ + "from datasets import load_dataset\n", + "\n", + "dataset = load_dataset(\"food101\", split=\"train[:5000]\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pUjwa7G8jjgW" + }, + "source": [ + "## Prepare datasets for training and evaluation" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "-Gg9xDW22yPD" + }, + "source": [ + "1. Prepare `label2id` and `id2label` dictionaries. This will come in handy when performing inference and for metadata information. " + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 35 + }, + "id": "GC3wK2aciz53", + "outputId": "cbcd5507-b109-43c1-bcba-bbe7e3822c97" + }, + "outputs": [ + { + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "'baklava'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "labels = dataset.features[\"label\"].names\n", + "label2id, id2label = dict(), dict()\n", + "for i, label in enumerate(labels):\n", + " label2id[label] = i\n", + " id2label[i] = label\n", + "\n", + "id2label[2]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "xgHUxR_-2-h1" + }, + "source": [ + "2. We load the image processor of the model we're fine-tuning." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "3hmq4a_fi2IX", + "outputId": "9e5004f1-1f4b-43e0-f7cf-fbd86b336e64" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "ViTImageProcessor {\n", + " \"do_normalize\": true,\n", + " \"do_rescale\": true,\n", + " \"do_resize\": true,\n", + " \"image_mean\": [\n", + " 0.5,\n", + " 0.5,\n", + " 0.5\n", + " ],\n", + " \"image_processor_type\": \"ViTImageProcessor\",\n", + " \"image_std\": [\n", + " 0.5,\n", + " 0.5,\n", + " 0.5\n", + " ],\n", + " \"resample\": 2,\n", + " \"rescale_factor\": 0.00392156862745098,\n", + " \"size\": {\n", + " \"height\": 224,\n", + " \"width\": 224\n", + " }\n", + "}" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from transformers import AutoImageProcessor\n", + "\n", + "image_processor = AutoImageProcessor.from_pretrained(model_checkpoint)\n", + "image_processor" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "EsZYbWKS3cPK" + }, + "source": [ + "As one might notice, the `image_processor` has useful information on which size the training and evaluation images should be resized, stats that should be used to normalize the pixel values, etc. " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "jKFuKh9P3E-e" + }, + "source": [ + "3. Using the image processor we prepare transformation functions for the datasets. These functions will include augmentation and pixel scaling. " + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "Zj33iIoCi3Uy" + }, + "outputs": [], + "source": [ + "from torchvision.transforms import (\n", + " CenterCrop,\n", + " Compose,\n", + " Normalize,\n", + " RandomHorizontalFlip,\n", + " RandomResizedCrop,\n", + " Resize,\n", + " ToTensor,\n", + ")\n", + "\n", + "normalize = Normalize(mean=image_processor.image_mean, std=image_processor.image_std)\n", + "train_transforms = Compose(\n", + " [\n", + " RandomResizedCrop(image_processor.size[\"height\"]),\n", + " RandomHorizontalFlip(),\n", + " ToTensor(),\n", + " normalize,\n", + " ]\n", + ")\n", + "\n", + "val_transforms = Compose(\n", + " [\n", + " Resize(image_processor.size[\"height\"]),\n", + " CenterCrop(image_processor.size[\"height\"]),\n", + " ToTensor(),\n", + " normalize,\n", + " ]\n", + ")\n", + "\n", + "\n", + "def preprocess_train(example_batch):\n", + " \"\"\"Apply train_transforms across a batch.\"\"\"\n", + " example_batch[\"pixel_values\"] = [\n", + " train_transforms(image.convert(\"RGB\")) for image in example_batch[\"image\"]\n", + " ]\n", + " return example_batch\n", + "\n", + "\n", + "def preprocess_val(example_batch):\n", + " \"\"\"Apply val_transforms across a batch.\"\"\"\n", + " example_batch[\"pixel_values\"] = [\n", + " val_transforms(image.convert(\"RGB\")) for image in example_batch[\"image\"]\n", + " ]\n", + " return example_batch" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "X4IPqOeK3UKW" + }, + "source": [ + "4. We split our mini dataset into training and validation. " + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "_uplVC66i5Gd" + }, + "outputs": [], + "source": [ + "# split up training into training + validation\n", + "splits = dataset.train_test_split(test_size=0.1)\n", + "train_ds = splits[\"train\"]\n", + "val_ds = splits[\"test\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "KV5Mlf4e3X5K" + }, + "source": [ + "5. We set the transformation functions to the datasets accordingly. " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "0QuiqyiXi9fN" + }, + "outputs": [], + "source": [ + "train_ds.set_transform(preprocess_train)\n", + "val_ds.set_transform(preprocess_val)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "sA1Cq97Ijpp8" + }, + "source": [ + "## Load and prepare a model \n", + "\n", + "In this section, we first load the model we want to fine-tune. " + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "id": "Zxgrg45Xty2S" + }, + "outputs": [], + "source": [ + "def print_trainable_parameters(model):\n", + " \"\"\"\n", + " Prints the number of trainable parameters in the model.\n", + " \"\"\"\n", + " trainable_params = 0\n", + " all_param = 0\n", + " for _, param in model.named_parameters():\n", + " all_param += param.numel()\n", + " if param.requires_grad:\n", + " trainable_params += param.numel()\n", + " print(\n", + " f\"trainable params: {trainable_params} || all params: {all_param} || trainable%: {100 * trainable_params / all_param:.2f}\"\n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "TYjC-A-44bHO" + }, + "source": [ + "The `LoraModel` class that we will use in a moment is wrapper of the original model to be fine-tuned. So, it's important for us to initialize the original model correctly. As such, we initialize it by specifying the `label2id` and `id2label` so that `AutoModelForImageClassification` can initialize a append classification head to the underlying model, adapted for our dataset. We can confirm this from the warning below:\n", + "\n", + "```\n", + "Some weights of ViTForImageClassification were not initialized from the model checkpoint at google/vit-base-patch16-224-in21k and are newly initialized: ['classifier.weight', 'classifier.bias']\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "3J5DokIqi-wV", + "outputId": "6c3d4bdf-8442-4f3a-93db-4eb0b1e16a70" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Some weights of the model checkpoint at google/vit-base-patch16-224-in21k were not used when initializing ViTForImageClassification: ['pooler.dense.bias', 'pooler.dense.weight']\n", + "- This IS expected if you are initializing ViTForImageClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).\n", + "- This IS NOT expected if you are initializing ViTForImageClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).\n", + "Some weights of ViTForImageClassification were not initialized from the model checkpoint at google/vit-base-patch16-224-in21k and are newly initialized: ['classifier.weight', 'classifier.bias']\n", + "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "trainable params: 85876325 || all params: 85876325 || trainable%: 100.00\n" + ] + } + ], + "source": [ + "from transformers import AutoModelForImageClassification, TrainingArguments, Trainer\n", + "\n", + "model = AutoModelForImageClassification.from_pretrained(\n", + " model_checkpoint,\n", + " label2id=label2id,\n", + " id2label=id2label,\n", + " ignore_mismatched_sizes=True, # provide this in case you're planning to fine-tune an already fine-tuned checkpoint\n", + ")\n", + "print_trainable_parameters(model)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "1EqYCiTy5F9N" + }, + "source": [ + "Also, take note of the number of total trainable parameters of `model`: it's 100%! We'll compare this number to that of the LoRA model.\n", + "\n", + "We now use the `LoraModel` to wrap `model` so that the \"update\" matrices are added to the respective places. " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "LNASJrqoi_8-", + "outputId": "04a1672d-0915-4335-f66f-cea330f57220" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "trainable params: 589824 || all params: 86466149 || trainable%: 0.68\n" + ] + } + ], + "source": [ + "from peft import LoraConfig, LoraModel\n", + "\n", + "config = LoraConfig(\n", + " r=16,\n", + " lora_alpha=16,\n", + " target_modules=[\"query\", \"value\"],\n", + " lora_dropout=0.1,\n", + " bias=\"none\",\n", + " modules_to_save=[\"classifier\"],\n", + ")\n", + "lora_model = LoraModel(config, model)\n", + "print_trainable_parameters(lora_model)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "OKQeuUDhjC3E" + }, + "source": [ + "Let's unpack what's going on here. \n", + "\n", + "In order for LoRA to take effect, we need to specify the target modules to `LoraConfig` so that `LoraModel` knows which modules inside our model needs to be amended with LoRA matrices. In this case, we're only interested in targetting the query and value matrices of the attention blocks of the base model. Since the parameters corresponding to these matrices are \"named\" with `query` and `value` respectively, we specify them accordingly in the `target_modules` argument of `LoraConfig`. \n", + "\n", + "We also specify `modules_to_save`. After we wrap our base model `model` with `LoraModel` along with the `config`, we get a new model where only the LoRA parameters are trainable (so-called \"update matrices\") while the pre-trained parameters are kept frozen. These include the parameters of the randomly initialized classifier parameters too. This is NOT we want when fine-tuning the base model on our custom dataset. To ensure that the classifier parameters are also trained, we specify `modules_to_save`. This also ensures that these modules are serialized alongside the LoRA trainable parameters when using utilities like `save_pretrained()` and `push_to_hub()`. \n", + "\n", + "Regarding the other parameters:\n", + "\n", + "* `r`: The dimension used by the LoRA update matrices.\n", + "* `alpha`: Scaling factor.\n", + "* `bias`: Specifying if the `bias` parameters should be trained. `None` denotes none of the `bias` parameters will be trained. \n", + "\n", + "`r` and `alpha` together control the total number of final trainable parameters when using LoRA giving us the flexbility to balance a trade-off between end performance and compute efficiency.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mRbdQvEujHHP" + }, + "source": [ + "We can also how many parameters we're actually training. Since we're interested in performing **parameter-efficient fine-tuning**, we should expect to notice a less number of trainable parameters from the `lora_model` in comparison to the original `model` which is indeed the case here. " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "m6lBFL_D-w7k" + }, + "source": [ + "## Training arguments\n", + "\n", + "We will leverage [🤗 Trainer](https://huggingface.co/docs/transformers/main_classes/trainer) for fine-tuning. It accepts several arguments which we wrap using [`TrainingArguments`](https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments). " + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "-iD2F33JjIzC" + }, + "outputs": [], + "source": [ + "from transformers import TrainingArguments, Trainer\n", + "\n", + "\n", + "model_name = model_checkpoint.split(\"/\")[-1]\n", + "batch_size = 128\n", + "\n", + "args = TrainingArguments(\n", + " f\"{model_name}-finetuned-lora-food101\",\n", + " remove_unused_columns=False,\n", + " evaluation_strategy=\"epoch\",\n", + " save_strategy=\"epoch\",\n", + " learning_rate=5e-3,\n", + " per_device_train_batch_size=batch_size,\n", + " gradient_accumulation_steps=4,\n", + " per_device_eval_batch_size=batch_size,\n", + " fp16=True,\n", + " num_train_epochs=5,\n", + " logging_steps=10,\n", + " load_best_model_at_end=True,\n", + " metric_for_best_model=\"accuracy\",\n", + " push_to_hub=True,\n", + " label_names=[\"labels\"],\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "7_SA1HcVAUNP" + }, + "source": [ + "Some things to note here:\n", + "\n", + "* We're using a larger batch size since there is only a handful of parameters to train. \n", + "* Larger learning rate than the normal (1e-5 for example). \n", + "\n", + "All of these things are a byproduct of the fact that we're training only a small number of parameters. This can potentially also reduce the need to conduct expensive hyperparameter tuning experiments. " + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XOlDXQnrjuc_" + }, + "source": [ + "## Prepare evaluation metric" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "id": "guYecwzyjLmj" + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "import evaluate\n", + "\n", + "\n", + "metric = evaluate.load(\"accuracy\")\n", + "\n", + "# the compute_metrics function takes a Named Tuple as input:\n", + "# predictions, which are the logits of the model as Numpy arrays,\n", + "# and label_ids, which are the ground-truth labels as Numpy arrays.\n", + "def compute_metrics(eval_pred):\n", + " \"\"\"Computes accuracy on a batch of predictions\"\"\"\n", + " predictions = np.argmax(eval_pred.predictions, axis=1)\n", + " return metric.compute(predictions=predictions, references=eval_pred.label_ids)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mNeLDXaE_989" + }, + "source": [ + "## Collation function\n", + "\n", + "This is used by `Trainer` to gather a batch of training and evaluation examples and prepare them in a format that is acceptable by the underlying model. " + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "id": "qIicZRMrjNC3" + }, + "outputs": [], + "source": [ + "import torch\n", + "\n", + "\n", + "def collate_fn(examples):\n", + " pixel_values = torch.stack([example[\"pixel_values\"] for example in examples])\n", + " labels = torch.tensor([example[\"label\"] for example in examples])\n", + " return {\"pixel_values\": pixel_values, \"labels\": labels}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "YpWudVaJjwkx" + }, + "source": [ + "## Train and evaluate" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000, + "referenced_widgets": [ + "664352207c6c4aa1a7fc7b2ac69dee49", + "d74fcfba2e15485a8f524b49d6393fb3", + "869c5bbf8ede4ce1b44501e3f7327e28", + "b7078020c81e4d7396a5f8c17651cf46", + "e7a80a88f21d41b4a0f0d38b561f6289", + "3b174fc794db469597347c8449ddf2d9", + "f953340acec44614b740ed0b0f395734", + "8293a7080ec745ae8f822ae7826ffb47", + "06bb8ca733eb42a9907082f443ba9477", + "327cc8c13a5345c7be13caf4383e0665", + "450548e393804fed9bbe69311ca4dcee" + ] + }, + "id": "p2-RStfgjOQt", + "outputId": "37073143-2aef-4af6-805d-a6a9df2ca3b4" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/content/vit-base-patch16-224-in21k-finetuned-lora-food101 is already a clone of https://huggingface.co/sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101. Make sure you pull the latest changes with `repo.git_pull()`.\n", + "WARNING:huggingface_hub.repository:/content/vit-base-patch16-224-in21k-finetuned-lora-food101 is already a clone of https://huggingface.co/sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101. Make sure you pull the latest changes with `repo.git_pull()`.\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "664352207c6c4aa1a7fc7b2ac69dee49", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Clean file pytorch_model.bin: 0%| | 1.00k/329M [00:00\n", + " \n", + " \n", + " [45/45 03:58, Epoch 5/5]\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
EpochTraining LossValidation LossAccuracy
1No log3.5659260.414000
24.0640003.1013440.642000
33.3187002.7583890.794000
42.8951002.5366660.836000
52.6147002.4537190.842000

" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "***** Running Evaluation *****\n", + " Num examples = 500\n", + " Batch size = 128\n", + "Saving model checkpoint to vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-9\n", + "Configuration saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-9/config.json\n", + "Model weights saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-9/pytorch_model.bin\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-9/preprocessor_config.json\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/preprocessor_config.json\n", + "***** Running Evaluation *****\n", + " Num examples = 500\n", + " Batch size = 128\n", + "Saving model checkpoint to vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-18\n", + "Configuration saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-18/config.json\n", + "Model weights saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-18/pytorch_model.bin\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-18/preprocessor_config.json\n", + "***** Running Evaluation *****\n", + " Num examples = 500\n", + " Batch size = 128\n", + "Saving model checkpoint to vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-27\n", + "Configuration saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-27/config.json\n", + "Model weights saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-27/pytorch_model.bin\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-27/preprocessor_config.json\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/preprocessor_config.json\n", + "***** Running Evaluation *****\n", + " Num examples = 500\n", + " Batch size = 128\n", + "Saving model checkpoint to vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-36\n", + "Configuration saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-36/config.json\n", + "Model weights saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-36/pytorch_model.bin\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-36/preprocessor_config.json\n", + "***** Running Evaluation *****\n", + " Num examples = 500\n", + " Batch size = 128\n", + "Saving model checkpoint to vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-45\n", + "Configuration saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-45/config.json\n", + "Model weights saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-45/pytorch_model.bin\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-45/preprocessor_config.json\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/preprocessor_config.json\n", + "\n", + "\n", + "Training completed. Do not forget to share your model on huggingface.co/models =)\n", + "\n", + "\n", + "Loading best model from vit-base-patch16-224-in21k-finetuned-lora-food101/checkpoint-45 (score: 0.842).\n" + ] + } + ], + "source": [ + "trainer = Trainer(\n", + " model,\n", + " args,\n", + " train_dataset=train_ds,\n", + " eval_dataset=val_ds,\n", + " tokenizer=image_processor,\n", + " compute_metrics=compute_metrics,\n", + " data_collator=collate_fn,\n", + ")\n", + "train_results = trainer.train()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "b2NENHxHCejv" + }, + "source": [ + "In just a few minutes, we have a fine-tuned model with 84.2% validation accuracy. Also, note that we used a very small subset of the training dataset which is definitely impacting the results. " + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 198 + }, + "id": "_MAd2906jQKG", + "outputId": "bf1aa394-8520-4e01-b264-7eae4eb0ca9c" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "***** Running Evaluation *****\n", + " Num examples = 500\n", + " Batch size = 128\n" + ] + }, + { + "data": { + "text/html": [ + "\n", + "

\n", + " \n", + " \n", + " [4/4 00:02]\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "{'eval_loss': 2.453718662261963,\n", + " 'eval_accuracy': 0.842,\n", + " 'eval_runtime': 3.7766,\n", + " 'eval_samples_per_second': 132.395,\n", + " 'eval_steps_per_second': 1.059,\n", + " 'epoch': 5.0}" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "trainer.evaluate(val_ds)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qo_scDEyAQER" + }, + "source": [ + "## Sharing your model and inference \n", + "\n", + "[TODO]" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 606, + "referenced_widgets": [ + "e80438ac4c724920870266a26c114aaa", + "0a4302d51e444bd186a60c44d687e364", + "4844a2187b654fbe82771813b01d66af", + "aa01155933e3484e88c9e301655d2db7", + "98549e134beb409cab475008fce4a35d", + "bbcc06f79da546069a83e80ca63be07e", + "336a22d2bcd147e886132dcf0f1d35e1", + "d2db09136bbe4f0886f7d49df91b4cf2", + "bccd590fa1ad40649432330a1a6c5575", + "bec8b9c3102d4beeb2b1c6f07034d144", + "afbd89198ebc4e35a27669a5ff61ab6a", + "d98cdc4493f84e4d92bb1e04dd4a9c6d", + "bf4ab273f71f47ebae98dc4a104e8e22", + "ac2419a65ee84d6c8e929d19bbb64648", + "a6b65edd2b59480998a8e89642357243", + "1afae18eed644726a1adf71dd36fa80e", + "59ce4e466bb44556a010f5e4661d18b2", + "7131f49dcc3f4ffc8d9f09dcd508b678", + "1c6e642bf5bd4411ab82ae21b110c06a", + "49891641c9ad45f3bcd0c818d61e2f91", + "e1671cd0bea74e55a3421d08eb8cc070", + "2a88a211c4694901b34ab518a0738ecd", + "c016d6b1d07549edb9a2c307fecb3100", + "eb399677ffac4b3997b6de8d3a385b87", + "b0d63d19626b424a991b413d1f4ede96", + "1f77381f52114642bc5c3d9bf6e97df6", + "41eb58de13ab4278ba2c9271a7f99101", + "63ec161d31d84d12bbab6bab422f644e", + "bd2b2c7670714d7187d99051a567ef7a", + "96cddc9c85e442d09516de4736bde7ed", + "57fdf7ca84bc4ac3bfb7134f8a20aefd", + "02f032cf567344d1a07b9742c1e89395", + "e532bba004c24176b629658710041531" + ] + }, + "id": "4dqRRCcGyGjp", + "outputId": "19a0babc-0273-4497-8fc2-219f1b7897e8" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Saving model checkpoint to vit-base-patch16-224-in21k-finetuned-lora-food101\n", + "Configuration saved in vit-base-patch16-224-in21k-finetuned-lora-food101/config.json\n", + "Model weights saved in vit-base-patch16-224-in21k-finetuned-lora-food101/pytorch_model.bin\n", + "Image processor saved in vit-base-patch16-224-in21k-finetuned-lora-food101/preprocessor_config.json\n", + "Several commits (2) will be pushed upstream.\n", + "WARNING:huggingface_hub.repository:Several commits (2) will be pushed upstream.\n", + "The progress bars may be unreliable.\n", + "WARNING:huggingface_hub.repository:The progress bars may be unreliable.\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "e80438ac4c724920870266a26c114aaa", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Upload file pytorch_model.bin: 0%| | 32.0k/329M [00:00 main\n", + "\n", + "WARNING:huggingface_hub.repository:remote: Scanning LFS files for validity... \n", + "remote: LFS file scan complete. \n", + "To https://huggingface.co/sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101\n", + " e877e50..4ada42e main -> main\n", + "\n", + "To https://huggingface.co/sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101\n", + " 4ada42e..5fdbe0d main -> main\n", + "\n", + "WARNING:huggingface_hub.repository:To https://huggingface.co/sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101\n", + " 4ada42e..5fdbe0d main -> main\n", + "\n" + ] + }, + { + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "'https://huggingface.co/sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101/commit/4ada42e122bcb831340bc1deb924cc1d574b3951'" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "trainer.push_to_hub()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "TyQvIcnFzLIV", + "outputId": "e5b7bc9a-32d1-48e6-f372-2a627dd4ab95" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Configuration saved in vit-base-patch16-224-in21k-finetuned-lora-food101/config.json\n", + "Model weights saved in vit-base-patch16-224-in21k-finetuned-lora-food101/pytorch_model.bin\n", + "Uploading the following files to sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101: pytorch_model.bin,config.json\n" + ] + }, + { + "data": { + "text/plain": [ + "CommitInfo(commit_url='https://huggingface.co/sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101/commit/430778499b3856a006868c5caa4ea75faa450c2a', commit_message='Upload ViTForImageClassification', commit_description='', oid='430778499b3856a006868c5caa4ea75faa450c2a', pr_url=None, pr_revision=None, pr_num=None)" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lora_model.push_to_hub(\"sayakpaul/vit-base-patch16-224-in21k-finetuned-lora-food101\")" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "pouB-RKyzo8Q", + "outputId": "76611fd1-764b-473a-d457-9baf5b103d07" + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Configuration saved in ./temp_lora_vit/config.json\n", + "Model weights saved in ./temp_lora_vit/pytorch_model.bin\n" + ] + } + ], + "source": [ + "peft_model_id = \"./temp_lora_vit\"\n", + "lora_model.save_pretrained(peft_model_id)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "2IkPRG3uz5_p", + "outputId": "5589bbb7-1fb6-4018-eb0d-d4f99694326c" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "total 330M\n", + "-rw-r--r-- 1 root root 5.4K Feb 7 04:04 config.json\n", + "-rw-r--r-- 1 root root 330M Feb 7 04:04 pytorch_model.bin\n" + ] + } + ], + "source": [ + "!ls -lh temp_lora_vit" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 461 + }, + "id": "IY78Ty570etw", + "outputId": "5e8f0756-847d-4031-d82b-cf14d4c39624" + }, + "outputs": [ + { + "ename": "ValueError", + "evalue": "ignored", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mHFValidationError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/usr/local/lib/python3.8/dist-packages/peft/utils/config.py\u001b[0m in \u001b[0;36mfrom_pretrained\u001b[0;34m(cls, pretrained_model_name_or_path, **kwargs)\u001b[0m\n\u001b[1;32m 99\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 100\u001b[0;31m \u001b[0mconfig_file\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mhf_hub_download\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpretrained_model_name_or_path\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mCONFIG_NAME\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 101\u001b[0m \u001b[0;32mexcept\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.8/dist-packages/huggingface_hub/utils/_validators.py\u001b[0m in \u001b[0;36m_inner_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 113\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0marg_name\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"repo_id\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 114\u001b[0;31m \u001b[0mvalidate_repo_id\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg_value\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 115\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.8/dist-packages/huggingface_hub/utils/_validators.py\u001b[0m in \u001b[0;36mvalidate_repo_id\u001b[0;34m(repo_id)\u001b[0m\n\u001b[1;32m 171\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mREPO_ID_REGEX\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmatch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrepo_id\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 172\u001b[0;31m raise HFValidationError(\n\u001b[0m\u001b[1;32m 173\u001b[0m \u001b[0;34m\"Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mHFValidationError\u001b[0m: Repo id must use alphanumeric chars or '-', '_', '.', '--' and '..' are forbidden, '-' and '.' cannot start or end the name, max length is 96: './temp_lora_vit'.", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mconfig\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPeftConfig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfrom_pretrained\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpeft_model_id\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m model = AutoModelForImageClassification.from_pretrained(\n\u001b[1;32m 6\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase_model_name_or_path\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.8/dist-packages/peft/utils/config.py\u001b[0m in \u001b[0;36mfrom_pretrained\u001b[0;34m(cls, pretrained_model_name_or_path, **kwargs)\u001b[0m\n\u001b[1;32m 100\u001b[0m \u001b[0mconfig_file\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mhf_hub_download\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpretrained_model_name_or_path\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mCONFIG_NAME\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 101\u001b[0m \u001b[0;32mexcept\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 102\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"Can't find config.json at '{pretrained_model_name_or_path}'\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 103\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 104\u001b[0m \u001b[0mloaded_attributes\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfrom_json_file\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mconfig_file\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mValueError\u001b[0m: Can't find config.json at './temp_lora_vit'" + ] + } + ], + "source": [ + "from peft import PeftConfig, PeftModel\n", + "\n", + "\n", + "config = PeftConfig.from_pretrained(peft_model_id)\n", + "model = AutoModelForImageClassification.from_pretrained(\n", + " config.base_model_name_or_path,\n", + ")\n", + "# Load the Lora model\n", + "inference_model = PeftModel.from_pretrained(model, peft_model_id)" + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "collapsed_sections": [ + "0a_bETbqv4P7", + "Y8dSVHoIv7HC", + "qo_scDEyAQER" + ], + "machine_shape": "hm", + "provenance": [] + }, + "gpuClass": "premium", + "kernelspec": { + "display_name": "peft-dev", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.2" + }, + "vscode": { + "interpreter": { + "hash": "62ba1781de76fc6672ab4d41176558d38a2895b3007f2161f5f79f77fdcaf8cf" + } + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "02f032cf567344d1a07b9742c1e89395": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "06bb8ca733eb42a9907082f443ba9477": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "ProgressStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "0a4302d51e444bd186a60c44d687e364": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_bbcc06f79da546069a83e80ca63be07e", + "placeholder": "​", + "style": "IPY_MODEL_336a22d2bcd147e886132dcf0f1d35e1", + "value": "Upload file pytorch_model.bin: 100%" + } + }, + "1afae18eed644726a1adf71dd36fa80e": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "1c6e642bf5bd4411ab82ae21b110c06a": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "1f77381f52114642bc5c3d9bf6e97df6": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_02f032cf567344d1a07b9742c1e89395", + "placeholder": "​", + "style": "IPY_MODEL_e532bba004c24176b629658710041531", + "value": " 9.99k/9.99k [00:51<?, ?B/s]" + } + }, + "2a88a211c4694901b34ab518a0738ecd": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "327cc8c13a5345c7be13caf4383e0665": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "336a22d2bcd147e886132dcf0f1d35e1": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "3b174fc794db469597347c8449ddf2d9": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "41eb58de13ab4278ba2c9271a7f99101": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "450548e393804fed9bbe69311ca4dcee": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "4844a2187b654fbe82771813b01d66af": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "FloatProgressModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_d2db09136bbe4f0886f7d49df91b4cf2", + "max": 344770029, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_bccd590fa1ad40649432330a1a6c5575", + "value": 344770029 + } + }, + "49891641c9ad45f3bcd0c818d61e2f91": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "ProgressStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "57fdf7ca84bc4ac3bfb7134f8a20aefd": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "ProgressStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "59ce4e466bb44556a010f5e4661d18b2": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "63ec161d31d84d12bbab6bab422f644e": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "664352207c6c4aa1a7fc7b2ac69dee49": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HBoxModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_d74fcfba2e15485a8f524b49d6393fb3", + "IPY_MODEL_869c5bbf8ede4ce1b44501e3f7327e28", + "IPY_MODEL_b7078020c81e4d7396a5f8c17651cf46" + ], + "layout": "IPY_MODEL_e7a80a88f21d41b4a0f0d38b561f6289" + } + }, + "7131f49dcc3f4ffc8d9f09dcd508b678": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "8293a7080ec745ae8f822ae7826ffb47": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "869c5bbf8ede4ce1b44501e3f7327e28": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "FloatProgressModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_8293a7080ec745ae8f822ae7826ffb47", + "max": 344770029, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_06bb8ca733eb42a9907082f443ba9477", + "value": 344770029 + } + }, + "96cddc9c85e442d09516de4736bde7ed": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "98549e134beb409cab475008fce4a35d": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "a6b65edd2b59480998a8e89642357243": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_e1671cd0bea74e55a3421d08eb8cc070", + "placeholder": "​", + "style": "IPY_MODEL_2a88a211c4694901b34ab518a0738ecd", + "value": " 357/357 [00:51<?, ?B/s]" + } + }, + "aa01155933e3484e88c9e301655d2db7": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_bec8b9c3102d4beeb2b1c6f07034d144", + "placeholder": "​", + "style": "IPY_MODEL_afbd89198ebc4e35a27669a5ff61ab6a", + "value": " 329M/329M [00:51<00:00, 7.19MB/s]" + } + }, + "ac2419a65ee84d6c8e929d19bbb64648": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "FloatProgressModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_1c6e642bf5bd4411ab82ae21b110c06a", + "max": 357, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_49891641c9ad45f3bcd0c818d61e2f91", + "value": 357 + } + }, + "afbd89198ebc4e35a27669a5ff61ab6a": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "b0d63d19626b424a991b413d1f4ede96": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "FloatProgressModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "FloatProgressModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "ProgressView", + "bar_style": "success", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_96cddc9c85e442d09516de4736bde7ed", + "max": 10230, + "min": 0, + "orientation": "horizontal", + "style": "IPY_MODEL_57fdf7ca84bc4ac3bfb7134f8a20aefd", + "value": 10230 + } + }, + "b7078020c81e4d7396a5f8c17651cf46": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_327cc8c13a5345c7be13caf4383e0665", + "placeholder": "​", + "style": "IPY_MODEL_450548e393804fed9bbe69311ca4dcee", + "value": " 329M/329M [00:42<00:00, 7.79MB/s]" + } + }, + "bbcc06f79da546069a83e80ca63be07e": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "bccd590fa1ad40649432330a1a6c5575": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "ProgressStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "ProgressStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "bar_color": null, + "description_width": "" + } + }, + "bd2b2c7670714d7187d99051a567ef7a": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "bec8b9c3102d4beeb2b1c6f07034d144": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "bf4ab273f71f47ebae98dc4a104e8e22": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_59ce4e466bb44556a010f5e4661d18b2", + "placeholder": "​", + "style": "IPY_MODEL_7131f49dcc3f4ffc8d9f09dcd508b678", + "value": "Upload file runs/Feb07_02-50-30_319afa680fd7/events.out.tfevents.1675738403.319afa680fd7.10047.2: 100%" + } + }, + "c016d6b1d07549edb9a2c307fecb3100": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HBoxModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_eb399677ffac4b3997b6de8d3a385b87", + "IPY_MODEL_b0d63d19626b424a991b413d1f4ede96", + "IPY_MODEL_1f77381f52114642bc5c3d9bf6e97df6" + ], + "layout": "IPY_MODEL_41eb58de13ab4278ba2c9271a7f99101" + } + }, + "d2db09136bbe4f0886f7d49df91b4cf2": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "d74fcfba2e15485a8f524b49d6393fb3": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_3b174fc794db469597347c8449ddf2d9", + "placeholder": "​", + "style": "IPY_MODEL_f953340acec44614b740ed0b0f395734", + "value": "Clean file pytorch_model.bin: 100%" + } + }, + "d98cdc4493f84e4d92bb1e04dd4a9c6d": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HBoxModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_bf4ab273f71f47ebae98dc4a104e8e22", + "IPY_MODEL_ac2419a65ee84d6c8e929d19bbb64648", + "IPY_MODEL_a6b65edd2b59480998a8e89642357243" + ], + "layout": "IPY_MODEL_1afae18eed644726a1adf71dd36fa80e" + } + }, + "e1671cd0bea74e55a3421d08eb8cc070": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "e532bba004c24176b629658710041531": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + }, + "e7a80a88f21d41b4a0f0d38b561f6289": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.2.0", + "model_name": "LayoutModel", + "state": { + "_model_module": "@jupyter-widgets/base", + "_model_module_version": "1.2.0", + "_model_name": "LayoutModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "LayoutView", + "align_content": null, + "align_items": null, + "align_self": null, + "border": null, + "bottom": null, + "display": null, + "flex": null, + "flex_flow": null, + "grid_area": null, + "grid_auto_columns": null, + "grid_auto_flow": null, + "grid_auto_rows": null, + "grid_column": null, + "grid_gap": null, + "grid_row": null, + "grid_template_areas": null, + "grid_template_columns": null, + "grid_template_rows": null, + "height": null, + "justify_content": null, + "justify_items": null, + "left": null, + "margin": null, + "max_height": null, + "max_width": null, + "min_height": null, + "min_width": null, + "object_fit": null, + "object_position": null, + "order": null, + "overflow": null, + "overflow_x": null, + "overflow_y": null, + "padding": null, + "right": null, + "top": null, + "visibility": null, + "width": null + } + }, + "e80438ac4c724920870266a26c114aaa": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HBoxModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HBoxModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HBoxView", + "box_style": "", + "children": [ + "IPY_MODEL_0a4302d51e444bd186a60c44d687e364", + "IPY_MODEL_4844a2187b654fbe82771813b01d66af", + "IPY_MODEL_aa01155933e3484e88c9e301655d2db7" + ], + "layout": "IPY_MODEL_98549e134beb409cab475008fce4a35d" + } + }, + "eb399677ffac4b3997b6de8d3a385b87": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "HTMLModel", + "state": { + "_dom_classes": [], + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "HTMLModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/controls", + "_view_module_version": "1.5.0", + "_view_name": "HTMLView", + "description": "", + "description_tooltip": null, + "layout": "IPY_MODEL_63ec161d31d84d12bbab6bab422f644e", + "placeholder": "​", + "style": "IPY_MODEL_bd2b2c7670714d7187d99051a567ef7a", + "value": "Upload file runs/Feb07_02-50-30_319afa680fd7/events.out.tfevents.1675738246.319afa680fd7.10047.0: 100%" + } + }, + "f953340acec44614b740ed0b0f395734": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.5.0", + "model_name": "DescriptionStyleModel", + "state": { + "_model_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_model_name": "DescriptionStyleModel", + "_view_count": null, + "_view_module": "@jupyter-widgets/base", + "_view_module_version": "1.2.0", + "_view_name": "StyleView", + "description_width": "" + } + } + } + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}