{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "rAmJ-WxxjSC6" }, "source": [ "# **BLIP model finetuing**\n", "\n", "**Datasets used**\n", "\n", "\n", "\n", "* [Control Net Deep Fashion](https://huggingface.co/datasets/ldhnam/deepfashion_controlnet)\n", "* [Deep Fashion with masks](https://huggingface.co/datasets/SaffalPoosh/deepFashion-with-masks)\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "1loyolj_jI_p" }, "source": [ "# Install Dependences\n", "\n" ] }, { "cell_type": "code", "source": [ "from huggingface_hub import notebook_login\n", "notebook_login()" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 145, "referenced_widgets": [ "fd2d3aac84e747ef9fea550ec9a7386d", "f46eec389a6e465d9da7fe9645c163da", "4710c57f77414948a8edffa923180ace", "58454cbb731748bfaee3db0c9d5cf5ba", "d2217d70e0de4cffb85cf30a0ece1e20", "27a2a696724240e48db9158c814987e2", "14e6340f96a24a83940a9ca94f91761d", "340c0254c799476bb777f06c13e0c476", "370ca959de5a4feebb621526c9b76930", "924ac284fa5a464aab90941d2de37d1d", "dd7aa4800af947db98784af70affa906", "2eae6964b0514deb8a986032cfa703a0", "34e88b7e493e4d698756bece63d043a3", "a51bf2e26c734146ae8fba179d2aa4aa", "6272895bedcc4dab9594b030145a6e9d", "585b25543d6d4971a19e5644b05d89dc", "e648bf12632a4c078068d55134187b46", "76f74f8572f84c3188ce30f1b9f308c5", "b1c6914c9cff47e9908188a1744f7242", "02ed82d4297d438f97b8d7481f519eee", "076f54dc01d944dcb4b17420752870af", "f866447196b749f884b03e648db8eded", "696e1a134d374285817e46f42e03504d", "4a13efd8cad04bfc971a48075fc9851e", "a4e6776e1057449a8e525a499f88c784", "77388a40adf04e0aa74542142c37c86b", "e9f36b0a9578425b91af01e16b34fcf1", "b07e98e4cc344be193a2da7e04f72bec", "00245c5c3d9243b187b4e701e7557c5b", "27a2b90344e54755a7cad4968ca8f350", "8956f48644fc410c8707a6aef3dc3a86", "318e896402ba44e0b73f45aa2d869592" ] }, "id": "IF2wU1arJRPk", "outputId": "a507c47f-46d9-40eb-87c2-fe4a95b789f1" }, "execution_count": 1, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "VBox(children=(HTML(value='
=0.16.4 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.20.3)\n", "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (1.23.5)\n", "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers) (23.2)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (6.0.1)\n", "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.10/dist-packages (from transformers) (2023.12.25)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from transformers) (2.31.0)\n", "Requirement already satisfied: tokenizers<0.19,>=0.14 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.15.1)\n", "Requirement already satisfied: safetensors>=0.3.1 in /usr/local/lib/python3.10/dist-packages (from transformers) (0.4.2)\n", "Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.10/dist-packages (from transformers) (4.66.1)\n", "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (2023.6.0)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (4.9.0)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.3.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (3.6)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2.0.7)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->transformers) (2024.2.2)\n", "Requirement already satisfied: datasets in /usr/local/lib/python3.10/dist-packages (2.17.0)\n", "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from datasets) (3.13.1)\n", "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from datasets) (1.23.5)\n", "Requirement already satisfied: pyarrow>=12.0.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (15.0.0)\n", "Requirement already satisfied: pyarrow-hotfix in /usr/local/lib/python3.10/dist-packages (from datasets) (0.6)\n", "Requirement already satisfied: dill<0.3.9,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.3.8)\n", "Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from datasets) (1.5.3)\n", "Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (2.31.0)\n", "Requirement already satisfied: tqdm>=4.62.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (4.66.1)\n", "Requirement already satisfied: xxhash in /usr/local/lib/python3.10/dist-packages (from datasets) (3.4.1)\n", "Requirement already satisfied: multiprocess in /usr/local/lib/python3.10/dist-packages (from datasets) (0.70.16)\n", "Requirement already satisfied: fsspec[http]<=2023.10.0,>=2023.1.0 in /usr/local/lib/python3.10/dist-packages (from datasets) (2023.6.0)\n", "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from datasets) (3.9.3)\n", "Requirement already satisfied: huggingface-hub>=0.19.4 in /usr/local/lib/python3.10/dist-packages (from datasets) (0.20.3)\n", "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from datasets) (23.2)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from datasets) (6.0.1)\n", "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.3.1)\n", "Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (23.2.0)\n", "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.4.1)\n", "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (6.0.5)\n", "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (1.9.4)\n", "Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->datasets) (4.0.3)\n", "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->datasets) (4.9.0)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets) (3.3.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets) (3.6)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets) (2.0.7)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->datasets) (2024.2.2)\n", "Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2.8.2)\n", "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->datasets) (2023.4)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.1->pandas->datasets) (1.16.0)\n" ] } ], "source": [ "!pip install transformers\n", "!pip install datasets\n", "!pip install 'transformers[torch]'\n", "!pip install 'transformers[tf-cpu]'\n", "!pip install 'transformers[flax]'" ] }, { "cell_type": "markdown", "metadata": { "id": "LxSR-PEwDLkE" }, "source": [ "**Testing the imports**" ] }, { "cell_type": "markdown", "metadata": { "id": "Nt1jz4F-knoM" }, "source": [ "**Loading the datasets**" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "RJDHNaqZkEqY" }, "outputs": [], "source": [ "from datasets import load_dataset" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "89tsRz5pj2fh" }, "outputs": [], "source": [ "saffal_possh_df = load_dataset(\"SaffalPoosh/deepFashion-with-masks\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "cP4KZxObk0Zk" }, "outputs": [], "source": [ "# Checking a simple sample from the dataset\n", "for data in saffal_possh_df.items():\n", " print(data[1][\"gender\"])\n", " print(data[1][\"cloth_type\"])\n", " print(data[1][\"caption\"])\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "7euwilYIkWl3" }, "outputs": [], "source": [ "control_net_deep_fashion = load_dataset(\"ldhnam/deepfashion_controlnet\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "wTHcR1LYk7Wq" }, "outputs": [], "source": [ "# Checking a simple sample from the dataset\n", "for data in control_net_deep_fashion.items():\n", " print(data[1][\"caption\"])\n" ] }, { "cell_type": "markdown", "metadata": { "id": "qf8n3B5e2Hnb" }, "source": [ "# **Pseudo-label and Pseudo-Questions**\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "hjwwKCCiQLlZ" }, "outputs": [], "source": [ "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM\n", "\n", "\n", "tokenizer = AutoTokenizer.from_pretrained(\"potsawee/t5-large-generation-squad-QuestionAnswer\")\n", "model = AutoModelForSeq2SeqLM.from_pretrained(\"potsawee/t5-large-generation-squad-QuestionAnswer\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "bygZiKk22T1V" }, "outputs": [], "source": [ "from tqdm import tqdm\n", "import numpy as np\n", "\n", "action_key_words = [\"in\", \"wearing\", \"standing\", \"is wearing\",\n", " \"posing\", \"sitting\", \"walking\", \"carrying\",\n", " \"leaning\"]\n", "\n", "# creating pseudo questions\n", "def create_pseudo_questions_for_saffal_possh(data, size=200):\n", " dataset_selection = data[\"train\"][0: size]\n", " questions = []\n", " answers = []\n", " images = []\n", " input_ids = []\n", "\n", " print(\"Loading the dataset..\")\n", "\n", " sample_id = 0\n", "\n", " for key, sample in dataset_selection.items():\n", " if key == \"caption\":\n", " for caption in tqdm(sample):\n", " caption_tokens = caption.split(\" \")\n", " if caption_tokens[2] in action_key_words:\n", "\n", " inputs = tokenizer(caption, return_tensors=\"pt\")\n", " outputs = model.generate(**inputs, max_length=100)\n", " question_answer = tokenizer.decode(outputs[0], skip_special_tokens=False)\n", " question_answer = question_answer.replace(tokenizer.pad_token, \"\").replace(tokenizer.eos_token, \"\")\n", " question, answer = question_answer.split(tokenizer.sep_token)\n", "\n", " questions.append(question)\n", " answers.append(answer)\n", " input_ids.append(sample_id)\n", " else:\n", " questions.append(\"Is there a person in the image?\")\n", " answers.append(\"Yes, there it is\")\n", " input_ids.append(sample_id)\n", " sample_id += 1\n", "\n", " dataset_selection[\"questions\"] = questions\n", " dataset_selection[\"answers\"] = answers\n", " dataset_selection[\"input_ids\"] = input_ids\n", "\n", "\n", " return dataset_selection\n", "\n", "saffal_possh_df_processed = create_pseudo_questions_for_saffal_possh(saffal_possh_df)\n", "print(saffal_possh_df_processed)\n", "\n", "control_net_deep_fashion_processed = create_pseudo_questions_for_saffal_possh(control_net_deep_fashion)\n", "print(control_net_deep_fashion_processed)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "P3dxkODty-Vl" }, "outputs": [], "source": [ "from datasets import Dataset\n", "\n", "saffal_dataset = Dataset.from_dict(saffal_possh_df_processed)\n", "control_net_dataset = Dataset.from_dict(control_net_deep_fashion_processed)\n", "\n", "print(saffal_dataset)\n", "print(control_net_dataset)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "ak_doWyi8cZs" }, "outputs": [], "source": [ "saffal_dataset = saffal_dataset.remove_columns([\"gender\", \"pose\", \"cloth_type\", \"pid\", \"mask\", \"mask_overlay\", \"caption\"])\n", "control_net_dataset = control_net_dataset.remove_columns([\"openpose\", \"cloth\", \"caption\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "0tn4Sb0Z80Iz" }, "outputs": [], "source": [ "print(saffal_dataset)\n", "print(control_net_dataset)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "ao9xvSJM9PW6" }, "outputs": [], "source": [ "from PIL import Image\n", "\n", "image = saffal_dataset['images'][0]\n", "image" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "x0jzKEAZ9T4b" }, "outputs": [], "source": [ "image = control_net_dataset['image'][0]\n", "image" ] }, { "cell_type": "markdown", "metadata": { "id": "NY64HtXa3xgz" }, "source": [ "**Structuring the dataset for Pytorch model train**" ] }, { "cell_type": "code", "source": [ "import torch\n", "\n", "# creating the dataset structure and model train based in\n", "# https://github.com/dino-chiio/blip-vqa-finetune/blob/main/finetuning.py\n", "\n", "class GenericFashionDataset(torch.utils.data.Dataset):\n", " \"\"\"VQA (v2) dataset.\"\"\"\n", "\n", " def __init__(self, dataset, processor):\n", " self.dataset = dataset\n", " self.processor = processor\n", "\n", " def __len__(self):\n", " return len(self.dataset)\n", "\n", " def __getitem__(self, idx):\n", " question = self.dataset['questions'][idx]\n", " answer = self.dataset['answers'][idx]\n", " image_id = self.dataset['input_ids'][idx]\n", " try:\n", " image = self.dataset['images'][idx]\n", " except:\n", " image = self.dataset['image'][idx]\n", " text = question\n", "\n", " encoding = self.processor(image, text, padding=\"max_length\", truncation=True, return_tensors=\"pt\")\n", " labels = self.processor.tokenizer.encode(\n", " answer, max_length= 8, pad_to_max_length=True, return_tensors='pt'\n", " )\n", " encoding[\"labels\"] = labels\n", "\n", " for k,v in encoding.items(): encoding[k] = v.squeeze()\n", " return encoding" ], "metadata": { "id": "3LEmVCwdrC_Q" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from transformers import BlipProcessor, BlipForQuestionAnswering\n", "\n", "model = BlipForQuestionAnswering.from_pretrained(\"Salesforce/blip-vqa-base\")\n", "processor = BlipProcessor.from_pretrained(\"Salesforce/blip-vqa-base\")\n", "\n", "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", "model.to(device)" ], "metadata": { "id": "_rusAJj3q7T9" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "saffal_train_dataset = GenericFashionDataset(dataset=saffal_dataset, processor=processor)\n", "control_net_train_dataset = GenericFashionDataset(dataset=control_net_dataset, processor=processor)" ], "metadata": { "id": "s9NCVsHlWSi0" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "from torch.utils.data import DataLoader\n", "\n", "batch_size = 2\n", "\n", "saffal_train_dataloader = DataLoader(saffal_train_dataset, batch_size=batch_size, shuffle=False, pin_memory=True)\n", "control_net_train_dataloader = DataLoader(control_net_train_dataset, batch_size=batch_size, shuffle=False, pin_memory=True)" ], "metadata": { "id": "iET_OYWQWqsR" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "lsL4fxFknYwG" }, "source": [ "# **Model Train**\n", "\n", "\n", "deepFashion-with-masks**" ] }, { "cell_type": "code", "source": [ "def train_model(data_loader, num_epochs=50, patience=5):\n", " optimizer = torch.optim.AdamW(model.parameters(), lr=4e-5)\n", " scheduler = torch.optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.9, last_epoch=-1, verbose=False)\n", "\n", " information = []\n", " scaler = torch.cuda.amp.GradScaler()\n", "\n", " for epoch in range(num_epochs):\n", " epoch_loss = 0\n", " model.train()\n", " for idx, batch in zip(tqdm(range(len(data_loader)), desc='Training batch: ...'), data_loader):\n", " input_ids = batch.pop('input_ids').to(device)\n", " pixel_values = batch.pop('pixel_values').to(device)\n", " labels = batch.pop('labels').to(device)\n", "\n", " with torch.amp.autocast(device_type='cuda', dtype=torch.float16):\n", " outputs = model(input_ids=input_ids,\n", " pixel_values=pixel_values,\n", " labels=labels)\n", "\n", " loss = outputs.loss\n", " epoch_loss += loss.item()\n", " optimizer.zero_grad()\n", "\n", " scaler.scale(loss).backward()\n", " scaler.step(optimizer)\n", " scaler.update()\n", "\n", " information.append((epoch_loss/len(saffal_train_dataloader), optimizer.param_groups[0][\"lr\"]))\n", " print(\"Epoch: {} - Training loss: {} - LR: {}\".format(epoch+1, epoch_loss/len(saffal_train_dataloader), optimizer.param_groups[0][\"lr\"]))\n", " scheduler.step()\n", " return model, information\n" ], "metadata": { "id": "Xllczl5lYAPk" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "**Training a model for Saffal Dataset**" ], "metadata": { "id": "VgNBleRlZlKi" } }, { "cell_type": "code", "source": [ "model, information = train_model(saffal_train_dataloader, num_epochs=1)" ], "metadata": { "id": "eePu8scwZHn6" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "import pickle as pk\n", "\n", "model_path = \"/content/drive/MyDrive/Hvar/saffal_fashion_model.pt\"\n", "model.save_pretrained(model_path, from_pt=True) #saving in the drive\n", "\n", "results_path = \"/content/drive/MyDrive/Hvar/saffal_fashion_model_train.pkl\"\n", "pk.dump(information, open(results_path, \"wb\"))" ], "metadata": { "id": "PdbvNJ8CXXIJ" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "**Pusing model to hugging face**" ], "metadata": { "id": "IXNkTzVfaHZC" } }, { "cell_type": "code", "source": [ "model_repo_name = \"wiusdy/blip_pretrained_saffal_fashion_finetuning\"\n", "model.push_to_hub(model_repo_name)" ], "metadata": { "id": "eZ6_yM02aKoO" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "**Training a dataset for Control Net dataset**" ], "metadata": { "id": "vvsoYZdIZoj-" } }, { "cell_type": "code", "source": [ "model, information = train_model(control_net_train_dataloader, num_epochs=1)" ], "metadata": { "id": "gNuRYjwyZr40" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "model_path = \"/content/drive/MyDrive/Hvar/control_net_fashion_model.pt\"\n", "model.save_pretrained(model_path, from_pt=True) #saving in the drive\n", "\n", "results_path = \"/content/drive/MyDrive/Hvar/control_net_fashion_model_train.pkl\"\n", "pk.dump(information, open(results_path, \"wb\"))" ], "metadata": { "id": "858Qld6fZt3U" }, "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "source": [ "**Pushing model to hugging face**" ], "metadata": { "id": "xyUZlTRmaMhl" } }, { "cell_type": "code", "source": [ "model_repo_name = \"wiusdy/blip_pretrained_control_net_fashion_finetuning\"\n", "model.push_to_hub(model_repo_name)" ], "metadata": { "id": "TFRuT5V8aOvm" }, "execution_count": null, "outputs": [] } ], "metadata": { "accelerator": "GPU", "colab": { "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "fd2d3aac84e747ef9fea550ec9a7386d": { "model_module": "@jupyter-widgets/controls", "model_name": "VBoxModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "VBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "VBoxView", "box_style": "", "children": [ "IPY_MODEL_076f54dc01d944dcb4b17420752870af", "IPY_MODEL_f866447196b749f884b03e648db8eded", "IPY_MODEL_696e1a134d374285817e46f42e03504d", "IPY_MODEL_4a13efd8cad04bfc971a48075fc9851e" ], "layout": "IPY_MODEL_14e6340f96a24a83940a9ca94f91761d" } }, "f46eec389a6e465d9da7fe9645c163da": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "model_module_version": "1.5.0", "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_340c0254c799476bb777f06c13e0c476", "placeholder": "​", "style": "IPY_MODEL_370ca959de5a4feebb621526c9b76930", "value": "

Copy a token from your Hugging Face\ntokens page and paste it below.
Immediately click login after copying\nyour token or it might be stored in plain text in this notebook file.
" } }, "4710c57f77414948a8edffa923180ace": { "model_module": "@jupyter-widgets/controls", "model_name": "PasswordModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "PasswordModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "PasswordView", "continuous_update": true, "description": "Token:", "description_tooltip": null, "disabled": false, "layout": "IPY_MODEL_924ac284fa5a464aab90941d2de37d1d", "placeholder": "​", "style": "IPY_MODEL_dd7aa4800af947db98784af70affa906", "value": "" } }, "58454cbb731748bfaee3db0c9d5cf5ba": { "model_module": "@jupyter-widgets/controls", "model_name": "CheckboxModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "CheckboxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "CheckboxView", "description": "Add token as git credential?", "description_tooltip": null, "disabled": false, "indent": true, "layout": "IPY_MODEL_2eae6964b0514deb8a986032cfa703a0", "style": "IPY_MODEL_34e88b7e493e4d698756bece63d043a3", "value": true } }, "d2217d70e0de4cffb85cf30a0ece1e20": { "model_module": "@jupyter-widgets/controls", "model_name": "ButtonModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ButtonModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ButtonView", "button_style": "", "description": "Login", "disabled": false, "icon": "", "layout": "IPY_MODEL_a51bf2e26c734146ae8fba179d2aa4aa", "style": "IPY_MODEL_6272895bedcc4dab9594b030145a6e9d", "tooltip": "" } }, "27a2a696724240e48db9158c814987e2": { "model_module": "@jupyter-widgets/controls", "model_name": "HTMLModel", "model_module_version": "1.5.0", "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_585b25543d6d4971a19e5644b05d89dc", "placeholder": "​", "style": "IPY_MODEL_e648bf12632a4c078068d55134187b46", "value": "\nPro Tip: If you don't already have one, you can create a dedicated\n'notebooks' token with 'write' access, that you can then easily reuse for all\nnotebooks.
" } }, "14e6340f96a24a83940a9ca94f91761d": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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": "center", "align_self": null, "border": null, "bottom": null, "display": "flex", "flex": null, "flex_flow": "column", "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": "50%" } }, "340c0254c799476bb777f06c13e0c476": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "370ca959de5a4feebb621526c9b76930": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "924ac284fa5a464aab90941d2de37d1d": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "dd7aa4800af947db98784af70affa906": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "2eae6964b0514deb8a986032cfa703a0": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "34e88b7e493e4d698756bece63d043a3": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "a51bf2e26c734146ae8fba179d2aa4aa": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "6272895bedcc4dab9594b030145a6e9d": { "model_module": "@jupyter-widgets/controls", "model_name": "ButtonStyleModel", "model_module_version": "1.5.0", "state": { "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ButtonStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "button_color": null, "font_weight": "" } }, "585b25543d6d4971a19e5644b05d89dc": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "e648bf12632a4c078068d55134187b46": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "76f74f8572f84c3188ce30f1b9f308c5": { "model_module": "@jupyter-widgets/controls", "model_name": "LabelModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "LabelModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "LabelView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_b1c6914c9cff47e9908188a1744f7242", "placeholder": "​", "style": "IPY_MODEL_02ed82d4297d438f97b8d7481f519eee", "value": "Connecting..." } }, "b1c6914c9cff47e9908188a1744f7242": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "02ed82d4297d438f97b8d7481f519eee": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "076f54dc01d944dcb4b17420752870af": { "model_module": "@jupyter-widgets/controls", "model_name": "LabelModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "LabelModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "LabelView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_a4e6776e1057449a8e525a499f88c784", "placeholder": "​", "style": "IPY_MODEL_77388a40adf04e0aa74542142c37c86b", "value": "Token is valid (permission: write)." } }, "f866447196b749f884b03e648db8eded": { "model_module": "@jupyter-widgets/controls", "model_name": "LabelModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "LabelModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "LabelView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_e9f36b0a9578425b91af01e16b34fcf1", "placeholder": "​", "style": "IPY_MODEL_b07e98e4cc344be193a2da7e04f72bec", "value": "Your token has been saved in your configured git credential helpers (store)." } }, "696e1a134d374285817e46f42e03504d": { "model_module": "@jupyter-widgets/controls", "model_name": "LabelModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "LabelModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "LabelView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_00245c5c3d9243b187b4e701e7557c5b", "placeholder": "​", "style": "IPY_MODEL_27a2b90344e54755a7cad4968ca8f350", "value": "Your token has been saved to /root/.cache/huggingface/token" } }, "4a13efd8cad04bfc971a48075fc9851e": { "model_module": "@jupyter-widgets/controls", "model_name": "LabelModel", "model_module_version": "1.5.0", "state": { "_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "LabelModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "LabelView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_8956f48644fc410c8707a6aef3dc3a86", "placeholder": "​", "style": "IPY_MODEL_318e896402ba44e0b73f45aa2d869592", "value": "Login successful" } }, "a4e6776e1057449a8e525a499f88c784": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "77388a40adf04e0aa74542142c37c86b": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "e9f36b0a9578425b91af01e16b34fcf1": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "b07e98e4cc344be193a2da7e04f72bec": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "00245c5c3d9243b187b4e701e7557c5b": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "27a2b90344e54755a7cad4968ca8f350": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": "" } }, "8956f48644fc410c8707a6aef3dc3a86": { "model_module": "@jupyter-widgets/base", "model_name": "LayoutModel", "model_module_version": "1.2.0", "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 } }, "318e896402ba44e0b73f45aa2d869592": { "model_module": "@jupyter-widgets/controls", "model_name": "DescriptionStyleModel", "model_module_version": "1.5.0", "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": 0 }