diff --git a/fast-DreamBooth.ipynb b/fast-DreamBooth.ipynb index f06f2719..4ac4b918 100644 --- a/fast-DreamBooth.ipynb +++ b/fast-DreamBooth.ipynb @@ -6,7 +6,7 @@ "id": "qEsNHTtVlbkV" }, "source": [ - "# **fast-DreamBooth colab From https://github.com/TheLastBen/fast-stable-diffusion, if you face any issues, feel free to discuss them.** \n", + "# **fast-DreamBooth colab From https://github.com/TheLastBen/fast-stable-diffusion, if you face any issues, feel free to discuss them.**\n", "Keep your notebook updated for best experience. [Support](https://ko-fi.com/thelastben)\n" ] }, @@ -51,7 +51,7 @@ " !pip uninstall -y diffusers\n", " !git clone --branch updt https://github.com/TheLastBen/diffusers\n", " !pip install -q /content/diffusers\n", - "print('\u001b[1;32mDONE !') " + "print('\u001b[1;32mDONE !')" ] }, { @@ -87,7 +87,7 @@ "\n", "#@markdown ---\n", "\n", - "with capture.capture_output() as cap: \n", + "with capture.capture_output() as cap:\n", " %cd /content/\n", "\n", "Huggingface_Token = \"\" #@param {type:\"string\"}\n", @@ -140,12 +140,12 @@ " !rm -r /content/stable-diffusion-v1-5/.git\n", " %cd /content/stable-diffusion-v1-5\n", " !rm model_index.json\n", - " time.sleep(1) \n", + " time.sleep(1)\n", " wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/model_index.json')\n", " !sed -i 's@\"clip_sample\": false@@g' /content/stable-diffusion-v1-5/scheduler/scheduler_config.json\n", " !sed -i 's@\"trained_betas\": null,@\"trained_betas\": null@g' /content/stable-diffusion-v1-5/scheduler/scheduler_config.json\n", - " !sed -i 's@\"sample_size\": 256,@\"sample_size\": 512,@g' /content/stable-diffusion-v1-5/vae/config.json \n", - " %cd /content/ \n", + " !sed -i 's@\"sample_size\": 256,@\"sample_size\": 512,@g' /content/stable-diffusion-v1-5/vae/config.json\n", + " %cd /content/\n", " clear_output()\n", " print('\u001b[1;32mDONE !')\n", " else:\n", @@ -183,7 +183,7 @@ " !git pull origin main\n", " clear_output()\n", " print('\u001b[1;32mDONE !')\n", - " \n", + "\n", "\n", "if Path_to_HuggingFace != \"\":\n", " if Custom_Model_Version=='V2.1-512px' or Custom_Model_Version=='V2.1-768px':\n", @@ -202,8 +202,8 @@ " !git pull origin main\n", " if os.path.exists('/content/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):\n", " !rm -r /content/stable-diffusion-custom/.git\n", - " %cd /content/ \n", - " MODEL_NAME=\"/content/stable-diffusion-custom\" \n", + " %cd /content/\n", + " MODEL_NAME=\"/content/stable-diffusion-custom\"\n", " clear_output()\n", " print('\u001b[1;32mDONE !')\n", " else:\n", @@ -234,24 +234,24 @@ " wget.download('https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/model_index.json')\n", " !sed -i 's@\"clip_sample\": false,@@g' /content/stable-diffusion-custom/scheduler/scheduler_config.json\n", " !sed -i 's@\"trained_betas\": null,@\"trained_betas\": null@g' /content/stable-diffusion-custom/scheduler/scheduler_config.json\n", - " !sed -i 's@\"sample_size\": 256,@\"sample_size\": 512,@g' /content/stable-diffusion-custom/vae/config.json \n", - " %cd /content/ \n", - " MODEL_NAME=\"/content/stable-diffusion-custom\" \n", + " !sed -i 's@\"sample_size\": 256,@\"sample_size\": 512,@g' /content/stable-diffusion-custom/vae/config.json\n", + " %cd /content/\n", + " MODEL_NAME=\"/content/stable-diffusion-custom\"\n", " clear_output()\n", " print('\u001b[1;32mDONE !')\n", " else:\n", " while not os.path.exists('/content/stable-diffusion-custom/unet/diffusion_pytorch_model.bin'):\n", " print('\u001b[1;31mCheck the link you provided')\n", - " time.sleep(5) \n", + " time.sleep(5)\n", "\n", "elif CKPT_Path !=\"\":\n", " %cd /content\n", - " clear_output() \n", + " clear_output()\n", " if os.path.exists(str(CKPT_Path)):\n", " if Custom_Model_Version=='1.5':\n", " !wget -O refmdlz https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/refmdlz\n", " !unzip -o -q refmdlz\n", - " !rm -f refmdlz \n", + " !rm -f refmdlz\n", " !wget -O convertodiff.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py\n", " clear_output()\n", " !python /content/convertodiff.py \"$CKPT_Path\" /content/stable-diffusion-custom --v1\n", @@ -277,19 +277,19 @@ " else:\n", " while not os.path.exists(str(CKPT_Path)):\n", " print('\u001b[1;31mWrong path, use the colab file explorer to copy the path')\n", - " time.sleep(5) \n", + " time.sleep(5)\n", "\n", - "elif CKPT_Link !=\"\": \n", + "elif CKPT_Link !=\"\":\n", " %cd /content\n", - " clear_output() \n", + " clear_output()\n", " !gdown --fuzzy -O model.ckpt $CKPT_Link\n", - " clear_output() \n", + " clear_output()\n", " if os.path.exists('/content/model.ckpt'):\n", " if os.path.getsize(\"/content/model.ckpt\") > 1810671599:\n", " if Custom_Model_Version=='1.5':\n", " !wget -O refmdlz https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/refmdlz\n", " !unzip -o -q refmdlz\n", - " !rm -f refmdlz \n", + " !rm -f refmdlz\n", " !wget -O convertodiff.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py\n", " clear_output()\n", " !python /content/convertodiff.py /content/model.ckpt /content/stable-diffusion-custom --v1\n", @@ -317,7 +317,7 @@ " while os.path.getsize('/content/model.ckpt') < 1810671599:\n", " print('\u001b[1;31mWrong link, check that the link is valid')\n", " time.sleep(5)\n", - " \n", + "\n", "else:\n", " if Model_Version==\"1.5\":\n", " if not os.path.exists('/content/stable-diffusion-v1-5'):\n", @@ -332,14 +332,14 @@ " MODEL_NAME=\"/content/stable-diffusion-v2-512\"\n", " else:\n", " MODEL_NAME=\"/content/stable-diffusion-v2-512\"\n", - " print(\"\u001b[1;32mThe v2-512px model already exists, using this model.\") \n", + " print(\"\u001b[1;32mThe v2-512px model already exists, using this model.\")\n", " elif Model_Version==\"V2.1-768px\":\n", - " if not os.path.exists('/content/stable-diffusion-v2-768'): \n", + " if not os.path.exists('/content/stable-diffusion-v2-768'):\n", " newdownloadmodel()\n", " MODEL_NAME=\"/content/stable-diffusion-v2-768\"\n", " else:\n", " MODEL_NAME=\"/content/stable-diffusion-v2-768\"\n", - " print(\"\u001b[1;32mThe v2-768px model already exists, using this model.\") " + " print(\"\u001b[1;32mThe v2-768px model already exists, using this model.\")" ] }, { @@ -375,12 +375,12 @@ " pass\n", "except:\n", " MODEL_NAME=\"\"\n", - " \n", + "\n", "PT=\"\"\n", "\n", "Session_Name = \"\" #@param{type: 'string'}\n", "while Session_Name==\"\":\n", - " print('\u001b[1;31mInput the Session Name:') \n", + " print('\u001b[1;31mInput the Session Name:')\n", " Session_Name=input('')\n", "Session_Name=Session_Name.replace(\" \",\"_\")\n", "\n", @@ -406,7 +406,7 @@ " !rm -r instance_images\n", " !unzip instance_images.zip\n", " !rm -r concept_images\n", - " !unzip concept_images.zip \n", + " !unzip concept_images.zip\n", " %cd /content\n", "\n", "\n", @@ -423,24 +423,24 @@ "\n", "if os.path.exists(str(SESSION_DIR)):\n", " mdls=[ckpt for ckpt in listdir(SESSION_DIR) if ckpt.split(\".\")[-1]==\"ckpt\"]\n", - " if not os.path.exists(MDLPTH) and '.ckpt' in str(mdls): \n", - " \n", - " def f(n): \n", + " if not os.path.exists(MDLPTH) and '.ckpt' in str(mdls):\n", + "\n", + " def f(n):\n", " k=0\n", - " for i in mdls: \n", - " if k==n: \n", + " for i in mdls:\n", + " if k==n:\n", " !mv \"$SESSION_DIR/$i\" $MDLPTH\n", " k=k+1\n", "\n", " k=0\n", " print('\u001b[1;33mNo final checkpoint model found, select which intermediary checkpoint to use, enter only the number, (000 to skip):\\n\u001b[1;34m')\n", "\n", - " for i in mdls: \n", + " for i in mdls:\n", " print(str(k)+'- '+i)\n", " k=k+1\n", " n=input()\n", " while int(n)>k-1:\n", - " n=input() \n", + " n=input()\n", " if n!=\"000\":\n", " f(int(n))\n", " print('\u001b[1;32mUsing the model '+ mdls[int(n)]+\" ...\")\n", @@ -449,7 +449,7 @@ " print('\u001b[1;32mSkipping the intermediary checkpoints.')\n", " del n\n", "\n", - " \n", + "\n", "if os.path.exists(str(SESSION_DIR)) and not os.path.exists(MDLPTH):\n", " print('\u001b[1;32mLoading session with no previous model, using the original model or the custom downloaded model')\n", " if MODEL_NAME==\"\":\n", @@ -462,7 +462,7 @@ " if Model_Version=='1.5':\n", " !wget -O refmdlz https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/refmdlz\n", " !unzip -o -q refmdlz\n", - " !rm -f refmdlz \n", + " !rm -f refmdlz\n", " !wget -O convertodiff.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/Dreambooth/convertodiffv1.py\n", " clear_output()\n", " print('\u001b[1;32mSession found, loading the trained model ...')\n", @@ -478,12 +478,12 @@ " clear_output()\n", " print('\u001b[1;32mSession found, loading the trained model ...')\n", " !python /content/convertodiff.py \"$MDLPTH\" \"$OUTPUT_DIR\" --v2 --reference_model stabilityai/stable-diffusion-2-1\n", - " !rm /content/convertodiff.py \n", + " !rm /content/convertodiff.py\n", " if os.path.exists(OUTPUT_DIR+'/unet/diffusion_pytorch_model.bin'):\n", - " resume=True \n", + " resume=True\n", " clear_output()\n", " print('\u001b[1;32mSession loaded.')\n", - " else: \n", + " else:\n", " if not os.path.exists(OUTPUT_DIR+'/unet/diffusion_pytorch_model.bin'):\n", " print('\u001b[1;31mConversion error, if the error persists, remove the CKPT file from the current session folder')\n", "\n", @@ -495,7 +495,7 @@ " else:\n", " print('\u001b[1;32mSession created, proceed to uploading instance images')\n", "\n", - " #@markdown \n", + " #@markdown\n", "\n", " #@markdown # The most importent step is to rename the instance pictures of each subject to a unique unknown identifier, example :\n", " #@markdown - If you have 30 pictures of yourself, simply select them all and rename only one to the chosen identifier for example : phtmejhn, the files would be : phtmejhn (1).jpg, phtmejhn (2).png ....etc then upload them, do the same for other people or objects with a different identifier, and that's it.\n", @@ -555,7 +555,7 @@ " new_path_with_file = os.path.join(INSTANCE_DIR, filename)\n", " file = Image.open(IMAGES_FOLDER_OPTIONAL+\"/\"+filename)\n", " width, height = file.size\n", - " if file.size !=(Crop_size, Crop_size): \n", + " if file.size !=(Crop_size, Crop_size):\n", " side_length = min(width, height)\n", " left = (width - side_length)/2\n", " top = (height - side_length)/2\n", @@ -573,7 +573,7 @@ " else:\n", " for filename in tqdm(os.listdir(IMAGES_FOLDER_OPTIONAL), bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):\n", " %cp -r \"$IMAGES_FOLDER_OPTIONAL/$filename\" \"$INSTANCE_DIR\"\n", - " \n", + "\n", " print('\\n\u001b[1;32mDone, proceed to the next cell')\n", "\n", "\n", @@ -587,7 +587,7 @@ " new_path_with_file = os.path.join(INSTANCE_DIR, filename)\n", " file = Image.open(new_path_with_file)\n", " width, height = file.size\n", - " if file.size !=(Crop_size, Crop_size): \n", + " if file.size !=(Crop_size, Crop_size):\n", " side_length = min(width, height)\n", " left = (width - side_length)/2\n", " top = (height - side_length)/2\n", @@ -609,7 +609,7 @@ "\n", "with capture.capture_output() as cap:\n", " %cd \"$INSTANCE_DIR\"\n", - " !find . -name \"* *\" -type f | rename 's/ /-/g' \n", + " !find . -name \"* *\" -type f | rename 's/ /-/g'\n", "\n", " %cd $SESSION_DIR\n", " !rm instance_images.zip\n", @@ -653,7 +653,7 @@ "\n", "#@markdown - If you prefer to specify directly the folder of the pictures instead of uploading, this will add the pictures to the existing (if any) concept images. Leave EMPTY to upload.\n", "\n", - "Crop_images= True \n", + "Crop_images= True\n", "Crop_size = \"512\"\n", "Crop_size=int(Crop_size)\n", "\n", @@ -669,7 +669,7 @@ " new_path_with_file = os.path.join(CONCEPT_DIR, filename)\n", " file = Image.open(IMAGES_FOLDER_OPTIONAL+\"/\"+filename)\n", " width, height = file.size\n", - " if file.size !=(Crop_size, Crop_size): \n", + " if file.size !=(Crop_size, Crop_size):\n", " side_length = min(width, height)\n", " left = (width - side_length)/2\n", " top = (height - side_length)/2\n", @@ -687,7 +687,7 @@ " else:\n", " for filename in tqdm(os.listdir(IMAGES_FOLDER_OPTIONAL), bar_format=' |{bar:15}| {n_fmt}/{total_fmt} Uploaded'):\n", " %cp -r \"$IMAGES_FOLDER_OPTIONAL/$filename\" \"$CONCEPT_DIR\"\n", - " \n", + "\n", "elif IMAGES_FOLDER_OPTIONAL ==\"\":\n", " uploaded = files.upload()\n", " if Crop_images:\n", @@ -698,7 +698,7 @@ " new_path_with_file = os.path.join(CONCEPT_DIR, filename)\n", " file = Image.open(new_path_with_file)\n", " width, height = file.size\n", - " if file.size !=(Crop_size, Crop_size): \n", + " if file.size !=(Crop_size, Crop_size):\n", " side_length = min(width, height)\n", " left = (width - side_length)/2\n", " top = (height - side_length)/2\n", @@ -716,9 +716,9 @@ " shutil.move(filename, CONCEPT_DIR)\n", " clear_output()\n", "\n", - " \n", + "\n", "print('\\n\u001b[1;32mAlmost done...')\n", - "with capture.capture_output() as cap: \n", + "with capture.capture_output() as cap:\n", " i=0\n", " for filename in os.listdir(CONCEPT_DIR):\n", " extension = filename.split(\".\")[-1]\n", @@ -768,7 +768,7 @@ " %rm -r $INSTANCE_DIR\"/.ipynb_checkpoints\"\n", "\n", "if os.path.exists(CONCEPT_DIR+\"/.ipynb_checkpoints\"):\n", - " %rm -r $CONCEPT_DIR\"/.ipynb_checkpoints\" \n", + " %rm -r $CONCEPT_DIR\"/.ipynb_checkpoints\"\n", "\n", "Resume_Training = False #@param {type:\"boolean\"}\n", "\n", @@ -813,7 +813,7 @@ "if UNet_Training_Steps==0:\n", " trnonltxt=\"--train_only_text_encoder\"\n", "\n", - "Seed='' \n", + "Seed=''\n", "\n", "Style_Training = False #@param {type:\"boolean\"}\n", "\n", @@ -862,7 +862,7 @@ "if os.path.getsize(MODELT_NAME+\"/text_encoder/pytorch_model.bin\") > 670901463:\n", " V2=True\n", "\n", - "Enable_text_encoder_training= True \n", + "Enable_text_encoder_training= True\n", "Enable_Text_Encoder_Concept_Training= True\n", "\n", "if Text_Encoder_Training_Steps==0:\n", @@ -903,7 +903,7 @@ "#@markdown - Auto-disconnect from google colab after the training to avoid wasting compute units.\n", "\n", "def dump_only_textenc(trnonltxt, MODELT_NAME, INSTANCE_DIR, OUTPUT_DIR, PT, Seed, precision, Training_Steps):\n", - " \n", + "\n", " !accelerate launch /content/diffusers/examples/dreambooth/train_dreambooth.py \\\n", " $trnonltxt \\\n", " --image_captions_filename \\\n", @@ -927,7 +927,7 @@ "def train_only_unet(stpsv, stp, SESSION_DIR, MODELT_NAME, INSTANCE_DIR, OUTPUT_DIR, PT, Seed, Res, precision, Training_Steps):\n", " clear_output()\n", " if resuming==\"Yes\":\n", - " print('\u001b[1;32mResuming Training...\u001b[0m') \n", + " print('\u001b[1;32mResuming Training...\u001b[0m')\n", " print('\u001b[1;33mTraining the UNet...\u001b[0m')\n", " !accelerate launch /content/diffusers/examples/dreambooth/train_dreambooth.py \\\n", " $Style \\\n", @@ -960,7 +960,7 @@ "if Enable_Text_Encoder_Concept_Training and os.listdir(CONCEPT_DIR)!=[]:\n", " clear_output()\n", " if resuming==\"Yes\":\n", - " print('\u001b[1;32mResuming Training...\u001b[0m') \n", + " print('\u001b[1;32mResuming Training...\u001b[0m')\n", " print('\u001b[1;33mTraining the text encoder on the concept...\u001b[0m')\n", " dump_only_textenc(trnonltxt, MODELT_NAME, CONCEPT_DIR, OUTPUT_DIR, PT, Seed, precision, Training_Steps=stptxtc)\n", "elif Enable_Text_Encoder_Concept_Training and os.listdir(CONCEPT_DIR)==[]:\n", @@ -968,7 +968,7 @@ " time.sleep(8)\n", "if UNet_Training_Steps!=0:\n", " train_only_unet(stpsv, stp, SESSION_DIR, MODELT_NAME, INSTANCE_DIR, OUTPUT_DIR, PT, Seed, Res, precision, Training_Steps=UNet_Training_Steps)\n", - " \n", + "\n", "\n", "if os.path.exists('/content/models/'+INSTANCE_NAME+'/unet/diffusion_pytorch_model.bin'):\n", " prc=\"--fp16\" if precision==\"fp16\" else \"\"\n", @@ -979,11 +979,11 @@ " clear_output()\n", " print(\"\u001b[1;32mDONE, the CKPT model is in your Gdrive in the sessions folder\")\n", " if Disconnect_after_training :\n", - " time.sleep(20) \n", - " runtime.unassign() \n", + " time.sleep(20)\n", + " runtime.unassign()\n", " else:\n", - " print(\"\u001b[1;31mSomething went wrong\") \n", - " else: \n", + " print(\"\u001b[1;31mSomething went wrong\")\n", + " else:\n", " !wget -O /content/convertosd.py https://github.com/TheLastBen/fast-stable-diffusion/raw/main/Dreambooth/convertosd.py\n", " clear_output()\n", " if precision==\"no\":\n", @@ -993,14 +993,14 @@ " !python /content/convertosd.py\n", " !rm /content/convertosd.py\n", " clear_output()\n", - " if os.path.exists(SESSION_DIR+\"/\"+INSTANCE_NAME+'.ckpt'): \n", + " if os.path.exists(SESSION_DIR+\"/\"+INSTANCE_NAME+'.ckpt'):\n", " print(\"\u001b[1;32mDONE, the CKPT model is in your Gdrive in the sessions folder\")\n", " if Disconnect_after_training :\n", " time.sleep(20)\n", " runtime.unassign()\n", " else:\n", " print(\"\u001b[1;31mSomething went wrong\")\n", - " \n", + "\n", "else:\n", " print(\"\u001b[1;31mSomething went wrong\")" ] @@ -1045,7 +1045,7 @@ "\n", "try:\n", " INSTANCE_NAME\n", - " INSTANCET=INSTANCE_NAME \n", + " INSTANCET=INSTANCE_NAME\n", "except:\n", " pass\n", "#@markdown - if checked, an input box will ask the full path to a desired model.\n", @@ -1070,12 +1070,12 @@ "except:\n", " print('\u001b[1;31mIt seems that you did not perform training during this session \u001b[1;32mor you chose to use a custom path,\\nprovide the full path to the model (including the name of the model):\\n')\n", " path_to_trained_model=input()\n", - " \n", + "\n", "while not os.path.exists(path_to_trained_model):\n", " print(\"\u001b[1;31mThe model doesn't exist on you Gdrive, use the file explorer to get the path : \")\n", " path_to_trained_model=input()\n", "\n", - " \n", + "\n", "with capture.capture_output() as cap:\n", " %cd /content/gdrive/MyDrive/\n", " %mkdir sd\n", @@ -1090,10 +1090,10 @@ " !wget -O /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/shared.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/modules/shared.py\n", "\n", "if Update_repo:\n", - " with capture.capture_output() as cap: \n", - " !rm /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.sh \n", + " with capture.capture_output() as cap:\n", + " !rm /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.sh\n", " !rm /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/paths.py\n", - " !rm /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py \n", + " !rm /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py\n", " !rm /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/ui.py\n", " !rm /content/gdrive/MyDrive/sd/stable-diffusion-webui/style.css\n", " %cd /content/gdrive/MyDrive/sd/stable-diffusion-webui/\n", @@ -1102,7 +1102,7 @@ "\n", "\n", "with capture.capture_output() as cap:\n", - " \n", + "\n", " if not os.path.exists('/content/gdrive/MyDrive/sd/stablediffusion/src/k-diffusion/k_diffusion'):\n", " !mkdir /content/gdrive/MyDrive/sd/stablediffusion/src\n", " %cd /content/gdrive/MyDrive/sd/stablediffusion/src\n", @@ -1112,12 +1112,12 @@ " !git clone https://github.com/sczhou/CodeFormer\n", " !git clone https://github.com/crowsonkb/k-diffusion\n", " !mv /content/gdrive/MyDrive/sd/stablediffusion/src/CLIP /content/gdrive/MyDrive/sd/stablediffusion/src/clip\n", - " !mv /content/gdrive/MyDrive/sd/stablediffusion/src/BLIP /content/gdrive/MyDrive/sd/stablediffusion/src/blip \n", - " !mv /content/gdrive/MyDrive/sd/stablediffusion/src/CodeFormer /content/gdrive/MyDrive/sd/stablediffusion/src/codeformer \n", - " !cp -r /content/gdrive/MyDrive/sd/stablediffusion/src/k-diffusion/k_diffusion /content/gdrive/MyDrive/sd/stable-diffusion-webui/ \n", + " !mv /content/gdrive/MyDrive/sd/stablediffusion/src/BLIP /content/gdrive/MyDrive/sd/stablediffusion/src/blip\n", + " !mv /content/gdrive/MyDrive/sd/stablediffusion/src/CodeFormer /content/gdrive/MyDrive/sd/stablediffusion/src/codeformer\n", + " !cp -r /content/gdrive/MyDrive/sd/stablediffusion/src/k-diffusion/k_diffusion /content/gdrive/MyDrive/sd/stable-diffusion-webui/\n", "\n", "\n", - "with capture.capture_output() as cap: \n", + "with capture.capture_output() as cap:\n", " %cd /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules\n", " !wget -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py\n", "\n", @@ -1125,14 +1125,14 @@ " if not os.path.exists('/tools/node/bin/lt'):\n", " !npm install -g localtunnel\n", "\n", - "with capture.capture_output() as cap: \n", + "with capture.capture_output() as cap:\n", " %cd /content/gdrive/MyDrive/sd/stable-diffusion-webui/\n", " time.sleep(1)\n", " !wget -O webui.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.py\n", " !sed -i 's@ui.create_ui().*@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py\n", " %cd /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/\n", " !wget -O ui.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/modules/ui.py\n", - " !sed -i 's@css = \"\".*@with open(os.path.join(script_path, \"style.css\"), \"r\", encoding=\"utf8\") as file:\\n css = file.read()@' /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/ui.py \n", + " !sed -i 's@css = \"\".*@with open(os.path.join(script_path, \"style.css\"), \"r\", encoding=\"utf8\") as file:\\n css = file.read()@' /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/ui.py\n", " %cd /content/gdrive/MyDrive/sd/stable-diffusion-webui\n", " !wget -O style.css https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/style.css\n", " !sed -i 's@min-height: 4.*@min-height: 5.5em;@g' /content/gdrive/MyDrive/sd/stable-diffusion-webui/style.css\n", @@ -1163,7 +1163,7 @@ " line = ' self.server_port = server_port\\n'\n", " sys.stdout.write(line)\n", " clear_output()\n", - " \n", + "\n", "else:\n", " share=''\n", " !nohup lt --port 7860 > srv.txt 2>&1 &\n", @@ -1180,14 +1180,14 @@ " if line.strip().startswith('self.protocol = \"https\"'):\n", " line = ' self.protocol = \"https\"\\n'\n", " if line.strip().startswith('if self.local_url.startswith(\"https\") or self.is_colab'):\n", - " line = '' \n", + " line = ''\n", " if line.strip().startswith('else \"http\"'):\n", - " line = '' \n", + " line = ''\n", " sys.stdout.write(line)\n", - " \n", + "\n", "\n", " !sed -i '13s@.*@ \"PUBLIC_SHARE_TRUE\": \"\u001b[32mConnected\",@' /usr/local/lib/python3.8/dist-packages/gradio/strings.py\n", - " \n", + "\n", " !rm /content/srv.txt\n", " !rm /content/srvr.txt\n", " clear_output()\n", @@ -1209,14 +1209,17 @@ " NM=\"False\"\n", "\n", "if os.path.exists('/usr/local/lib/python3.8/dist-packages/xformers'):\n", - " xformers=\"--xformers\" \n", + " xformers=\"--xformers\"\n", "else:\n", " xformers=\"\"\n", "\n", "if os.path.isfile(path_to_trained_model):\n", - " !python /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py $share --disable-safe-unpickle --no-half-vae --enable-insecure-extension-access --ckpt \"$path_to_trained_model\" $configf $xformers\n", + " ckpt_dir=os.path.dirname(path_to_trained_model)\n", + " ckpt_cfg='--ckpt %s --ckpt-dir %s' % (path_to_trained_model, ckpt_dir)\n", "else:\n", - " !python /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py $share --disable-safe-unpickle --no-half-vae --enable-insecure-extension-access --ckpt-dir \"$path_to_trained_model\" $configf $xformers" + " ckpt_cfg='--ckpt-dir %s' % path_to_trained_model\n", + "\n", + "!python /content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py $share --disable-safe-unpickle --no-half-vae --enable-insecure-extension-access $ckpt_cfg $configf $xformers" ] }, { @@ -1225,7 +1228,7 @@ "id": "d_mQ23XsOc5R" }, "source": [ - "# Upload The Trained Model to Hugging Face " + "# Upload The Trained Model to Hugging Face" ] }, { @@ -1254,8 +1257,8 @@ "Name_of_your_concept = \"\" #@param {type:\"string\"}\n", "if(Name_of_your_concept == \"\"):\n", " Name_of_your_concept = Session_Name\n", - "Name_of_your_concept=Name_of_your_concept.replace(\" \",\"-\") \n", - " \n", + "Name_of_your_concept=Name_of_your_concept.replace(\" \",\"-\")\n", + "\n", "Save_concept_to = \"My_Profile\" #@param [\"Public_Library\", \"My_Profile\"]\n", "\n", "#@markdown - [Create a write access token](https://huggingface.co/settings/tokens) , go to \"New token\" -> Role : Write. A regular read token won't work here.\n", @@ -1329,7 +1332,7 @@ " image_string = f'''\n", " {image_string}![{i}](https://huggingface.co/{repo_id}/resolve/main/sample_images/{image})\n", " '''\n", - " \n", + "\n", "readme_text = f'''---\n", "license: creativeml-openrail-m\n", "tags:\n", @@ -1501,7 +1504,7 @@ " clear_output()\n", " print(\"\u001b[1;33mTHE SESSION \u001b[1;31m\"+s.value+\" \u001b[1;33mHAS BEEN REMOVED FROM YOUR GDRIVE\")\n", " !rm -r '/content/gdrive/MyDrive/Fast-Dreambooth/Sessions/{s.value}'\n", - " s.options=os.listdir(\"/content/gdrive/MyDrive/Fast-Dreambooth/Sessions\") \n", + " s.options=os.listdir(\"/content/gdrive/MyDrive/Fast-Dreambooth/Sessions\")\n", " else:\n", " d.close()\n", " s.close()\n", @@ -1535,4 +1538,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} +} \ No newline at end of file