Spaces:
Running
on
L4
Running
on
L4
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,6 +23,7 @@ import tempfile
|
|
| 23 |
import cv2
|
| 24 |
import os
|
| 25 |
import requests
|
|
|
|
| 26 |
|
| 27 |
snapshot_download(repo_id="LiuZichen/MagicQuill-models", repo_type="model", local_dir="models")
|
| 28 |
# HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
@@ -177,6 +178,11 @@ def generate(ckpt_name, total_mask, original_image, add_color_image, add_edge_im
|
|
| 177 |
)
|
| 178 |
|
| 179 |
final_image_base64 = tensor_to_base64(final_image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
return final_image_base64
|
| 181 |
|
| 182 |
def generate_image_handler(x, ckpt_name, negative_prompt, fine_edge, grow_size, edge_strength, color_strength, inpaint_strength, seed, steps, cfg, sampler_name, scheduler):
|
|
|
|
| 23 |
import cv2
|
| 24 |
import os
|
| 25 |
import requests
|
| 26 |
+
import gc
|
| 27 |
|
| 28 |
snapshot_download(repo_id="LiuZichen/MagicQuill-models", repo_type="model", local_dir="models")
|
| 29 |
# HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
|
|
| 178 |
)
|
| 179 |
|
| 180 |
final_image_base64 = tensor_to_base64(final_image)
|
| 181 |
+
|
| 182 |
+
del latent_samples, final_image, lineart_output, color_output
|
| 183 |
+
gc.collect()
|
| 184 |
+
torch.cuda.empty_cache()
|
| 185 |
+
|
| 186 |
return final_image_base64
|
| 187 |
|
| 188 |
def generate_image_handler(x, ckpt_name, negative_prompt, fine_edge, grow_size, edge_strength, color_strength, inpaint_strength, seed, steps, cfg, sampler_name, scheduler):
|