Skip to content

Commit

Permalink
create symlink for styles.csv and artists.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
ddPn08 committed Jan 5, 2023
1 parent 6f38f26 commit 851d137
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions automatic1111.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"source": [
"# [Stable Diffusion WebUI Colab](https://github.com/ddPn08/stable-diffusion-webui-colab) by [ddPn08](https://github.com/ddpn08/)\n",
"\n",
"Wiki -> https://github.com/ddPn08/automatic1111-colab/wiki\n",
"## Wiki\n",
"https://github.com/ddPn08/automatic1111-colab/wiki\n",
"\n",
"<br />\n",
"\n",
Expand Down Expand Up @@ -95,8 +96,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "Mls4_48XOrTd"
"id": "Mls4_48XOrTd",
"cellView": "form"
},
"outputs": [],
"source": [
Expand All @@ -122,14 +123,13 @@
"import os\n",
"\n",
"mount_success = False\n",
"if mount_google_drive:\n",
"drive_path = \"/content/drive\"\n",
"if mount_google_drive and not os.path.exists(drive_path):\n",
" from google.colab import drive\n",
"\n",
" try:\n",
" drive_path = \"/content/drive\"\n",
" drive.mount(drive_path, force_remount=force_remount)\n",
" data_dir_gdrive = \"/content/drive/MyDrive/AI/automatic1111\" # @param {type:\"string\"}\n",
" data_dir = data_dir_gdrive\n",
" ! rm -Rf {data_dir} && ln -s {data_dir_gdrive} {data_dir}\n",
" mount_success = True\n",
" except:\n",
" print(\"...error mounting drive or with drive path variables\")\n",
Expand All @@ -142,22 +142,31 @@
"models_path = f\"{data_dir}/models\"\n",
"output_path = f\"{data_dir}/outputs\"\n",
"config_path = f\"{data_dir}/config\"\n",
"scripts_path = f\"{data_dir}/scripts\"\n",
"extensions_file_path = f\"{data_dir}/extensions.txt\"\n",
"\n",
"os.makedirs(models_path, exist_ok=True)\n",
"os.makedirs(output_path, exist_ok=True)\n",
"os.makedirs(config_path, exist_ok=True)\n",
"os.makedirs(f\"{models_path}/Stable-diffusion\", exist_ok=True)\n",
"\n",
"\n",
"for script in os.listdir(scripts_path):\n",
" ! rm -Rf stable-diffusion-webui/scripts/{script} && ln -s {scripts_path}/{script} stable-diffusion-webui/scripts/{script}\n",
"\n",
"for dir in os.listdir(models_path):\n",
" if dir == \"embeddings\":\n",
" ! rm -Rf stable-diffusion-webui/embeddings && ln -s {models_path}/embeddings stable-diffusion-webui/embeddings\n",
" else:\n",
" ! rm -Rf stable-diffusion-webui/models/{dir} && ln -s {models_path}/{dir} stable-diffusion-webui/models/{dir}\n",
"\n",
"! rm -f stable-diffusion-webui/outputs && ln -s {data_dir}/outputs stable-diffusion-webui/outputs\n",
"! rm -f stable-diffusion-webui/config.json && ln -s {config_path}/config.json stable-diffusion-webui/config.json\n",
"! rm -f stable-diffusion-webui/ui-config.json && ln -s {config_path}/ui-config.json stable-diffusion-webui/ui-config.json\n",
"! rm -Rf stable-diffusion-webui/outputs && ln -s {data_dir}/outputs stable-diffusion-webui/outputs\n",
"\n",
"for filename in [\"config.json\", \"ui-config.json\", \"styles.csv\", \"artists.csv\"]:\n",
" ! rm -f stable-diffusion-webui/{filename}\n",
" if not os.path.exists(f\"{config_path}/{filename}\"):\n",
" ! touch {config_path}/{filename}\n",
" ! ln -s {config_path}/{filename} stable-diffusion-webui/{filename}\n",
"\n",
"if download_if_missing:\n",
" if not model_filename:\n",
Expand Down Expand Up @@ -239,20 +248,20 @@
"use_ngrok = False # @param {type: \"boolean\"}\n",
"load_token_from_gdrive = True # @param {type:\"boolean\"}\n",
"ngrok_auth_token = \"\" # @param {type: \"string\"}\n",
"ngrok_region = \"auto\" # @param [\"auto\", \"us\", \"eu\", \"au\", \"ap\", \"sa\", \"jp\", \"in\"]\n",
"ngrok_region = \"default\" # @param [\"default\", \"us\", \"eu\", \"au\", \"ap\", \"sa\", \"jp\", \"in\"]\n",
"\n",
"if os.path.exists(f\"{data_dir}/ngrok.txt\") and use_ngrok:\n",
" with open(f\"{data_dir}/ngrok.txt\", mode=\"r\") as f:\n",
" lines = f.readlines()\n",
" if not ngrok_auth_token and len(lines) > 0:\n",
" ngrok_auth_token = lines[0].strip()\n",
" if ngrok_region == \"auto\" and len(lines) > 1:\n",
" if ngrok_region == \"default\" and len(lines) > 1:\n",
" ngrok_region = lines[1].strip()\n",
"\n",
"with open(f\"{data_dir}/ngrok.txt\", mode=\"w\") as f:\n",
" f.write(f\"{ngrok_auth_token}\\n{ngrok_region}\")\n",
"\n",
"if not ngrok_region or ngrok_region == \"auto\":\n",
"if not ngrok_region or ngrok_region == \"default\":\n",
" ngrok_region = \"us\"\n",
"\n",
"# @markdown &nbsp;\n",
Expand Down Expand Up @@ -302,8 +311,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Ao2t5h5qG9HD",
"cellView": "form"
"cellView": "form",
"id": "Ao2t5h5qG9HD"
},
"outputs": [],
"source": [
Expand All @@ -321,6 +330,8 @@
"import sys\n",
"\n",
"for extension in extensions:\n",
" if extension.startswith(\"#\"):\n",
" continue\n",
" ! git clone {extension}\n",
" extension_name = extension.split(\"/\")[-1]\n",
" ! cd {extension_name} && git fetch\n",
Expand Down Expand Up @@ -385,8 +396,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "Y4ebYsPqTrGb"
"id": "Y4ebYsPqTrGb",
"cellView": "form"
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -428,10 +439,10 @@
"metadata": {
"accelerator": "GPU",
"colab": {
"machine_shape": "hm",
"provenance": [],
"include_colab_link": true
},
"gpuClass": "standard",
"kernelspec": {
"display_name": "automatic",
"language": "python",
Expand Down

0 comments on commit 851d137

Please sign in to comment.