File size: 2,061 Bytes
33d4721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%writefile config.yml\n",
    "task: image_classification # do not change\n",
    "base_model: google/vit-base-patch16-224 # the model to be used from hugging face hub\n",
    "project_name: autotrain-image-classification-model # the name of the project, must be unique\n",
    "log: tensorboard # do not change\n",
    "backend: local # do not change\n",
    "\n",
    "data:\n",
    "  path: data/ # the path to the data folder, this folder consists of `train` and `valid` (if any) folders\n",
    "  train_split: train # this folder inside data/ will be used for training, it contains the images in subfolders.\n",
    "  valid_split: null # this folder inside data/ will be used for validation, it contains the images in subfolders. If not available, set it to null\n",
    "  column_mapping: # do not change\n",
    "    image_column: image\n",
    "    target_column: labels\n",
    "\n",
    "params:\n",
    "  epochs: 2\n",
    "  batch_size: 4\n",
    "  lr: 2e-5\n",
    "  optimizer: adamw_torch\n",
    "  scheduler: linear\n",
    "  gradient_accumulation: 1\n",
    "  mixed_precision: fp16\n",
    "\n",
    "hub:\n",
    "  username: ${HF_USERNAME} # please set HF_USERNAME in colab secrets\n",
    "  token: ${HF_TOKEN} # please set HF_TOKEN in colab secrets, must be valid hugging face write token\n",
    "  push_to_hub: true # set to true if you want to push the model to the hub"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from google.colab import userdata\n",
    "HF_USERNAME = userdata.get('HF_USERNAME')\n",
    "HF_TOKEN = userdata.get('HF_TOKEN')\n",
    "os.environ['HF_USERNAME'] = HF_USERNAME\n",
    "\n",
    "os.environ['HF_TOKEN'] = HF_TOKEN\n",
    "!autotrain --config config.yml"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}