hollowstrawberry / kohya-colab

Accessible Google Colab notebooks for Stable Diffusion Lora training, based on the work of kohya-ss and Linaqruf
GNU General Public License v3.0
564 stars 79 forks source link

Incorrect root directory in non-colab environment. #170

Open wutipong opened 1 week ago

wutipong commented 1 week ago

I tried to run the Lora_Trainer_XL locally (still not successfully, need some more fidgetting). I noticed that the root_dir is set to "~/Loras" when COLAB is not true.

However, Python (at least at the version I'm using, which is 3.12) does not expand ~ to current user home. Instead it just uses the path as is. The directory referred to by this variable is <jupyter_running_dir>/~/Loras, which is way off. The script ended up not find any images although there are files at ~/Loras/<project>/dataset directory.

A fix would be, to replace:

root_dir = "/content" if COLAB else "~/Loras"

with

import pathlib
....

root_dir = "/content" if COLAB else pathlib.Path.home() / "Loras"

This has been tested on a Linux system (Manjaro Linux). Haven't tried on Windows yet though.