Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,7 +57,7 @@ def environment_setup(use_q6: bool):
|
|
| 57 |
output.append(proc.stderr)
|
| 58 |
|
| 59 |
# Clone ComfyUI if missing
|
| 60 |
-
if not os.path.isdir("
|
| 61 |
output.append("Cloning ComfyUI repo...")
|
| 62 |
proc = subprocess.run("git clone https://github.com/Isi-dev/ComfyUI /content/ComfyUI", shell=True, capture_output=True, text=True)
|
| 63 |
output.append(proc.stdout + proc.stderr)
|
|
@@ -76,9 +76,9 @@ def environment_setup(use_q6: bool):
|
|
| 76 |
output.append("ComfyUI_GGUF repo already exists")
|
| 77 |
|
| 78 |
# Ensure model directories exist
|
| 79 |
-
model_unet_dir = "
|
| 80 |
-
text_enc_dir = "
|
| 81 |
-
vae_dir = "
|
| 82 |
os.makedirs(model_unet_dir, exist_ok=True)
|
| 83 |
os.makedirs(text_enc_dir, exist_ok=True)
|
| 84 |
os.makedirs(vae_dir, exist_ok=True)
|
|
@@ -110,7 +110,7 @@ def imports_initialization():
|
|
| 110 |
global unet_loader, clip_loader, clip_encode_positive, clip_encode_negative
|
| 111 |
global vae_loader, empty_latent_video, ksampler, vae_decode, save_webp, save_webm
|
| 112 |
|
| 113 |
-
sys.path.insert(0, '
|
| 114 |
|
| 115 |
from comfy import model_management
|
| 116 |
from nodes import (
|
|
@@ -154,7 +154,7 @@ def clear_memory():
|
|
| 154 |
del obj
|
| 155 |
gc.collect()
|
| 156 |
|
| 157 |
-
def save_as_mp4(images, filename_prefix, fps, output_dir="
|
| 158 |
os.makedirs(output_dir, exist_ok=True)
|
| 159 |
output_path = f"{output_dir}/{filename_prefix}.mp4"
|
| 160 |
frames = [(img.cpu().numpy() * 255).astype(np.uint8) for img in images]
|
|
@@ -163,7 +163,7 @@ def save_as_mp4(images, filename_prefix, fps, output_dir="/content/ComfyUI/outpu
|
|
| 163 |
writer.append_data(frame)
|
| 164 |
return output_path
|
| 165 |
|
| 166 |
-
def save_as_webp(images, filename_prefix, fps, quality=90, lossless=False, method=4, output_dir="
|
| 167 |
os.makedirs(output_dir, exist_ok=True)
|
| 168 |
output_path = f"{output_dir}/{filename_prefix}.webp"
|
| 169 |
frames = [(img.cpu().numpy() * 255).astype(np.uint8) for img in images]
|
|
@@ -173,7 +173,7 @@ def save_as_webp(images, filename_prefix, fps, quality=90, lossless=False, metho
|
|
| 173 |
writer.append_data(frame)
|
| 174 |
return output_path
|
| 175 |
|
| 176 |
-
def save_as_webm(images, filename_prefix, fps, codec="vp9", quality=32, output_dir="
|
| 177 |
os.makedirs(output_dir, exist_ok=True)
|
| 178 |
output_path = f"{output_dir}/{filename_prefix}.webm"
|
| 179 |
frames = [(img.cpu().numpy() * 255).astype(np.uint8) for img in images]
|
|
@@ -183,7 +183,7 @@ def save_as_webm(images, filename_prefix, fps, codec="vp9", quality=32, output_d
|
|
| 183 |
writer.append_data(frame)
|
| 184 |
return output_path
|
| 185 |
|
| 186 |
-
def save_as_image(image, filename_prefix, output_dir="
|
| 187 |
os.makedirs(output_dir, exist_ok=True)
|
| 188 |
output_path = f"{output_dir}/{filename_prefix}.png"
|
| 189 |
frame = (image.cpu().numpy() * 255).astype(np.uint8)
|
|
|
|
| 57 |
output.append(proc.stderr)
|
| 58 |
|
| 59 |
# Clone ComfyUI if missing
|
| 60 |
+
if not os.path.isdir("./ComfyUI"):
|
| 61 |
output.append("Cloning ComfyUI repo...")
|
| 62 |
proc = subprocess.run("git clone https://github.com/Isi-dev/ComfyUI /content/ComfyUI", shell=True, capture_output=True, text=True)
|
| 63 |
output.append(proc.stdout + proc.stderr)
|
|
|
|
| 76 |
output.append("ComfyUI_GGUF repo already exists")
|
| 77 |
|
| 78 |
# Ensure model directories exist
|
| 79 |
+
model_unet_dir = "./ComfyUI/models/unet"
|
| 80 |
+
text_enc_dir = "./ComfyUI/models/text_encoders"
|
| 81 |
+
vae_dir = "./ComfyUI/models/vae"
|
| 82 |
os.makedirs(model_unet_dir, exist_ok=True)
|
| 83 |
os.makedirs(text_enc_dir, exist_ok=True)
|
| 84 |
os.makedirs(vae_dir, exist_ok=True)
|
|
|
|
| 110 |
global unet_loader, clip_loader, clip_encode_positive, clip_encode_negative
|
| 111 |
global vae_loader, empty_latent_video, ksampler, vae_decode, save_webp, save_webm
|
| 112 |
|
| 113 |
+
sys.path.insert(0, './ComfyUI')
|
| 114 |
|
| 115 |
from comfy import model_management
|
| 116 |
from nodes import (
|
|
|
|
| 154 |
del obj
|
| 155 |
gc.collect()
|
| 156 |
|
| 157 |
+
def save_as_mp4(images, filename_prefix, fps, output_dir="./ComfyUI/output"):
|
| 158 |
os.makedirs(output_dir, exist_ok=True)
|
| 159 |
output_path = f"{output_dir}/{filename_prefix}.mp4"
|
| 160 |
frames = [(img.cpu().numpy() * 255).astype(np.uint8) for img in images]
|
|
|
|
| 163 |
writer.append_data(frame)
|
| 164 |
return output_path
|
| 165 |
|
| 166 |
+
def save_as_webp(images, filename_prefix, fps, quality=90, lossless=False, method=4, output_dir="./ComfyUI/output"):
|
| 167 |
os.makedirs(output_dir, exist_ok=True)
|
| 168 |
output_path = f"{output_dir}/{filename_prefix}.webp"
|
| 169 |
frames = [(img.cpu().numpy() * 255).astype(np.uint8) for img in images]
|
|
|
|
| 173 |
writer.append_data(frame)
|
| 174 |
return output_path
|
| 175 |
|
| 176 |
+
def save_as_webm(images, filename_prefix, fps, codec="vp9", quality=32, output_dir="./ComfyUI/output"):
|
| 177 |
os.makedirs(output_dir, exist_ok=True)
|
| 178 |
output_path = f"{output_dir}/{filename_prefix}.webm"
|
| 179 |
frames = [(img.cpu().numpy() * 255).astype(np.uint8) for img in images]
|
|
|
|
| 183 |
writer.append_data(frame)
|
| 184 |
return output_path
|
| 185 |
|
| 186 |
+
def save_as_image(image, filename_prefix, output_dir="./ComfyUI/output"):
|
| 187 |
os.makedirs(output_dir, exist_ok=True)
|
| 188 |
output_path = f"{output_dir}/{filename_prefix}.png"
|
| 189 |
frame = (image.cpu().numpy() * 255).astype(np.uint8)
|