Dep update

This commit is contained in:
Shawn 2023-06-03 02:20:40 -05:00
parent 8fe41e460e
commit b8015bef2d
1 changed files with 48 additions and 190 deletions

View File

@ -63,8 +63,8 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"id": "hAuBbtSvGpau", "cellView": "form",
"cellView": "form" "id": "hAuBbtSvGpau"
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
@ -104,19 +104,21 @@
"!wget -O arial.ttf https://raw.githubusercontent.com/matomo-org/travis-scripts/master/fonts/Arial.ttf\n", "!wget -O arial.ttf https://raw.githubusercontent.com/matomo-org/travis-scripts/master/fonts/Arial.ttf\n",
"\n", "\n",
"packages = [\n", "packages = [\n",
" 'transformers==4.27.1',\n", " 'transformers==4.29.2',\n",
" 'diffusers[torch]==0.14.0',\n", " 'diffusers[torch]==0.14.0',\n",
" 'pynvml==11.4.1',\n", " 'pynvml==11.4.1',\n",
" 'bitsandbytes==0.37.2',\n", " 'bitsandbytes==0.37.2',\n",
" 'ftfy==6.1.1',\n", " 'ftfy==6.1.1',\n",
" 'aiohttp==3.8.4',\n", " 'aiohttp==3.8.4',\n",
" 'compel~=1.1.3',\n", " 'compel~=1.1.3',\n",
" 'protobuf==3.20.3',\n", " 'protobuf==3.20.1',\n",
" 'wandb==0.13.6',\n", " 'wandb==0.15.3',\n",
" 'pyre-extensions==0.0.23',\n", " 'pyre-extensions==0.0.29',\n",
" 'xformers==0.0.20',\n", " 'xformers==0.0.20',\n",
" 'pytorch-lightning==1.9.2',\n", " 'pytorch-lightning==1.6.5',\n",
" 'OmegaConf==2.2.3',\n", " 'OmegaConf==2.2.3',\n",
" 'tensorboard>=2.11.0',\n",
" 'tensorrt'\n",
" 'wandb',\n", " 'wandb',\n",
" 'colorama',\n", " 'colorama',\n",
" 'keyboard',\n", " 'keyboard',\n",
@ -191,15 +193,15 @@
"</table>\n", "</table>\n",
"\"\"\"))\n", "\"\"\"))\n",
"\n", "\n",
"time.sleep(2)\n" "time.sleep(2)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"cellView": "form", "id": "unaffeqGP_0A",
"id": "unaffeqGP_0A" "cellView": "form"
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
@ -214,7 +216,7 @@
"from IPython.display import clear_output\n", "from IPython.display import clear_output\n",
"!mkdir input\n", "!mkdir input\n",
"%cd /content/EveryDream2trainer\n", "%cd /content/EveryDream2trainer\n",
"MODEL_LOCATION = \"sd_v1-5+vae.ckpt\" #@param [\"sd_v1-5+vae.ckpt\", \"hakurei/waifu-diffusion-v1-3\", \"stabilityai/stable-diffusion-2-1-base\", \"stabilityai/stable-diffusion-2-1\"] {allow-input: true}\n", "MODEL_LOCATION = \"panopstor/EveryDream\" #@param [\"sd_v1-5+vae.ckpt\", \"hakurei/waifu-diffusion-v1-3\", \"stabilityai/stable-diffusion-2-1-base\", \"stabilityai/stable-diffusion-2-1\"] {allow-input: true}\n",
"\n", "\n",
"if MODEL_LOCATION == \"sd_v1-5+vae.ckpt\":\n", "if MODEL_LOCATION == \"sd_v1-5+vae.ckpt\":\n",
" MODEL_LOCATION = \"panopstor/EveryDream\"\n", " MODEL_LOCATION = \"panopstor/EveryDream\"\n",
@ -240,9 +242,10 @@
"\n", "\n",
"# Check if the downloaded or copied model is a .ckpt file\n", "# Check if the downloaded or copied model is a .ckpt file\n",
"#@markdown Is the model 1.5 or 2.1 based?\n", "#@markdown Is the model 1.5 or 2.1 based?\n",
"model_type = \"SD1x\" #@param [\"SD1x\", \"SD2_512_base\", \"SD21\"]\n",
"\n",
"if download_path.endswith(\".ckpt\") or MODEL_LOCATION.endswith(\".ckpt\"):\n", "if download_path.endswith(\".ckpt\") or MODEL_LOCATION.endswith(\".ckpt\"):\n",
" If_Ckpt = True\n", " If_Ckpt = True\n",
" model_type = \"SD1x\" #@param [\"SD1x\", \"SD2_512_base\", \"SD21\"]\n",
" save_path = download_path\n", " save_path = download_path\n",
" if \".ckpt\" in save_name:\n", " if \".ckpt\" in save_name:\n",
" save_name = save_name.replace(\".ckpt\", \"\")\n", " save_name = save_name.replace(\".ckpt\", \"\")\n",
@ -277,7 +280,7 @@
"if inference_yaml != \" \":\n", "if inference_yaml != \" \":\n",
" print(\"Model saved to: \" + save_name + \". The \" + inference_yaml + \" was used!\")\n", " print(\"Model saved to: \" + save_name + \". The \" + inference_yaml + \" was used!\")\n",
"\n", "\n",
"print(\"Model \" + save_name + \" will be used!\")\n" "print(\"Model \" + save_name + \" will be used!\")"
] ]
}, },
{ {
@ -326,20 +329,27 @@
"#@markdown * Name your project so you can find it in your logs\n", "#@markdown * Name your project so you can find it in your logs\n",
"Project_Name = \"My_Project\" #@param{type: 'string'}\n", "Project_Name = \"My_Project\" #@param{type: 'string'}\n",
"\n", "\n",
"# Load the JSON file\n", "\n",
"with open('optimizer.json', 'r') as file:\n", "\n",
"if model_type == 'SD2_512_base' or model_type == 'SD21':\n",
" file_path = \"/content/EveryDream2trainer/optimizerSD21.json\"\n",
"else:\n",
" file_path = \"/content/EveryDream2trainer/optimizer.json\"\n",
"\n",
"with open(file_path, 'r') as file:\n",
" data = json.load(file)\n", " data = json.load(file)\n",
"\n", "\n",
"\n",
"#@markdown * The learning rate affects how much \"training\" is done on the model per training step. It is a very careful balance to select a value that will learn your data and not wreck the model. \n", "#@markdown * The learning rate affects how much \"training\" is done on the model per training step. It is a very careful balance to select a value that will learn your data and not wreck the model. \n",
"#@markdown Leave this default unless you are very comfortable with training and know what you are doing.\n", "#@markdown Leave this default unless you are very comfortable with training and know what you are doing.\n",
"Learning_Rate = 1e-6 #@param{type: 'number'}\n", "Learning_Rate = 1e-6 #@param{type: 'number'}\n",
"#@markdown * chosing this will allow you to ignore any settings specific to the text encode and will match it with the Unets settings, recommended for beginers.\n", "#@markdown * chosing this will allow you to ignore any settings specific to the text encode and will match it with the Unets settings, recommended for beginers.\n",
"Match_text_to_Unet = False #@param{type:\"boolean\"}\n", "Match_text_to_Unet = False #@param{type:\"boolean\"}\n",
"Text_lr = 0.5e-6 #@param {type:\"number\"}\n", "Text_lr = 5e-7 #@param {type:\"number\"}\n",
"#@markdown * A learning rate scheduler can change your learning rate as training progresses.\n", "#@markdown * A learning rate scheduler can change your learning rate as training progresses.\n",
"#@markdown * I recommend sticking with constant until you are comfortable with general training. \n", "#@markdown * I recommend sticking with constant until you are comfortable with general training. \n",
"Schedule = \"constant\" #@param [\"constant\", \"polynomial\", \"linear\", \"cosine\"] {allow-input: true}\n", "Schedule = \"linear\" #@param [\"constant\", \"polynomial\", \"linear\", \"cosine\"] {allow-input: true}\n",
"Text_lr_scheduler = \"constant\" #@param [\"constant\", \"polynomial\", \"linear\", \"cosine\"] {allow-input: true}\n", "Text_lr_scheduler = \"linear\" #@param [\"constant\", \"polynomial\", \"linear\", \"cosine\"] {allow-input: true}\n",
"#@markdown * warm up steps are useful for validation and cosine lrs\n", "#@markdown * warm up steps are useful for validation and cosine lrs\n",
"lr_warmup_steps = 0 #@param{type:\"integer\"}\n", "lr_warmup_steps = 0 #@param{type:\"integer\"}\n",
"lr_decay_steps = 0 #@param {type:\"number\"} \n", "lr_decay_steps = 0 #@param {type:\"number\"} \n",
@ -361,7 +371,7 @@
"data['text_encoder_overrides']['lr_decay_steps'] = Text_lr_decay_steps\n", "data['text_encoder_overrides']['lr_decay_steps'] = Text_lr_decay_steps\n",
"\n", "\n",
"# Save the updated JSON data back to the file\n", "# Save the updated JSON data back to the file\n",
"with open('optimizer.json', 'w') as file:\n", "with open(file_path, 'w') as file:\n",
" json.dump(data, file, indent=4)\n", " json.dump(data, file, indent=4)\n",
"\n", "\n",
"#@markdown * Resolution to train at (recommend 512). Higher resolution will require lower batch size (below).\n", "#@markdown * Resolution to train at (recommend 512). Higher resolution will require lower batch size (below).\n",
@ -388,7 +398,7 @@
"\n", "\n",
"#@markdown * Max Epochs to train for, this defines how many total times all your training data is used. Default of 100 is a good start if you are training ~30-40 images of one subject. If you have 100 images, you can reduce this to 40-50 and so forth.\n", "#@markdown * Max Epochs to train for, this defines how many total times all your training data is used. Default of 100 is a good start if you are training ~30-40 images of one subject. If you have 100 images, you can reduce this to 40-50 and so forth.\n",
"\n", "\n",
"Max_Epochs = 200 #@param {type:\"slider\", min:0, max:200, step:1}\n", "Max_Epochs = 100 #@param {type:\"slider\", min:0, max:200, step:1}\n",
"\n", "\n",
"#@markdown * How often to save checkpoints.\n", "#@markdown * How often to save checkpoints.\n",
"Save_every_N_epoch = 20 #@param{type:\"integer\"}\n", "Save_every_N_epoch = 20 #@param{type:\"integer\"}\n",
@ -543,16 +553,15 @@
" time.sleep(40)\n", " time.sleep(40)\n",
" runtime.unassign()\n", " runtime.unassign()\n",
"\n", "\n",
"os.kill(os.getpid(), 9)\n", "os.kill(os.getpid(), 9)"
"\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"id": "8HmIWtODuE6p", "cellView": "form",
"cellView": "form" "id": "8HmIWtODuE6p"
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
@ -618,6 +627,9 @@
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"cellView": "form", "cellView": "form",
"colab": {
"background_save": true
},
"id": "BafdWaYymg0O" "id": "BafdWaYymg0O"
}, },
"outputs": [], "outputs": [],
@ -643,166 +655,7 @@
"with open(file_path, \"w\") as file:\n", "with open(file_path, \"w\") as file:\n",
" file.write(content)\n", " file.write(content)\n",
"\n", "\n",
"print(\"The specified code block has been deleted.\")\n" "print(\"The specified code block has been deleted.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "d20kz8EtosWM"
},
"outputs": [],
"source": [
"#@title train.json Editor { display-mode: \"form\" }\n",
"#title json Editor for ED2\n",
"\n",
"import json\n",
"\n",
"data = {\n",
" \"disable_textenc_training\": False,\n",
" \"disable_xformers\": False,\n",
" \"disable_amp\": False,\n",
" \"lowvram\": False,\n",
" \"notebook\": False,\n",
" \"save_optimizer\": False,\n",
" \"scale_lr\": False,\n",
" \"gradient_checkpointing\": True,\n",
" \"wandb\": False,\n",
" \"write_schedule\": False,\n",
" \"rated_dataset\": False,\n",
" \"batch_size\": 10,\n",
" \"ckpt_every_n_minutes\": None,\n",
" \"clip_grad_norm\": None,\n",
" \"clip_skip\": 0,\n",
" \"cond_dropout\": 0.04,\n",
" \"data_root\": \"X:\\\\my_project_data\\\\project_abc\",\n",
" \"flip_p\": 0.0,\n",
" \"gpuid\": 0,\n",
" \"grad_accum\": 1,\n",
" \"logdir\": \"logs\",\n",
" \"log_step\": 25,\n",
" \"lr\": 1.5e-06,\n",
" \"lr_decay_steps\": 0,\n",
" \"lr_scheduler\": \"constant\",\n",
" \"lr_warmup_steps\": None,\n",
" \"max_epochs\": 30,\n",
" \"optimizer_config\": \"optimizer.json\",\n",
" \"project_name\": \"project_abc\",\n",
" \"resolution\": 512,\n",
" \"resume_ckpt\": \"sd_v1-5_vae\",\n",
" \"run_name\": None,\n",
" \"sample_prompts\": \"sample_prompts.txt\",\n",
" \"sample_steps\": 300,\n",
" \"save_ckpt_dir\": None,\n",
" \"save_ckpts_from_n_epochs\": 0,\n",
" \"save_every_n_epochs\": 20,\n",
" \"seed\": 555,\n",
" \"shuffle_tags\": False,\n",
" \"validation_config\": \"validation_default.json\",\n",
" \"rated_dataset_target_dropout_percent\": 50,\n",
" \"zero_frequency_noise_ratio\": 0.02\n",
"}\n",
"\n",
"%cd /content/EveryDream2trainer\n",
"#@markdown JSON Parameters\n",
"findlast = \"\" \n",
"Resume_Last_Training_session = False #@param {type:\"boolean\"}\n",
"findlast == Resume_Last_Training_session\n",
"disable_textenc_training = False #@param {type:\"boolean\"}\n",
"data[\"disable_textenc_training\"] = disable_textenc_training\n",
"disable_xformers = False #@param {type:\"boolean\"}\n",
"data[\"disable_xformers\"] = disable_xformers\n",
"gradient_checkpointing = True #@param {type:\"boolean\"}\n",
"data[\"gradient_checkpointing\"] = gradient_checkpointing\n",
"save_optimizer = False #@param {type:\"boolean\"}\n",
"data[\"save_optimizer\"] = save_optimizer \n",
"scale_lr = False #@param {type:\"boolean\"}\n",
"data[\"scale_lr\"] = scale_lr\n",
"shuffle_tags = False #@param {type:\"boolean\"}\n",
"data[\"shuffle_tags\"] = shuffle_tags\n",
"wandb = False #@param {type:\"boolean\"}\n",
"data[\"wandb\"] = wandb\n",
"write_schedule = False #@param {type:\"boolean\"}\n",
"data[\"write_schedule\"] = write_schedule\n",
"rated_dataset = False #@param {type:\"boolean\"}\n",
"data[\"rated_dataset\"] = rated_dataset \n",
"batch_size = 8 #@param {type:\"integer\"}\n",
"data[\"batch_size\"] = batch_size\n",
"ckpt_every_n_minutes = None #@param {type:\"raw\"}\n",
"data[\"ckpt_every_n_minutes\"] = ckpt_every_n_minutes\n",
"clip_grad_norm = None #@param {type:\"raw\"}\n",
"data[\"clip_grad_norm\"] = clip_grad_norm\n",
"clip_skip = 0 #@param {type:\"integer\"}\n",
"data[\"clip_skip\"] = clip_skip\n",
"cond_dropout = 0.04 #@param {type:\"number\"}\n",
"data[\"cond_dropout\"] = cond_dropout\n",
"data_root = \"X:\\\\my_project_data\\\\project_abc\" #@param {type:\"string\"}\n",
"data[\"data_root\"] = data_root\n",
"flip_p = 0.0 #@param {type:\"number\"}\n",
"data[\"flip_p\"] = flip_p\n",
"grad_accum = 1 #@param {type:\"integer\"}\n",
"data[\"grad_accum\"] = grad_accum\n",
"logdir = \"logs\" #@param {type:\"string\"}\n",
"data[\"logdir\"] = logdir\n",
"log_step = 25 #@param {type:\"integer\"}\n",
"data[\"log_step\"] = log_step\n",
"lr = 1.5e-06 #@param {type:\"number\"}\n",
"data[\"lr\"] = lr\n",
"lr_decay_steps = 0 #@param {type:\"integer\"}\n",
"data[\"lr_decay_steps\"] = lr_decay_steps\n",
"lr_scheduler = \"constant\" #@param {type:\"string\"}\n",
"data[\"lr_scheduler\"] = lr_scheduler\n",
"lr_warmup_steps = None #@param {type:\"raw\"}\n",
"data[\"lr_warmup_steps\"] = lr_warmup_steps\n",
"max_epochs = 100 #@param {type:\"integer\"}\n",
"data[\"max_epochs\"] = max_epochs\n",
"optimizer_config = \"optimizer.json\" #@param {type:\"string\"}\n",
"data[\"optimizer_config\"] = optimizer_config\n",
"project_name = \"project_abc\" #@param {type:\"string\"}\n",
"data[\"project_name\"] = project_name\n",
"resolution = 512 #@param {type:\"integer\"}\n",
"data[\"resolution\"] = resolution\n",
"resume_ckpt = \"sd_v1-5_vae\" #@param {type:\"string\"}\n",
"if findlast:\n",
" resume_ckpt = \"findlast\"\n",
"data[\"resume_ckpt\"] = resume_ckpt\n",
"run_name = None #@param {type:\"raw\"}\n",
"data[\"run_name\"] = run_name\n",
"sample_prompts = \"sample_prompts.txt\" #@param [\"sample_prompts.txt\", \"sample_prompts.json\"]\n",
"data[\"sample_prompts\"] = sample_prompts\n",
"sample_steps = 300 #@param {type:\"integer\"}\n",
"data[\"sample_steps\"] = sample_steps\n",
"save_ckpt_dir = None #@param {type:\"raw\"}\n",
"data[\"save_ckpt_dir\"] = save_ckpt_dir\n",
"save_ckpts_from_n_epochs = 0 #@param {type:\"integer\"}\n",
"data[\"save_ckpts_from_n_epochs\"] = save_ckpts_from_n_epochs\n",
"save_every_n_epochs = 20 #@param {type:\"integer\"}\n",
"data[\"save_every_n_epochs\"] = save_every_n_epochs\n",
"seed = 555 #@param {type:\"integer\"}\n",
"data[\"seed\"] = seed\n",
"validation_config = \"validation_default.json\" #@param {type:\"string\"}\n",
"data[\"validation_config\"] = validation_config\n",
"rated_dataset_target_dropout_percent = 50 #@param {type:\"integer\"}\n",
"data[\"rated_dataset_target_dropout_percent\"] = rated_dataset_target_dropout_percent\n",
"zero_frequency_noise_ratio = 0.02 #@param {type:\"number\"}\n",
"data[\"zero_frequency_noise_ratio\"] = zero_frequency_noise_ratio\n",
"\n",
"\n",
"\n",
"# Display the modified JSON data\n",
"print(\"Modified JSON data:\")\n",
"print(json.dumps(data, indent=2))\n",
"\n",
"\n",
"# Save the modified JSON data to a file\n",
"filename = \"train.json\" #@param {type:\"string\"}\n",
"variable_name = \"\" #@param {type:\"string\"}\n",
"\n",
"with open(filename, 'w') as file:\n",
" json.dump(data, file, indent=2)\n",
"\n",
"print(f\"Modified JSON data saved to '{filename}'.\")"
] ]
}, },
{ {
@ -815,7 +668,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"#@title Alternate startup script\n", "#@title Alternate startup script\n",
"#@markdown * Edit train.json to setup your paramaters\n", "#@markdown * Edit train.json or chain0.json to setup your paramaters\n",
"\n", "\n",
"#@markdown * Edit using a chain length of 0 will use train.json\n", "#@markdown * Edit using a chain length of 0 will use train.json\n",
"\n", "\n",
@ -823,8 +676,6 @@
"\n", "\n",
"#@markdown * make sure to check each confguration you will need 1 Json per chain length 3 are provided\n", "#@markdown * make sure to check each confguration you will need 1 Json per chain length 3 are provided\n",
"\n", "\n",
"#@markdown * make sure your .Json contain the line Notebook: true\n",
"\n",
"#@markdown * your locations in the .json can be done in this format /content/drive/MyDrive/ - then the sub folder you wish to use\n", "#@markdown * your locations in the .json can be done in this format /content/drive/MyDrive/ - then the sub folder you wish to use\n",
"\n", "\n",
"%cd /content/EveryDream2trainer\n", "%cd /content/EveryDream2trainer\n",
@ -838,6 +689,15 @@
" l -= 1\n", " l -= 1\n",
" I =+ 1" " I =+ 1"
] ]
},
{
"cell_type": "markdown",
"source": [
"Need some tools to Manage your large datasets check out https://github.com/victorchall/EveryDream for some usefull tools and captioner"
],
"metadata": {
"id": "ls6mX94trxZV"
}
} }
], ],
"metadata": { "metadata": {
@ -847,10 +707,8 @@
"gpuType": "T4", "gpuType": "T4",
"include_colab_link": true "include_colab_link": true
}, },
"gpuClass": "standard",
"kernelspec": { "kernelspec": {
"display_name": "venv", "display_name": "Python 3",
"language": "python",
"name": "python3" "name": "python3"
}, },
"language_info": { "language_info": {