Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import logging
|
|
| 2 |
import random
|
| 3 |
import warnings
|
| 4 |
import os
|
| 5 |
-
os.environ["GIT_TERMINAL_PROMPT"] = "0"
|
| 6 |
import gradio as gr
|
| 7 |
import numpy as np
|
| 8 |
import spaces
|
|
@@ -15,6 +14,8 @@ import subprocess
|
|
| 15 |
from huggingface_hub import hf_hub_download
|
| 16 |
import tempfile
|
| 17 |
|
|
|
|
|
|
|
| 18 |
# Setup ComfyUI and custom nodes
|
| 19 |
if not os.path.exists("ComfyUI"):
|
| 20 |
subprocess.run(["git", "clone", "https://github.com/comfyanonymous/ComfyUI"])
|
|
@@ -22,10 +23,10 @@ if not os.path.exists("ComfyUI"):
|
|
| 22 |
custom_nodes_dir = os.path.join("ComfyUI", "custom_nodes")
|
| 23 |
os.makedirs(custom_nodes_dir, exist_ok=True)
|
| 24 |
|
| 25 |
-
# Clone
|
| 26 |
-
usd_dir = os.path.join(custom_nodes_dir, "
|
| 27 |
if not os.path.exists(usd_dir):
|
| 28 |
-
subprocess.run(["git", "clone", "https://github.com/ssitu/
|
| 29 |
|
| 30 |
# Clone comfy_mtb
|
| 31 |
mtb_dir = os.path.join(custom_nodes_dir, "comfy_mtb")
|
|
@@ -47,11 +48,11 @@ if not os.path.exists(kjn_dir):
|
|
| 47 |
comfy_models_dir = os.path.join("ComfyUI", "models")
|
| 48 |
os.makedirs(comfy_models_dir, exist_ok=True)
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
os.makedirs(
|
| 53 |
-
if not os.path.exists(os.path.join(
|
| 54 |
-
hf_hub_download(repo_id="Kijai/flux-fp8", filename="flux1-dev-fp8.safetensors", local_dir=
|
| 55 |
|
| 56 |
# CLIP models
|
| 57 |
clip_dir = os.path.join(comfy_models_dir, "clip")
|
|
@@ -204,8 +205,8 @@ def enhance_image(
|
|
| 204 |
vaeloader = NODE_CLASS_MAPPINGS["VAELoader"]()
|
| 205 |
vae = get_value_at_index(vaeloader.load_vae(vae_name="ae.safetensors"), 0)
|
| 206 |
|
| 207 |
-
unetloader = NODE_CLASS_MAPPINGS["
|
| 208 |
-
model = get_value_at_index(unetloader.
|
| 209 |
|
| 210 |
ultimatesdupscale = NODE_CLASS_MAPPINGS["UltimateSDUpscale"]()
|
| 211 |
upscale_out = ultimatesdupscale.upscale(
|
|
|
|
| 2 |
import random
|
| 3 |
import warnings
|
| 4 |
import os
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
import numpy as np
|
| 7 |
import spaces
|
|
|
|
| 14 |
from huggingface_hub import hf_hub_download
|
| 15 |
import tempfile
|
| 16 |
|
| 17 |
+
os.environ["GIT_TERMINAL_PROMPT"] = "0"
|
| 18 |
+
|
| 19 |
# Setup ComfyUI and custom nodes
|
| 20 |
if not os.path.exists("ComfyUI"):
|
| 21 |
subprocess.run(["git", "clone", "https://github.com/comfyanonymous/ComfyUI"])
|
|
|
|
| 23 |
custom_nodes_dir = os.path.join("ComfyUI", "custom_nodes")
|
| 24 |
os.makedirs(custom_nodes_dir, exist_ok=True)
|
| 25 |
|
| 26 |
+
# Clone UltimateSDUpscale
|
| 27 |
+
usd_dir = os.path.join(custom_nodes_dir, "ComfyUI_UltimateSDUpscale")
|
| 28 |
if not os.path.exists(usd_dir):
|
| 29 |
+
subprocess.run(["git", "clone", "https://github.com/ssitu/ComfyUI_UltimateSDUpscale", usd_dir])
|
| 30 |
|
| 31 |
# Clone comfy_mtb
|
| 32 |
mtb_dir = os.path.join(custom_nodes_dir, "comfy_mtb")
|
|
|
|
| 48 |
comfy_models_dir = os.path.join("ComfyUI", "models")
|
| 49 |
os.makedirs(comfy_models_dir, exist_ok=True)
|
| 50 |
|
| 51 |
+
# Diffusion models (Flux FP8)
|
| 52 |
+
diffusion_dir = os.path.join(comfy_models_dir, "diffusion_models")
|
| 53 |
+
os.makedirs(diffusion_dir, exist_ok=True)
|
| 54 |
+
if not os.path.exists(os.path.join(diffusion_dir, "flux1-dev-fp8.safetensors")):
|
| 55 |
+
hf_hub_download(repo_id="Kijai/flux-fp8", filename="flux1-dev-fp8.safetensors", local_dir=diffusion_dir)
|
| 56 |
|
| 57 |
# CLIP models
|
| 58 |
clip_dir = os.path.join(comfy_models_dir, "clip")
|
|
|
|
| 205 |
vaeloader = NODE_CLASS_MAPPINGS["VAELoader"]()
|
| 206 |
vae = get_value_at_index(vaeloader.load_vae(vae_name="ae.safetensors"), 0)
|
| 207 |
|
| 208 |
+
unetloader = NODE_CLASS_MAPPINGS["LoadDiffusionModel"]()
|
| 209 |
+
model = get_value_at_index(unetloader.load_diffusion_model(unet_name="flux1-dev-fp8.safetensors", weight_dtype="fp8_e4m3fn"), 0)
|
| 210 |
|
| 211 |
ultimatesdupscale = NODE_CLASS_MAPPINGS["UltimateSDUpscale"]()
|
| 212 |
upscale_out = ultimatesdupscale.upscale(
|