Skip to content

Commit

Permalink
Improve PYTHON variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaltais committed Apr 18, 2024
1 parent 84fb7ce commit 85bdb37
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions kohya_gui/convert_model_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def convert_model(
Expand Down Expand Up @@ -50,7 +50,7 @@ def convert_model(
return

run_cmd = [
PYTHON,
fr'"{PYTHON}"',
fr'"{scriptdir}/sd-scripts/tools/convert_diffusers20_original_sd.py"',
]

Expand Down
2 changes: 0 additions & 2 deletions kohya_gui/dreambooth_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
huggingface = None
use_shell = False

PYTHON = fr'"{sys.executable}"'

TRAIN_BUTTON_VISIBLE = [gr.Button(visible=True), gr.Button(visible=False), gr.Textbox(value=time.time())]


Expand Down
4 changes: 2 additions & 2 deletions kohya_gui/extract_lora_from_dylora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def extract_dylora(
Expand Down Expand Up @@ -51,7 +51,7 @@ def extract_dylora(
save_to = f"{path}_tmp{ext}"

run_cmd = [
PYTHON,
fr'"{PYTHON}"',
rf'"{scriptdir}/sd-scripts/networks/extract_lora_from_dylora.py"',
"--save_to",
rf'"{save_to}"',
Expand Down
4 changes: 2 additions & 2 deletions kohya_gui/extract_lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def extract_lora(
Expand Down Expand Up @@ -74,7 +74,7 @@ def extract_lora(
return

run_cmd = [
PYTHON,
fr'"{PYTHON}"',
fr'"{scriptdir}/sd-scripts/networks/extract_lora_from_models.py"',
"--load_precision",
load_precision,
Expand Down
4 changes: 2 additions & 2 deletions kohya_gui/extract_lycoris_locon_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def extract_lycoris_locon(
Expand Down Expand Up @@ -74,7 +74,7 @@ def extract_lycoris_locon(
path, ext = os.path.splitext(output_name)
output_name = f"{path}_tmp{ext}"

run_cmd = [PYTHON, fr'"{scriptdir}/tools/lycoris_locon_extract.py"']
run_cmd = [fr'"{PYTHON}"', fr'"{scriptdir}/tools/lycoris_locon_extract.py"']

if is_sdxl:
run_cmd.append("--is_sdxl")
Expand Down
6 changes: 3 additions & 3 deletions kohya_gui/finetune_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable

presets_dir = rf"{scriptdir}/presets"
TRAIN_BUTTON_VISIBLE = [gr.Button(visible=True), gr.Button(visible=False), gr.Textbox(value=time.time())]
Expand Down Expand Up @@ -569,7 +569,7 @@ def train_model(
if generate_caption_database:
# Define the command components
run_cmd = [
PYTHON,
fr'"{PYTHON}"',
f'"{scriptdir}/sd-scripts/finetune/merge_captions_to_metadata.py"',
]

Expand Down Expand Up @@ -606,7 +606,7 @@ def train_model(
if generate_image_buckets:
# Build the command to run the preparation script
run_cmd = [
PYTHON,
fr'"{PYTHON}"',
f'"{scriptdir}/sd-scripts/finetune/prepare_buckets_latents.py"',
image_folder,
os.path.join(train_dir, caption_metadata_filename),
Expand Down
4 changes: 2 additions & 2 deletions kohya_gui/git_caption_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Set up logging
log = setup_logging()

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def caption_images(
Expand All @@ -35,7 +35,7 @@ def caption_images(

log.info(f"GIT captioning files in {train_data_dir}...")

run_cmd = [PYTHON, fr'"{scriptdir}/sd-scripts/finetune/make_captions_by_git.py"']
run_cmd = [fr'"{PYTHON}"', fr'"{scriptdir}/sd-scripts/finetune/make_captions_by_git.py"']

# Add --model_id if provided
if model_id != "":
Expand Down
4 changes: 2 additions & 2 deletions kohya_gui/group_images_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Set up logging
log = setup_logging()

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def group_images(
Expand All @@ -34,7 +34,7 @@ def group_images(
log.info(f"Grouping images in {input_folder}...")

run_cmd = [
PYTHON,
fr'"{PYTHON}"',
f'"{scriptdir}/tools/group_images.py"',
fr'"{input_folder}"',
fr'"{output_folder}"',
Expand Down
6 changes: 3 additions & 3 deletions kohya_gui/merge_lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def check_model(model):
Expand Down Expand Up @@ -425,9 +425,9 @@ def merge_lora(
return

if not sdxl_model:
run_cmd = [PYTHON, fr'"{scriptdir}/sd-scripts/networks/merge_lora.py"']
run_cmd = [fr'"{PYTHON}"', fr'"{scriptdir}/sd-scripts/networks/merge_lora.py"']
else:
run_cmd = [PYTHON, fr'"{scriptdir}/sd-scripts/networks/sdxl_merge_lora.py"']
run_cmd = [fr'"{PYTHON}"', fr'"{scriptdir}/sd-scripts/networks/sdxl_merge_lora.py"']

if sd_model:
run_cmd.append("--sd_model")
Expand Down
4 changes: 2 additions & 2 deletions kohya_gui/merge_lycoris_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def merge_lycoris(
Expand All @@ -39,7 +39,7 @@ def merge_lycoris(

# Build the command to run merge_lycoris.py using list format
run_cmd = [
PYTHON,
fr'"{PYTHON}"',
fr'"{scriptdir}/tools/merge_lycoris.py"',
fr'"{base_model}"',
fr'"{lycoris_model}"',
Expand Down
4 changes: 2 additions & 2 deletions kohya_gui/resize_lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄

PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def resize_lora(
Expand Down Expand Up @@ -65,7 +65,7 @@ def resize_lora(
device = "cuda"

run_cmd = [
PYTHON,
fr'"{PYTHON}"',
fr'"{scriptdir}/sd-scripts/networks/resize_lora.py"',
"--save_precision",
save_precision,
Expand Down
2 changes: 1 addition & 1 deletion kohya_gui/svd_merge_lora_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
refresh_symbol = "\U0001f504" # 🔄
save_style_symbol = "\U0001f4be" # 💾
document_symbol = "\U0001F4C4" # 📄
PYTHON = fr'"{sys.executable}"'
PYTHON = sys.executable


def svd_merge_lora(
Expand Down
2 changes: 1 addition & 1 deletion kohya_gui/wd14_caption_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def caption_images(

log.info(f"Captioning files in {train_data_dir}...")
run_cmd = [
get_executable_path("accelerate"),
fr'"{get_executable_path("accelerate")}"',
"launch",
fr'"{scriptdir}/sd-scripts/finetune/tag_images_by_wd14_tagger.py"',
]
Expand Down

0 comments on commit 85bdb37

Please sign in to comment.