File size: 28,583 Bytes
852967a |
1 2 |
{"cells":[{"attachments":{},"cell_type":"markdown","metadata":{},"source":["## NovelAi lora训练项目 修复版(Kaggle云端部署项目,完全免费,无需任何配置!)\n","**torch: 2.0.0+cu118 • xformers: 0.0.17**\n","\n","<span style=\"color:red; font-weight:bold;\">有问题请加qq群\n","632428790</span>"]},{"cell_type":"code","execution_count":23,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.427437Z","iopub.status.busy":"2023-05-16T08:52:59.427001Z","iopub.status.idle":"2023-05-16T08:52:59.435093Z","shell.execute_reply":"2023-05-16T08:52:59.433856Z","shell.execute_reply.started":"2023-05-16T08:52:59.427399Z"},"trusted":true},"outputs":[],"source":["#安装目录\n","install_path='/kaggle/working'\n","\n","#内网传透\n","useNgrok = 0 # 非必填 是否使用ngrok作为公网访问地址\n","#tesoerboard\n","ngrokTokenFile='/kaggle/input/ngroktoken/Authtoken.txt' # 非必填 存放ngrokToken的文件的路径\n","port = 6006\n","#炼丹炉的gui\n","ngrokTokenFile1='/kaggle/input/ngroktoken/Authtoken1.txt' # 非必填 存放ngrokToken的文件的路径\n","port1 = 28000\n","\n","#优化\n","multi_gpu = 0\n","lowram = 1\n","\n","#删除脚本重新安装\n","reLoad = 0\n","\n","#更新脚本\n","updata = 0\n","\n","#自动打包训练好的模型\n","zip_output = 1\n","#自动清理\n","clear_output = 1\n","#自动上传抱脸\n","upload = 1\n","hugTokenFile='/kaggle/input/hugfacetoken/hugfacetoken.txt' # 非必填 存放hugfacetoken的文件的路径\n","#仓库名\n","repo_id=\"sukaka/train_model\"\n","#上传仓库路径\n","path_in_repo=\"模型.zip\""]},{"cell_type":"code","execution_count":24,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.445197Z","iopub.status.busy":"2023-05-16T08:52:59.444768Z","iopub.status.idle":"2023-05-16T08:52:59.453565Z","shell.execute_reply":"2023-05-16T08:52:59.452389Z","shell.execute_reply.started":"2023-05-16T08:52:59.445149Z"},"trusted":true},"outputs":[],"source":["#一些基础模型下载\n","model_download_urls = [\n","#novelai\n","'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/animefull-final-pruned.safetensors',\n","#sdv1.5\n","'https://huggingface.co/datasets/sukaka/sd_models_fp16/resolve/main/sd-v1-5.safetensors'\n","]\n","#下载在sd-models/"]},{"cell_type":"code","execution_count":25,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.456190Z","iopub.status.busy":"2023-05-16T08:52:59.455792Z","iopub.status.idle":"2023-05-16T08:52:59.466787Z","shell.execute_reply":"2023-05-16T08:52:59.465801Z","shell.execute_reply.started":"2023-05-16T08:52:59.456134Z"},"trusted":true},"outputs":[],"source":["#开启图形化配置参数\n","use_gui = 0\n","\n","#一键倒入炼丹参数\n","config_file='#/kaggle/input/input-qin/qin.toml'\n","\n","#炼丹参数配置,如果使用gui或一键导入炼丹参数,请忽略以下\n","pretrained_model = \"sd-models/animefull-final-pruned.safetensors\"\n","is_v2_model = 0\n","parameterization = 0\n","train_data_dir = \"/kaggle/input/input-qin/input_qin\"\n","reg_data_dir = \"\"\n","network_module = \"networks.lora\"\n","network_weights = \"\"\n","network_dim = 32\n","network_alpha = 32\n","resolution = \"512,768\"\n","batch_size = 2\n","max_train_epoches = 10\n","save_every_n_epochs = 2\n","train_unet_only = 0\n","train_text_encoder_only = 0\n","stop_text_encoder_training = 0\n","noise_offset = \"0\"\n","keep_tokens = 0\n","min_snr_gamma = 0\n","lr = \"1e-4\"\n","unet_lr = \"1e-4\"\n","text_encoder_lr = \"1e-5\"\n","lr_scheduler = \"cosine_with_restarts\"\n","lr_warmup_steps = 0\n","lr_restart_cycles = 1\n","output_name = \"qin\"\n","save_model_as = \"safetensors\"\n","save_state = 0\n","resume = \"\"\n","min_bucket_reso = 256\n","max_bucket_reso = 1024\n","persistent_data_loader_workers = 0\n","clip_skip = 2\n","\n","# Optimizer settings\n","optimizer_type = \"AdamW8bit\" # Optimizer type | Available options: AdamW AdamW8bit Lion SGDNesterov SGDNesterov8bit DAdaptation AdaFactor\n","\n","# LyCORIS training settings\n","algo = \"lora\" # LyCORIS network algo | Available options: lora, loha, lokr, ia3, dylora. lora is equivalent to locon\n","conv_dim = 4 # conv dim | Similar to network_dim, recommended to be 4\n","conv_alpha = 4 # conv alpha | Similar to network_alpha, can use same or smaller values than conv_dim\n","dropout = \"0\" # dropout | Dropout probability, 0 means no dropout, larger values mean more dropout. LoHa/LoKr/(IA)^3 do not currently support dropout"]},{"cell_type":"code","execution_count":26,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.468869Z","iopub.status.busy":"2023-05-16T08:52:59.468293Z","iopub.status.idle":"2023-05-16T08:52:59.599053Z","shell.execute_reply":"2023-05-16T08:52:59.598032Z","shell.execute_reply.started":"2023-05-16T08:52:59.468836Z"},"trusted":true},"outputs":[],"source":["import shutil\n","import gc\n","import os\n","import re\n","import time\n","import subprocess\n","import multiprocessing\n","import inspect\n","import pkg_resources\n","from pathlib import Path\n","from concurrent.futures import ProcessPoolExecutor\n","os.environ['install_path'] = install_path\n","os.environ['HF_HOME'] = 'huggingface'\n","os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n","os.environ[\"PL_TORCH_DISTRIBUTED_BACKEND\"] = \"gloo\"\n"," \n","def libtcmalloc():\n"," if os.path.exists('/kaggle/temp'):\n"," os.chdir('/kaggle')\n"," os.chdir('temp')\n"," os.environ[\"LD_PRELOAD\"] = \"libtcmalloc.so\"\n"," print('内存优化已安装')\n"," else:\n"," os.system('apt -y install -qq aria2')\n"," os.system('pip install -q pyngrok ')\n"," os.chdir('/kaggle')\n"," os.makedirs('temp', exist_ok=True)\n"," os.chdir('temp')\n"," os.system('wget -qq http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb')\n"," os.system('wget -qq https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb')\n"," os.system('wget -qq https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb')\n"," os.system('wget -qq https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb')\n"," os.system('apt install -qq libunwind8-dev -y')\n"," !dpkg -i *.deb\n"," os.environ[\"LD_PRELOAD\"] = \"libtcmalloc.so\"\n"," !rm *.deb\n"," print('内存优化已安装')\n"," \n","def LoRA_scripts_install():\n"," %cd $install_path\n"," if reLoad == 1:\n"," !rm -rf lora-scripts\n"," if Path(\"lora-scripts\").exists():\n"," if updata == 1:\n"," %cd lora-scripts\n"," !git checkout .\n"," !git pull\n"," print('LoRA-scripts已更新')\n"," else:\n"," print('LoRA-scripts已安装')\n"," else:\n"," print('LoRA-scripts安装中')\n"," #下载秋叶的脚本\n"," !git clone --recurse-submodules https://github.com/Akegarasu/lora-scripts\n"," print('LoRA-scripts已安装')\n","\n","def venv_install():\n"," %cd /opt/conda/envs\n"," if os.path.exists('venv'):\n"," print('环境已安装')\n"," else:\n"," %cd /kaggle/working/\n"," if not os.path.exists('venv.tar.gz'):\n"," print('环境包下载中')\n"," !wget https://huggingface.co/datasets/sukaka/venv_ai_drow/resolve/main/lora_train_py31010_torch2_cu118_xf17.tar.gz -O venv.tar.gz\n"," print('环境包已下载')\n"," %cd /opt/conda/envs/\n"," !mkdir venv\n"," %cd venv\n"," print('环境安装中')\n"," !tar -xzf /kaggle/working/venv.tar.gz\n"," !source /opt/conda/bin/activate venv\\\n"," print('环境安装完毕')"]},{"cell_type":"code","execution_count":27,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.603112Z","iopub.status.busy":"2023-05-16T08:52:59.602637Z","iopub.status.idle":"2023-05-16T08:52:59.615336Z","shell.execute_reply":"2023-05-16T08:52:59.614389Z","shell.execute_reply.started":"2023-05-16T08:52:59.603079Z"},"trusted":true},"outputs":[],"source":["def download_links(links, target_folder):\n"," for link in links:\n"," if link.startswith('https://huggingface.co/'):\n"," filename = re.search(r'[^/]+$', link).group(0)\n"," os.system(f'aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M -d \"{target_folder}\" -o \"{filename}\" \"{link}\"')\n"," else:\n"," os.system(f'aria2c --console-log-level=error -q -c -x 16 -s 16 -k 1M --remote-time -d \"{target_folder}\" \"{link}\"')\n","def download_models():\n"," download_links(model_download_urls, f'{install_path}/lora-scripts/sd-models')"]},{"cell_type":"code","execution_count":28,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.617220Z","iopub.status.busy":"2023-05-16T08:52:59.616866Z","iopub.status.idle":"2023-05-16T08:52:59.627751Z","shell.execute_reply":"2023-05-16T08:52:59.626852Z","shell.execute_reply.started":"2023-05-16T08:52:59.617186Z"},"trusted":true},"outputs":[],"source":["def ngrok_start(ngrokTokenFile: str, port: int, address_name: str):\n"," if useNgrok == 1:\n"," if Path(ngrokTokenFile).exists():\n"," with open(ngrokTokenFile, encoding=\"utf-8\") as nkfile:\n"," ngrokToken = nkfile.readline()\n"," print('use nrgok')\n"," from pyngrok import conf, ngrok\n"," conf.get_default().auth_token = ngrokToken\n"," conf.get_default().monitor_thread = False\n"," ssh_tunnels = ngrok.get_tunnels(conf.get_default())\n"," if len(ssh_tunnels) == 0:\n"," ssh_tunnel = ngrok.connect(port, bind_tls=True)\n"," print(f'{address_name}:' + ssh_tunnel.public_url)\n"," else:\n"," print(f'{address_name}:' + ssh_tunnels[0].public_url)\n"," else:\n"," print('skip start ngrok')\n"," else:\n"," print('skip start ngrok')"]},{"cell_type":"code","execution_count":29,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.630549Z","iopub.status.busy":"2023-05-16T08:52:59.629058Z","iopub.status.idle":"2023-05-16T08:52:59.725117Z","shell.execute_reply":"2023-05-16T08:52:59.724154Z","shell.execute_reply.started":"2023-05-16T08:52:59.630523Z"},"trusted":true},"outputs":[],"source":["def tensorboard_start():\n"," ngrok_start(ngrokTokenFile,port,'tensorboard地址')\n"," %cd $install_path/lora-scripts\n"," !conda run -n venv --no-capture-output tensorboard --logdir='logs'\n","\n","def gui(launch_args,port: int):\n"," import argparse\n"," import json\n"," import webbrowser\n"," from datetime import datetime\n"," from threading import Lock\n"," import uvicorn\n"," from fastapi import BackgroundTasks, FastAPI, Request\n"," from fastapi.responses import FileResponse\n"," from fastapi.staticfiles import StaticFiles\n"," import toml\n","\n"," app = FastAPI()\n","\n"," lock = Lock()\n","\n"," # fix mimetype error in some fucking systems\n"," sf = StaticFiles(directory=\"frontend/dist\")\n"," _o_fr = sf.file_response\n"," def _hooked_file_response(*args, **kwargs):\n"," full_path = args[0]\n"," r = _o_fr(*args, **kwargs)\n"," if full_path.endswith(\".js\"):\n"," r.media_type = \"application/javascript\"\n"," elif full_path.endswith(\".css\"):\n"," r.media_type = \"text/css\"\n"," return r\n"," sf.file_response = _hooked_file_response\n","\n"," parser = argparse.ArgumentParser(description=\"GUI for training network\")\n"," parser.add_argument(\"--port\", type=int, default=port, help=\"Port to run the server on\")\n","\n"," def run_train(toml_path: str):\n"," print(f\"Training started with config file / 训练开始,使用配置文件: {toml_path}\")\n"," cmd = f\"conda run -n venv --no-capture-output accelerate launch {' '.join(launch_args)} sd-scripts/train_network.py --config_file {toml_path}\"\n"," try:\n"," result = subprocess.run(cmd, shell=True, env=os.environ)\n"," if result.returncode != 0:\n"," print(f\"Training failed / 训练失败\")\n"," else:\n"," print(f\"Training finished / 训练完成\")\n"," except Exception as e:\n"," print(f\"An error occurred when training / 创建训练进程时出现致命错误: {e}\")\n"," finally:\n"," lock.release()\n","\n","\n"," @app.post(\"/api/run\")\n"," async def create_toml_file(request: Request, background_tasks: BackgroundTasks):\n"," acquired = lock.acquire(blocking=False)\n","\n"," if not acquired:\n"," print(\"Training is already running / 已有正在进行的训练\")\n"," return {\"status\": \"fail\", \"detail\": \"Training is already running\"}\n","\n"," timestamp = datetime.now().strftime(\"%Y%m%d-%H%M%S\")\n"," toml_file = f\"toml/{timestamp}.toml\"\n"," toml_data = await request.body()\n"," j = json.loads(toml_data.decode(\"utf-8\"))\n"," with open(toml_file, \"w\") as f:\n"," f.write(toml.dumps(j))\n"," background_tasks.add_task(run_train, toml_file)\n"," return {\"status\": \"success\"}\n","\n"," @app.middleware(\"http\")\n"," async def add_cache_control_header(request, call_next):\n"," response = await call_next(request)\n"," response.headers[\"Cache-Control\"] = \"max-age=0\"\n"," return response\n","\n"," @app.get(\"/\")\n"," async def index():\n"," return FileResponse(\"./frontend/dist/index.html\")\n","\n"," app.mount(\"/\", sf, name=\"static\")\n","\n"," if __name__ == \"__main__\":\n"," args, _ = parser.parse_known_args()\n"," print(f\"Server started at http://127.0.0.1:{port}\")\n","\n"," webbrowser.open(f\"http://127.0.0.1:{port}\")\n"," uvicorn.run(app, host=\"127.0.0.1\", port=port, log_level=\"error\")\n","\n","def train_start():\n"," %cd /kaggle/working\n"," !mkdir output\n"," %cd $install_path/lora-scripts\n"," \n"," ext_args = []\n"," launch_args = []\n"," if multi_gpu == 1:\n"," launch_args.append('--multi_gpu')\n"," launch_args.append('--num_processes=2')\n"," if use_gui == 1:\n"," ngrok_start(ngrokTokenFile1,port1,'炼丹炉gui')\n"," gui(launch_args,port1)\n"," else:\n"," if Path(config_file).is_file():\n"," cmd = f\"\"\"conda run -n venv --no-capture-output accelerate launch {' '.join(launch_args)} \"sd-scripts/train_network.py\" \\\n"," --config_file={config_file}\"\"\"\n"," os.system(cmd)\n"," else:\n"," if lowram == 1:\n"," ext_args.append('--lowram')\n","\n"," if is_v2_model == 1:\n"," ext_args.append('--v2')\n"," else:\n"," ext_args.append(f'--clip_skip {clip_skip}')\n","\n"," if parameterization == 1:\n"," ext_args.append('--v_parameterization')\n","\n"," if train_unet_only == 1:\n"," ext_args.append('--network_train_unet_only')\n","\n"," if train_text_encoder_only == 1:\n"," ext_args.append('--network_train_text_encoder_only')\n","\n"," if network_weights:\n"," ext_args.append(f'--network_weights {network_weights}')\n","\n"," if reg_data_dir:\n"," ext_args.append(f'--reg_data_dir {reg_data_dir}')\n","\n"," if optimizer_type:\n"," ext_args.append(f'--optimizer_type {optimizer_type}')\n","\n"," if optimizer_type == 'DAdaptation':\n"," ext_args.append('--optimizer_args decouple=True')\n","\n"," if save_state == 1:\n"," ext_args.append('--save_state')\n","\n"," if resume:\n"," ext_args.append(f'--resume {resume}')\n","\n"," if persistent_data_loader_workers == 1:\n"," ext_args.append('--persistent_data_loader_workers')\n","\n"," if network_module == 'lycoris.kohya':\n"," ext_args.append(f'--network_args conv_dim={conv_dim} conv_alpha={conv_alpha} algo={algo} dropout={dropout}')\n","\n"," if stop_text_encoder_training != 0:\n"," ext_args.append(f'--stop_text_encoder_training {stop_text_encoder_training}')\n","\n"," if noise_offset != '0':\n"," ext_args.append(f'--noise_offset {noise_offset}')\n","\n"," if min_snr_gamma != 0:\n"," ext_args.append(f'--min_snr_gamma {min_snr_gamma}')\n","\n"," cmd = f\"\"\"conda run -n venv --no-capture-output accelerate launch {' '.join(launch_args)} \"sd-scripts/train_network.py\" \\\n"," --enable_bucket \\\n"," --pretrained_model_name_or_path={pretrained_model} \\\n"," --train_data_dir={train_data_dir} \\\n"," --output_dir=\"/kaggle/working/output\" \\\n"," --logging_dir=\"logs\" \\\n"," --log_prefix={output_name} \\\n"," --resolution={resolution} \\\n"," --network_module={network_module} \\\n"," --max_train_epochs={max_train_epoches} \\\n"," --learning_rate={lr} \\\n"," --unet_lr={unet_lr} \\\n"," --text_encoder_lr={text_encoder_lr} \\\n"," --lr_scheduler={lr_scheduler} \\\n"," --lr_warmup_steps={lr_warmup_steps} \\\n"," --lr_scheduler_num_cycles={lr_restart_cycles} \\\n"," --network_dim={network_dim} \\\n"," --network_alpha={network_alpha} \\\n"," --output_name={output_name} \\\n"," --train_batch_size={batch_size} \\\n"," --save_every_n_epochs={save_every_n_epochs} \\\n"," --mixed_precision=\"fp16\" \\\n"," --save_precision=\"fp16\" \\\n"," --seed=\"1337\" \\\n"," --cache_latents \\\n"," --prior_loss_weight=1 \\\n"," --max_token_length=225 \\\n"," --caption_extension=\".txt\" \\\n"," --save_model_as={save_model_as} \\\n"," --min_bucket_reso={min_bucket_reso} \\\n"," --max_bucket_reso={max_bucket_reso} \\\n"," --keep_tokens={keep_tokens} \\\n"," --xformers --shuffle_caption {' '.join(ext_args)} \"\"\"\n"," os.system(cmd)\n"]},{"cell_type":"code","execution_count":30,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.728159Z","iopub.status.busy":"2023-05-16T08:52:59.727226Z","iopub.status.idle":"2023-05-16T08:52:59.741483Z","shell.execute_reply":"2023-05-16T08:52:59.740397Z","shell.execute_reply.started":"2023-05-16T08:52:59.728126Z"},"trusted":true},"outputs":[],"source":["def main():\n"," startTicks = time.time()\n"," libtcmalloc()\n"," with ProcessPoolExecutor() as executor:\n"," futures = [executor.submit(func) for func in [LoRA_scripts_install, venv_install]]\n"," for future in futures:\n"," future.result()\n"," download_models()\n"," startTicks = time.time()\n"," with ProcessPoolExecutor() as executor:\n"," futures = []\n"," for func in [tensorboard_start, train_start]:\n"," futures.append(executor.submit(func))\n"," time.sleep(1)\n"," for future in futures:\n"," future.result()"]},{"cell_type":"code","execution_count":31,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.743422Z","iopub.status.busy":"2023-05-16T08:52:59.742858Z","iopub.status.idle":"2023-05-16T08:52:59.758702Z","shell.execute_reply":"2023-05-16T08:52:59.757643Z","shell.execute_reply.started":"2023-05-16T08:52:59.743389Z"},"trusted":true},"outputs":[],"source":["def hugface_upload():\n"," if Path(hugTokenFile).exists():\n"," with open(hugTokenFile,encoding = \"utf-8\") as nkfile:\n"," hugToken = nkfile.readline()\n"," if upload == 1 and hugToken != '':\n"," from huggingface_hub import login\n"," # 使用您的 Hugging Face 访问令牌登录\n"," login(token= hugToken)\n"," from huggingface_hub import HfApi\n"," # 实例化 HfApi 类\n"," api = HfApi()\n"," print(\"HfApi 类已实例化\")\n","\n"," # 使用 upload_file() 函数上传文件\n"," print(\"开始上传文件...\")\n"," response = api.upload_file(\n"," path_or_fileobj=\"/kaggle/working/模型.zip\",\n"," path_in_repo=path_in_repo,\n"," repo_id=repo_id,\n"," repo_type=\"dataset\"\n"," )\n"," print(\"文件上传完成\")\n"," print(f\"响应: {response}\")\n","\n","def zip_clear():\n"," if zip_output == 1:\n"," shutil.make_archive('/kaggle/working/模型', 'zip', '/kaggle/working/output/')\n"," print('模型已压缩到output')\n"," if clear_output == 1:\n"," def clear_directory(folder_path):\n"," for filename in os.listdir(folder_path):\n"," file_path = os.path.join(folder_path, filename)\n"," if os.path.isfile(file_path) or os.path.islink(file_path):\n"," os.unlink(file_path)\n"," elif os.path.isdir(file_path):\n"," shutil.rmtree(file_path)\n"," clear_directory('/kaggle/working/output')\n"," clear_directory('/kaggle/working/lora-scripts/logs')\n"," print('清理完毕')\n","\n","def after_train():\n"," zip_clear()\n"," hugface_upload()\n"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2023-05-16T08:52:59.760777Z","iopub.status.busy":"2023-05-16T08:52:59.760419Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["内存优化已安装\n","/kaggle/working/opt/conda/envs\n","\n","环境已安装\n","LoRA-scripts安装中\n","Cloning into 'lora-scripts'...\n","remote: Enumerating objects: 532, done.\u001b[K\n","remote: Counting objects: 100% (381/381), done.\u001b[K\n","remote: Compressing objects: 100% (160/160), done.\u001b[K\n","remote: Total 532 (delta 269), reused 318 (delta 220), pack-reused 151\u001b[K\n","Receiving objects: 100% (532/532), 249.13 KiB | 3.51 MiB/s, done.\n","Resolving deltas: 100% (310/310), done.\n","Submodule 'frontend' (https://github.com/hanamizuki-ai/lora-gui-dist) registered for path 'frontend'\n","Submodule 'sd-scripts' (https://github.com/kohya-ss/sd-scripts.git) registered for path 'sd-scripts'\n","Cloning into '/kaggle/working/lora-scripts/frontend'...\n","remote: Enumerating objects: 200, done. \n","remote: Counting objects: 100% (200/200), done. \n","remote: Compressing objects: 100% (128/128), done. \n","remote: Total 200 (delta 101), reused 147 (delta 48), pack-reused 0 \n","Receiving objects: 100% (200/200), 1.51 MiB | 12.45 MiB/s, done.\n","Resolving deltas: 100% (101/101), done.\n","Cloning into '/kaggle/working/lora-scripts/sd-scripts'...\n","remote: Enumerating objects: 2808, done. \n","remote: Counting objects: 100% (1021/1021), done. \n","remote: Compressing objects: 100% (278/278), done. \n","remote: Total 2808 (delta 841), reused 842 (delta 743), pack-reused 1787 \n","Receiving objects: 100% (2808/2808), 3.28 MiB | 16.98 MiB/s, done.\n","Resolving deltas: 100% (1921/1921), done.\n","Submodule path 'frontend': checked out 'dec83af2b9cb7991d2df19f77efad297b431453c'\n","Submodule path 'sd-scripts': checked out 'cd984992cf6587dfc9582c45bcbe15c25f87bb89'\n","LoRA-scripts已安装\n","skip start ngrok\n","/kaggle/working/lora-scripts\n","/kaggle/working\n","mkdir: cannot create directory ‘output’: File exists\n","/kaggle/working/lora-scripts\n","\n","NOTE: Using experimental fast data loading logic. To disable, pass\n"," \"--load_fast=false\" and report issues on GitHub. More details:\n"," https://github.com/tensorflow/tensorboard/issues/4784\n","\n","Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all\n","TensorBoard 2.10.1 at http://localhost:6006/ (Press CTRL+C to quit)\n","prepare tokenizer\n"]},{"name":"stderr","output_type":"stream","text":["Downloading (…)olve/main/vocab.json: 100%|██████████| 961k/961k [00:00<00:00, 16.7MB/s]\n","Downloading (…)olve/main/merges.txt: 100%|██████████| 525k/525k [00:00<00:00, 12.0MB/s]\n","Downloading (…)cial_tokens_map.json: 100%|██████████| 389/389 [00:00<00:00, 296kB/s]\n","Downloading (…)okenizer_config.json: 100%|██████████| 905/905 [00:00<00:00, 978kB/s]\n"]},{"name":"stdout","output_type":"stream","text":["update token length: 225\n","Use DreamBooth method.\n","prepare images.\n","found directory /kaggle/input/input-qin/input_qin/7_qin contains 22 image files\n","154 train images with repeating.\n","0 reg images.\n","no regularization images / 正則化画像が見つかりませんでした\n","[Dataset 0]\n"," batch_size: 2\n"," resolution: (512, 768)\n"," enable_bucket: True\n"," min_bucket_reso: 256\n"," max_bucket_reso: 1024\n"," bucket_reso_steps: 64\n"," bucket_no_upscale: False\n","\n"," [Subset 0 of Dataset 0]\n"," image_dir: \"/kaggle/input/input-qin/input_qin/7_qin\"\n"," image_count: 22\n"," num_repeats: 7\n"," shuffle_caption: True\n"," keep_tokens: 0\n"," caption_dropout_rate: 0.0\n"," caption_dropout_every_n_epoches: 0\n"," caption_tag_dropout_rate: 0.0\n"," color_aug: False\n"," flip_aug: False\n"," face_crop_aug_range: None\n"," random_crop: False\n"," token_warmup_min: 1,\n"," token_warmup_step: 0,\n"," is_reg: False\n"," class_tokens: qin\n"," caption_extension: .txt\n","\n","\n","[Dataset 0]\n","loading image sizes.\n","make buckets\n","number of images (including repeats) / 各bucketの画像枚数(繰り返し回数を含む)\n","bucket 0: resolution (512, 768), count: 154\n","mean ar error (without repeats): 0.0\n","prepare accelerator\n","Using accelerator 0.15.0 or above.\n","loading model for process 0/1\n","load StableDiffusion checkpoint\n"]},{"name":"stderr","output_type":"stream","text":["100%|██████████| 22/22 [00:00<00:00, 923.08it/s]\n","/opt/conda/envs/venv/lib/python3.10/site-packages/safetensors/torch.py:98: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()\n"," with safe_open(filename, framework=\"pt\", device=device) as f:\n","/opt/conda/envs/venv/lib/python3.10/site-packages/torch/_utils.py:776: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()\n"," return self.fget.__get__(instance, owner)()\n","/opt/conda/envs/venv/lib/python3.10/site-packages/torch/storage.py:899: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()\n"," storage = cls(wrap_storage=untyped_storage)\n"]},{"name":"stdout","output_type":"stream","text":["loading u-net: <All keys matched successfully>\n","loading vae: <All keys matched successfully>\n"]}],"source":["main()"]},{"cell_type":"code","execution_count":null,"metadata":{"trusted":true},"outputs":[],"source":["#训练完毕,手动执行。进行打包和上传\n","after_train()"]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.10"}},"nbformat":4,"nbformat_minor":4}
|