hdparmar commited on
Commit
55ddab3
1 Parent(s): 159bc58

Upload finetune_itt.ipynb with huggingface_hub

Browse files
Files changed (1) hide show
  1. finetune_itt.ipynb +131 -0
finetune_itt.ipynb ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "55f9ccf6-d430-4c0a-aa60-12d8d4425c60",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "!nvidia-smi"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": null,
16
+ "id": "8370ded1-4832-46b6-944f-235c032673b5",
17
+ "metadata": {},
18
+ "outputs": [],
19
+ "source": [
20
+ "from huggingface_hub import notebook_login\n",
21
+ "\n",
22
+ "notebook_login()"
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": null,
28
+ "id": "25f44308-a145-4af2-8fd2-81dc50eaf472",
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "# Check the dataset\n",
33
+ "from datasets import load_dataset\n",
34
+ "ds = load_dataset(\"hdparmar/irish-traditional-tunes\", split=\"train\")\n",
35
+ "sample = ds[0]\n",
36
+ "display(sample[\"image\"])\n",
37
+ "print(sample[\"text\"])"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "execution_count": null,
43
+ "id": "eac20890-d221-449f-9cd6-a71c9099bff5",
44
+ "metadata": {},
45
+ "outputs": [],
46
+ "source": [
47
+ "from huggingface_hub import hf_hub_download\n",
48
+ "ckpt_path = hf_hub_download(repo_id=\"riffusion/riffusion-model-v1\", filename=\"riffusion-model-v1.ckpt\")"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": null,
54
+ "id": "985a83ee-43d4-4d95-8904-4a601d3a8bca",
55
+ "metadata": {},
56
+ "outputs": [],
57
+ "source": [
58
+ "# 2xA6000:\n",
59
+ "BATCH_SIZE = 4\n",
60
+ "N_GPUS = 2\n",
61
+ "ACCUMULATE_BATCHES = 2\n",
62
+ "GPU_LIST = \",\".join((str(x) for x in range(N_GPUS))) + \",\"\n",
63
+ "print(f\"Using GPUs: {GPU_LIST}\")\n",
64
+ "\n",
65
+ "import os\n",
66
+ "os.environ[\"BATCH_SIZE\"] = str(BATCH_SIZE) \n",
67
+ "os.environ[\"N_GPUS\"] = str(N_GPUS) \n",
68
+ "os.environ[\"ACCUMULATE_BATCHES\"] = str(ACCUMULATE_BATCHES)\n",
69
+ "os.environ[\"GPU_LIST\"] = GPU_LIST\n",
70
+ "os.environ[\"CKPT_PATH\"] = ckpt_path\n",
71
+ "\n",
72
+ "!echo \"$BATCH_SIZE\"\n",
73
+ "!echo \"$N_GPUS\"\n",
74
+ "!echo \"$ACCUMULATE_BATCHES\"\n",
75
+ "!echo \"$GPU_LIST\"\n",
76
+ "!echo \"$CKPT_PATH\""
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "code",
81
+ "execution_count": null,
82
+ "id": "64d80dca-e7c6-438f-965c-3322d0cb33ed",
83
+ "metadata": {},
84
+ "outputs": [],
85
+ "source": [
86
+ "# Run training\n",
87
+ "!(python main.py \\\n",
88
+ " -t \\\n",
89
+ " --base configs/stable-diffusion/pokemon.yaml \\\n",
90
+ " --gpus \"$GPU_LIST\" \\\n",
91
+ " --scale_lr False \\\n",
92
+ " --num_nodes 1 \\\n",
93
+ " --check_val_every_n_epoch 6 \\\n",
94
+ " --finetune_from \"$CKPT_PATH\" \\\n",
95
+ " data.params.batch_size=\"$BATCH_SIZE\" \\\n",
96
+ " lightning.trainer.accumulate_grad_batches=\"$ACCUMULATE_BATCHES\" \\\n",
97
+ " data.params.validation.params.n_gpus=\"$N_GPUS\" \\\n",
98
+ ")"
99
+ ]
100
+ },
101
+ {
102
+ "cell_type": "code",
103
+ "execution_count": null,
104
+ "id": "438dd0c2-674b-408e-b8d6-8b789dfcd2ee",
105
+ "metadata": {},
106
+ "outputs": [],
107
+ "source": []
108
+ }
109
+ ],
110
+ "metadata": {
111
+ "kernelspec": {
112
+ "display_name": "Python 3 (ipykernel)",
113
+ "language": "python",
114
+ "name": "python3"
115
+ },
116
+ "language_info": {
117
+ "codemirror_mode": {
118
+ "name": "ipython",
119
+ "version": 3
120
+ },
121
+ "file_extension": ".py",
122
+ "mimetype": "text/x-python",
123
+ "name": "python",
124
+ "nbconvert_exporter": "python",
125
+ "pygments_lexer": "ipython3",
126
+ "version": "3.10.6"
127
+ }
128
+ },
129
+ "nbformat": 4,
130
+ "nbformat_minor": 5
131
+ }