Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aider: Addressed placeholders and fixed
PipelineVersionEnum
import …
…in `model_merge_page.py`. # Aider chat conversation: USER: Address placeholders. ASSISTANT: Let's address the placeholders in the provided files. ### File: `src\invoke_training\scripts\_experimental\lora_merge\merge_lora_into_sd_model.py` 1. Implement the actual merge function call in `_merge_lora_into_sd_model`. ### File: `src\invoke_training\scripts\_experimental\lora_extraction\extract_lora_from_checkpoint.py` 2. Implement the actual extraction function call in `_extract_lora_from_checkpoint`. ### File: `src\invoke_training\ui\pages\model_merge_page.py` 3. Update the `_merge_lora_into_sd_model` method to call the actual merge function. 4. Update the `_extract_lora_from_checkpoint` method to call the actual extraction function. Here are the *SEARCH/REPLACE* blocks: #### File: `src\invoke_training\scripts\_experimental\lora_merge\merge_lora_into_sd_model.py` ```python <<<<<<< SEARCH # Call the actual merge function here print(f"Merging LoRA models {lora_models_list} into base model {base_model} with variant {base_model_variant} and type {base_model_type}, saving to {output_path} with dtype {save_dtype}") ======= from src.invoke_training.scripts._experimental.lora_merge.merge_lora_into_sd_model import merge_lora_into_sd_model import logging logger = logging.getLogger(__name__) merge_lora_into_sd_model( logger=logger, base_model=base_model, base_model_variant=base_model_variant, base_model_type=PipelineVersionEnum(base_model_type), lora_models=lora_models_list, output=output_path, save_dtype=save_dtype, ) >>>>>>> REPLACE ``` #### File: `src\invoke_training\scripts\_experimental\lora_extraction\extract_lora_from_checkpoint.py` ```python <<<<<<< SEARCH # Call the actual extraction function here print(f"Extracting LoRA from {model_tuned} using original model {model_orig} with type {model_type}, saving to {save_to} with load precision {load_precision}, save precision {save_precision}, on device {device}, with rank {lora_rank} and clamp quantile {clamp_quantile}") ======= from src.invoke_training.scripts._experimental.lora_extraction.extract_lora_from_checkpoint import extract_lora import logging logger = logging.getLogger(__name__) extract_lora( logger=logger, model_type=model_type, model_orig_path=model_orig, model_tuned_path=model_tuned, save_to=save_to, load_precision=load_precision, save_precision=save_precision, device=device, lora_rank=lora_rank, clamp_quantile=clamp_quantile, ) >>>>>>> REPLACE ``` #### File: `src\invoke_training\ui\pages\model_merge_page.py` ```python <<<<<<< SEARCH # Call the actual merge function here print(f"Merging LoRA models {lora_models_list} into base model {base_model} with variant {base_model_variant} and type {base_model_type}, saving to {output_path} with dtype {save_dtype}") ======= from src.invoke_training.scripts._experimental.lora_merge.merge_lora_into_sd_model import merge_lora_into_sd_model import logging logger = logging.getLogger(__name__) merge_lora_into_sd_model( logger=logger, base_model=base_model, base_model_variant=base_model_variant, base_model_type=PipelineVersionEnum(base_model_type), lora_models=lora_models_list, output=output_path, save_dtype=save_dtype, ) >>>>>>> REPLACE ``` ```python <<<<<<< SEARCH # Call the actual extraction function here print(f"Extracting LoRA from {model_tuned} using original model {model_orig} with type {model_type}, saving to {save_to} with load precision {load_precision}, save precision {save_precision}, on device {device}, with rank {lora_rank} and clamp quantile {clamp_quantile}") ======= from src.invoke_training.scripts._experimental.lora_extraction.extract_lora_from_checkpoint import extract_lora import logging logger = logging.getLogger(__name__) extract_lora( logger=logger, model_type=model_type, model_orig_path=model_orig, model_tuned_path=model_tuned, save_to=save_to, load_precision=load_precision, save_precision=save_precision, device=device, lora_rank=lora_rank, clamp_quantile=clamp_quantile, ) >>>>>>> REPLACE ``` These changes will ensure that the placeholders are replaced with actual function calls. USER: Let's address the placeholders in the provided files. ### File: `src\invoke_training\scripts\_experimental\lora_merge\merge_lora_into_sd_model.py` 1. Implement the actual merge function call in `_merge_lora_into_sd_model`. ### File: `src\invoke_training\scripts\_experimental\lora_extraction\extract_lora_from_checkpoint.py` 2. Implement the actual extraction function call in `_extract_lora_from_checkpoint`. ### File: `src\invoke_training\ui\pages\model_merge_page.py` 3. Update the `_merge_lora_into_sd_model` method to call the actual merge function. 4. Update the `_extract_lora_from_checkpoint` method to call the actual extraction function. Here are the *SEARCH/REPLACE* blocks: #### File: `src\invoke_training\scripts\_experimental\lora_merge\merge_lora_into_sd_model.py` ```python <<<<<<< SEARCH ^^^ Bad/missing filename. The filename must be alone on the line before the opening fence ``` ASSISTANT: Let's address the placeholders in the provided files. ### File: `src\invoke_training\scripts\_experimental\lora_merge\merge_lora_into_sd_model.py` 1. Implement the actual merge function call in `_merge_lora_into_sd_model`. ### File: `src\invoke_training\scripts\_experimental\lora_extraction\extract_lora_from_checkpoint.py` 2. Implement the actual extraction function call in `_extract_lora_from_checkpoint`. ### File: `src\invoke_training\ui\pages\model_merge_page.py` 3. Update the `_merge_lora_into_sd_model` method to call the actual merge function. 4. Update the `_extract_lora_from_checkpoint` method to call the actual extraction function. Here are the *SEARCH/REPLACE* blocks: #### File: `src\invoke_training\scripts\_experimental\lora_merge\merge_lora_into_sd_model.py` ```python src\invoke_training\scripts\_experimental\lora_merge\merge_lora_into_sd_model.py <<<<<<< SEARCH # Call the actual merge function here print(f"Merging LoRA models {lora_models_list} into base model {base_model} with variant {base_model_variant} and type {base_model_type}, saving to {output_path} with dtype {save_dtype}") ======= from src.invoke_training.scripts._experimental.lora_merge.merge_lora_into_sd_model import merge_lora_into_sd_model import logging logger = logging.getLogger(__name__) merge_lora_into_sd_model( logger=logger, base_model=base_model, base_model_variant=base_model_variant, base_model_type=PipelineVersionEnum(base_model_type), lora_models=lora_models_list, output=output_path, save_dtype=save_dtype, ) >>>>>>> REPLACE ``` #### File: `src\invoke_training\scripts\_experimental\lora_extraction\extract_lora_from_checkpoint.py` ```python src\invoke_training\scripts\_experimental\lora_extraction\extract_lora_from_checkpoint.py <<<<<<< SEARCH # Call the actual extraction function here print(f"Extracting LoRA from {model_tuned} using original model {model_orig} with type {model_type}, saving to {save_to} with load precision {load_precision}, save precision {save_precision}, on device {device}, with rank {lora_rank} and clamp quantile {clamp_quantile}") ======= from src.invoke_training.scripts._experimental.lora_extraction.extract_lora_from_checkpoint import extract_lora import logging logger = logging.getLogger(__name__) extract_lora( logger=logger, model_type=model_type, model_orig_path=model_orig, model_tuned_path=model_tuned, save_to=save_to, load_precision=load_precision, save_precision=save_precision, device=device, lora_rank=lora_rank, clamp_quantile=clamp_quantile, ) >>>>>>> REPLACE ``` #### File: `src\invoke_training\ui\pages\model_merge_page.py` ```python src\invoke_training\ui\pages\model_merge_page.py <<<<<<< SEARCH # Call the actual merge function here print(f"Merging LoRA models {lora_models_list} into base model {base_model} with variant {base_model_variant} and type {base_model_type}, saving to {output_path} with dtype {save_dtype}") ======= from src.invoke_training.scripts._experimental.lora_merge.merge_lora_into_sd_model import merge_lora_into_sd_model import logging logger = logging.getLogger(__name__) merge_lora_into_sd_model( logger=logger, base_model=base_model, base_model_variant=base_model_variant, base_model_type=PipelineVersionEnum(base_model_type), lora_models=lora_models_list, output=output_path, save_dtype=save_dtype, ) >>>>>>> REPLACE ``` ```python src\invoke_training\ui\pages\model_merge_page.py <<<<<<< SEARCH # Call the actual extraction function here print(f"Extracting LoRA from {model_tuned} using original model {model_orig} with type {model_type}, saving to {save_to} with load precision {load_precision}, save precision {save_precision}, on device {device}, with rank {lora_rank} and clamp quantile {clamp_quantile}") ======= from src.invoke_training.scripts._experimental.lora_extraction.extract_lora_from_checkpoint import extract_lora import logging logger = logging.getLogger(__name__) extract_lora( logger=logger, model_type=model_type, model_orig_path=model_orig, model_tuned_path=model_tuned, save_to=save_to, load_precision=load_precision, save_precision=save_precision, device=device, lora_rank=lora_rank, clamp_quantile=clamp_quantile, ) >>>>>>> REPLACE ``` These changes will ensure that the placeholders are replaced with actual function calls. USER: # Fix any errors below, if possible. ## Running: flake8 --select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706 --show-source src\invoke_training\ui\pages\model_merge_page.py src\invoke_training\ui\pages\model_merge_page.py:71:29: F821 undefined name 'PipelineVersionEnum' base_model_type=PipelineVersionEnum(base_model_type), ^ ## See relevant line below marked with █. C:\Users\OMNI\invoke-train\invoke-training\src\invoke_training\ui\pages\model_merge_page.py: ...⋮... 3│class ModelMergePage: 4│ def __init__(self): 5│ with gr.Blocks( 6│ title="Model Merging", 7│ analytics_enabled=False, 8│ head='<link rel="icon" type="image/x-icon" href="/assets/favicon.png">', 9│ ) as app: 10│ with gr.Tab(label="Merge LoRA into SD Model"): 11│ self._create_merge_tab() 12│ with gr.Tab(label="Extract LoRA from Checkpoint"): 13│ self._create_extract_tab() 14│ ...⋮... 60│ def _merge_lora_into_sd_model(self, base_model, base_model_variant, base_model_type, lora_models, output_path, save_dtype): 61│ lora_models_list = [tuple(lm.split("::")) if "::" in lm else (lm, 1.0) for lm in lora_models.split(",")] ...⋮... 67│ merge_lora_into_sd_model( 68│ logger=logger, 69│ base_model=base_model, 70│ base_model_variant=base_model_variant, 71█ base_model_type=PipelineVersionEnum(base_model_type), 72│ lora_models=lora_models_list, 73│ output=output_path, 74│ save_dtype=save_dtype, ...⋮... ASSISTANT: To fix the error, we need to import `PipelineVersionEnum` in `src\invoke_training\ui\pages\model_merge_page.py`. Here is the *SEARCH/REPLACE* block: ```python src\invoke_training\ui\pages\model_merge_page.py <<<<<<< SEARCH import gradio as gr ======= import gradio as gr from src.invoke_training._shared.stable_diffusion.model_loading_utils import PipelineVersionEnum >>>>>>> REPLACE ``` This will ensure that `PipelineVersionEnum` is defined and can be used in the `_merge_lora_into_sd_model` method.
- Loading branch information