Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).
|
|
38 |
good_vae = AutoencoderKL.from_pretrained(base_model, subfolder="vae", torch_dtype=dtype).to(device)
|
39 |
|
40 |
txt2img_pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=dtype).to(device)
|
41 |
-
|
42 |
|
43 |
# img2img model
|
44 |
img2img_pipe = AutoPipelineForImage2Image.from_pretrained(base_model, vae=good_vae, transformer=txt2img_pipe.transformer, text_encoder=txt2img_pipe.text_encoder, tokenizer=txt2img_pipe.tokenizer, text_encoder_2=txt2img_pipe.text_encoder_2, tokenizer_2=txt2img_pipe.tokenizer_2, torch_dtype=dtype)
|
@@ -67,7 +67,7 @@ class calculateDuration:
|
|
67 |
else:
|
68 |
print(f"Elapsed time: {self.elapsed_time:.6f} seconds")
|
69 |
|
70 |
-
|
71 |
def generate_image(orginal_image, prompt, adapter_names, steps, seed, image_strength, cfg_scale, width, height, progress):
|
72 |
|
73 |
|
@@ -147,7 +147,8 @@ def upload_image_to_r2(image, account_id, access_key, secret_key, bucket_name):
|
|
147 |
|
148 |
def generate_random_4_digit_string():
|
149 |
return ''.join(random.choices(string.digits, k=4))
|
150 |
-
|
|
|
151 |
def run_lora(prompt, image_url, lora_strings_json, image_strength, cfg_scale, steps, randomize_seed, seed, width, height, upload_to_r2, account_id, access_key, secret_key, bucket, progress=gr.Progress(track_tqdm=True)):
|
152 |
print("run_lora", prompt, lora_strings_json, cfg_scale, steps, width, height)
|
153 |
gr.Info("Starting process")
|
@@ -167,10 +168,6 @@ def run_lora(prompt, image_url, lora_strings_json, image_strength, cfg_scale, s
|
|
167 |
with calculateDuration("Unloading LoRA"):
|
168 |
img2img_pipe.unload_lora_weights()
|
169 |
txt2img_pipe.unload_lora_weights()
|
170 |
-
|
171 |
-
print(txt2img_pipe.get_active_adapters())
|
172 |
-
list_adapters_component_wise = txt2img_pipe.get_list_adapters()
|
173 |
-
print(list_adapters_component_wise)
|
174 |
|
175 |
lora_configs = None
|
176 |
adapter_names = []
|
|
|
38 |
good_vae = AutoencoderKL.from_pretrained(base_model, subfolder="vae", torch_dtype=dtype).to(device)
|
39 |
|
40 |
txt2img_pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=dtype).to(device)
|
41 |
+
txt2img_pipe.__class__.load_lora_into_transformer = classmethod(load_lora_into_transformer)
|
42 |
|
43 |
# img2img model
|
44 |
img2img_pipe = AutoPipelineForImage2Image.from_pretrained(base_model, vae=good_vae, transformer=txt2img_pipe.transformer, text_encoder=txt2img_pipe.text_encoder, tokenizer=txt2img_pipe.tokenizer, text_encoder_2=txt2img_pipe.text_encoder_2, tokenizer_2=txt2img_pipe.tokenizer_2, torch_dtype=dtype)
|
|
|
67 |
else:
|
68 |
print(f"Elapsed time: {self.elapsed_time:.6f} seconds")
|
69 |
|
70 |
+
|
71 |
def generate_image(orginal_image, prompt, adapter_names, steps, seed, image_strength, cfg_scale, width, height, progress):
|
72 |
|
73 |
|
|
|
147 |
|
148 |
def generate_random_4_digit_string():
|
149 |
return ''.join(random.choices(string.digits, k=4))
|
150 |
+
|
151 |
+
@spaces.GPU(duration=120)
|
152 |
def run_lora(prompt, image_url, lora_strings_json, image_strength, cfg_scale, steps, randomize_seed, seed, width, height, upload_to_r2, account_id, access_key, secret_key, bucket, progress=gr.Progress(track_tqdm=True)):
|
153 |
print("run_lora", prompt, lora_strings_json, cfg_scale, steps, width, height)
|
154 |
gr.Info("Starting process")
|
|
|
168 |
with calculateDuration("Unloading LoRA"):
|
169 |
img2img_pipe.unload_lora_weights()
|
170 |
txt2img_pipe.unload_lora_weights()
|
|
|
|
|
|
|
|
|
171 |
|
172 |
lora_configs = None
|
173 |
adapter_names = []
|