drive_link / comfyui_drive_link.py
arcacolab's picture
Upload 4 files
f69753d verified
# -*- coding: utf-8 -*-
"""comfyui_drive_link.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/#fileId=https%3A//huggingface.co/arcacolab/drive_link/blob/main/comfyui_drive_link.ipynb
<a href="https://colab.research.google.com/github/arcacolab/oneclick/blob/main/comfyui_drive_link.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
"""
import os
source_checkpoints = "/content/ComfyUI/models/checkpoints"
target_checkpoints = "/content/drive/MyDrive/ONECLICK/model"
source_loras = "/content/ComfyUI/models/loras"
target_loras = "/content/drive/MyDrive/ONECLICK/lora"
source_vae = "/content/ComfyUI/models/vae"
target_vae = "/content/drive/MyDrive/ONECLICK/vae"
source_embeddings = "/content/ComfyUI/models/embeddings"
target_embeddings = "/content/drive/MyDrive/ONECLICK/embedding"
os.makedirs(target_checkpoints, exist_ok=True)
os.makedirs(target_loras, exist_ok=True)
os.makedirs(target_vae, exist_ok=True)
os.makedirs(target_embeddings, exist_ok=True)
!ln -sf "{target_checkpoints}" "{source_checkpoints}"
!ln -sf "{target_loras}" "{source_loras}"
!ln -sf "{target_vae}" "{source_vae}"
!ln -sf "{target_embeddings}" "{source_embeddings}"
#์ถœ๋ ฅ๋ฌผ ๊ฒฝ๋กœ ๊ด€๋ จ
import shutil
def delete_output_folder_if_file_exists():
"""
/content/ComfyUI/output ํด๋” ๋‚ด๋ถ€์— _output_images_will_be_put_here ํŒŒ์ผ์ด ์žˆ๋Š” ๊ฒฝ์šฐ ํด๋”๋ฅผ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.
ํŒŒ์ผ์ด ์—†๋Š” ๊ฒฝ์šฐ ํด๋”๋ฅผ ์œ ์ง€ํ•ฉ๋‹ˆ๋‹ค.
"""
folder_path = "/content/ComfyUI/output"
file_path = os.path.join(folder_path, "_output_images_will_be_put_here")
if os.path.exists(file_path):
shutil.rmtree(folder_path, ignore_errors=True)
print(f"{folder_path} ํด๋”๋ฅผ ์‚ญ์ œํ–ˆ์Šต๋‹ˆ๋‹ค. (_output_images_will_be_put_here ํŒŒ์ผ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.)")
else:
print(f"{folder_path} ํด๋”๋ฅผ ์œ ์ง€ํ•ฉ๋‹ˆ๋‹ค. (_output_images_will_be_put_here ํŒŒ์ผ์ด ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.)")
# ํ•จ์ˆ˜ ํ˜ธ์ถœ
delete_output_folder_if_file_exists()
import os
sdpath = "/content/drive/MyDrive/ONECLICK/"
outputspath = sdpath + "output"
if not os.path.exists(outputspath):
!mkdir -p -v "{outputspath}"
link_path = "/content/ComfyUI/output"
if not os.path.exists(link_path) and not os.path.islink(link_path):
!ln -s -v "{outputspath}" "{link_path}"