Small tweaks to ckpt processing, add tool to prefix params keys

This commit is contained in:
Ean Garvey
2024-06-01 11:53:40 -05:00
parent 26f80ccbbb
commit 42abc6787d
3 changed files with 28 additions and 1 deletions

View File

@@ -262,6 +262,8 @@ class StableDiffusion:
control_mode,
hints,
):
if seed == -1:
seed = randint(0, sys.maxsize)
img = self.sd_pipe.generate_images(
prompt,
negative_prompt,

View File

@@ -71,7 +71,12 @@ def save_irpa(weights_path, prepend_str):
new_key = prepend_str + key
archive.add_tensor(new_key, weights[key])
irpa_file = weights_path.replace(".safetensors", ".irpa")
if "safetensors" in weights_path:
irpa_file = weights_path.replace(".safetensors", ".irpa")
elif "irpa" in weights_path:
irpa_file = weights_path
else:
return Exception("Invalid file format. Please provide a .safetensors or .irpa file.")
archive.save(irpa_file)
return irpa_file

View File

@@ -0,0 +1,20 @@
from apps.shark_studio.modules.ckpt_processing import save_irpa
import argparse
import safetensors
parser = argparse.ArgumentParser()
parser.add_argument(
"--input",
type=str,
default="",
help="input safetensors/irpa",
)
parser.add_argument(
"--prefix",
type=str,
default="",
help="prefix to add to all the keys in the irpa",
)
args = parser.parse_args()
output_file = save_irpa(args.input, args.prefix)
print("saved irpa to", output_file, "with prefix", args.prefix)