Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ import torch
|
|
| 7 |
import gradio as gr
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
from comfy import model_management
|
|
|
|
|
|
|
| 10 |
from PIL import Image
|
| 11 |
|
| 12 |
# --- Helper Functions from original script ---
|
|
@@ -31,20 +33,24 @@ def find_path(name: str, path: str = None) -> str:
|
|
| 31 |
|
| 32 |
def add_comfyui_directory_to_sys_path() -> None:
|
| 33 |
comfyui_path = os.getcwd()
|
| 34 |
-
if
|
| 35 |
-
sys.path
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
def add_extra_model_paths() -> None:
|
| 39 |
try:
|
| 40 |
from main import load_extra_path_config
|
| 41 |
-
except ImportError:
|
| 42 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
extra_model_paths = find_path("extra_model_paths.yaml")
|
| 44 |
-
if extra_model_paths
|
| 45 |
load_extra_path_config(extra_model_paths)
|
| 46 |
-
else:
|
| 47 |
-
print("Could not find the extra_model_paths config file.")
|
| 48 |
|
| 49 |
def import_custom_nodes() -> None:
|
| 50 |
import asyncio
|
|
@@ -62,6 +68,7 @@ def import_custom_nodes() -> None:
|
|
| 62 |
add_comfyui_directory_to_sys_path()
|
| 63 |
add_extra_model_paths()
|
| 64 |
import_custom_nodes()
|
|
|
|
| 65 |
from nodes import NODE_CLASS_MAPPINGS
|
| 66 |
|
| 67 |
print("Downlading models from Hugging Face Hub...")
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
from comfy import model_management
|
| 10 |
+
import comfy_extras.nodes_model_advanced
|
| 11 |
+
import comfy_extras.nodes_custom_sampler
|
| 12 |
from PIL import Image
|
| 13 |
|
| 14 |
# --- Helper Functions from original script ---
|
|
|
|
| 33 |
|
| 34 |
def add_comfyui_directory_to_sys_path() -> None:
|
| 35 |
comfyui_path = os.getcwd()
|
| 36 |
+
if "main.py" in os.listdir(comfyui_path):
|
| 37 |
+
if comfyui_path not in sys.path:
|
| 38 |
+
sys.path.append(comfyui_path)
|
| 39 |
+
print(f"'{comfyui_path}' added to sys.path")
|
| 40 |
|
| 41 |
def add_extra_model_paths() -> None:
|
| 42 |
try:
|
| 43 |
from main import load_extra_path_config
|
| 44 |
+
except (ImportError, ModuleNotFoundError):
|
| 45 |
+
print("Could not import from main.py, trying utils...")
|
| 46 |
+
try:
|
| 47 |
+
from utils.extra_config import load_extra_path_config
|
| 48 |
+
except (ImportError, ModuleNotFoundError):
|
| 49 |
+
print("Could not find load_extra_path_config function.")
|
| 50 |
+
return
|
| 51 |
extra_model_paths = find_path("extra_model_paths.yaml")
|
| 52 |
+
if extra_model_paths:
|
| 53 |
load_extra_path_config(extra_model_paths)
|
|
|
|
|
|
|
| 54 |
|
| 55 |
def import_custom_nodes() -> None:
|
| 56 |
import asyncio
|
|
|
|
| 68 |
add_comfyui_directory_to_sys_path()
|
| 69 |
add_extra_model_paths()
|
| 70 |
import_custom_nodes()
|
| 71 |
+
|
| 72 |
from nodes import NODE_CLASS_MAPPINGS
|
| 73 |
|
| 74 |
print("Downlading models from Hugging Face Hub...")
|