Skip to content

Commit

Permalink
Update dreambooth_corridor_vastai.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
yushan777 committed Jun 11, 2023
1 parent f0e2d4e commit d8a49aa
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions dreambooth_corridor_vastai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"outputs": [],
"source": [
"# BUILD ENV\n",
"\n",
"!pip install numpy==1.23.1\n",
"!pip install pytorch-lightning==1.7.6\n",
"!pip install csv-logger\n",
Expand All @@ -61,7 +62,11 @@
"!pip install -e .\n",
"!pip install huggingface_hub\n",
"!pip install gdown\n",
"!pip install gitpython\n"
"!pip install gitpython\n",
"\n",
"from IPython.display import clear_output\n",
"clear_output()\n",
"print(\"✅ Environment Built.\")"
]
},
{
Expand All @@ -87,7 +92,6 @@
"outputs": [],
"source": [
"# Download the 1.5 sd model\n",
"from IPython.display import clear_output\n",
"from huggingface_hub import hf_hub_download\n",
"\n",
"downloaded_model_path = hf_hub_download(\n",
Expand Down Expand Up @@ -118,10 +122,8 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n",
"# The following folder names reflect what was used in the C.D. tutorial, \n",
"# rename them if you want, according to your probject's preferences.\n",
"# The example folder names here reflect what was used in the Corridor tutorial, \n",
"# rename them according to your probject's preferences.\n",
"training_images_root = \"trainingImages\" # <-- change this (optional)\n",
"\n",
"subject_token_word = \"nikopueringer\" # <-- change this!\n",
Expand All @@ -133,14 +135,18 @@
"subject_path = f'{training_images_root}/{subject_token_word}/{subject_class_word}'\n",
"style_path = f'{training_images_root}/{style_token_word}/{style_class_word}'\n",
"\n",
"# ==============================================\n",
"# create folders \n",
"import os\n",
"if os.path.exists(subject_path) == False:\n",
" os.makedirs(subject_path)\n",
" print(f'{subject_path} Created.')\n",
"else:\n",
" print(f'{subject_path} already exists.')\n",
"\n",
"if os.path.exists(style_path) == False:\n",
" os.makedirs(style_path)\n",
" print(f'{style_path} Created.')\n",
"else:\n",
" print(f'{style_path} already exists.')\n",
"\n"
Expand Down Expand Up @@ -259,9 +265,9 @@
"source": [
"\n",
"\n",
"# The following folder names reflect what was used in the C.D. tutorial, \n",
"# rename them if you want, according to your probject's preferences.\n",
"reg_images_root = \"regImages\"\n",
"# The example folder names here reflect what was used in the Corridor tutorial, \n",
"# rename them according to your probject's preferences.\n",
"reg_images_root = \"regImages\" # <-- change this (optional)\n",
"\n",
"# subject_class_word and style_class_word used below were already defined when creating the training image folders\n",
"# will be reused here. \n",
Expand All @@ -271,11 +277,13 @@
"# create folders \n",
"if os.path.exists(reg_subject_path) == False:\n",
" os.makedirs(reg_subject_path)\n",
" print(f'{reg_subject_path} Created.')\n",
"else:\n",
" print(f'{reg_subject_path} already exists.')\n",
"\n",
"if os.path.exists(reg_style_path) == False:\n",
" os.makedirs(reg_style_path)\n",
" print(f'{reg_style_path} Created.')\n",
"else:\n",
" print(f'{reg_style_path} already exists.')"
]
Expand Down Expand Up @@ -391,7 +399,7 @@
"metadata": {},
"outputs": [],
"source": [
"repeats_val = 50\n",
"repeats = 100 # <-- change this (optional)\n",
"\n",
"filename = \"dreambooth_helpers/dreambooth_trainer_configurations.py\"\n",
"file = open(filename)\n",
Expand All @@ -406,12 +414,12 @@
"if repeats_line.startswith(pattern): \n",
" # replace the line\n",
" new_line = ''\n",
" if repeats_val >0 and repeats_val <=9:\n",
" new_line = f'\"repeats\": {repeats_val},\\n'.rjust(34)\n",
" elif repeats_val >=10 and repeats_val <=99:\n",
" new_line = f'\"repeats\": {repeats_val},\\n'.rjust(35)\n",
" elif repeats_val >=100 and repeats_val <=999:\n",
" new_line = f'\"repeats\": {repeats_val},\\n'.rjust(36)\n",
" if repeats >0 and repeats <=9:\n",
" new_line = f'\"repeats\": {repeats},\\n'.rjust(34)\n",
" elif repeats >=10 and repeats <=99:\n",
" new_line = f'\"repeats\": {repeats},\\n'.rjust(35)\n",
" elif repeats >=100 and repeats <=999:\n",
" new_line = f'\"repeats\": {repeats},\\n'.rjust(36)\n",
"\n",
" lines[192-1] = new_line\n",
"\n",
Expand Down

0 comments on commit d8a49aa

Please sign in to comment.