Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -16,35 +16,14 @@ print("CUDA dispon铆vel:", torch.cuda.is_available())
|
|
16 |
print("Quantidade de GPUs:", torch.cuda.device_count())
|
17 |
if torch.cuda.is_available():
|
18 |
print("GPU atual:", torch.cuda.get_device_name(0))
|
19 |
-
else:
|
20 |
-
print("CUDA n茫o est谩 dispon铆vel. Verificando por que:")
|
21 |
-
try:
|
22 |
-
torch.cuda.init()
|
23 |
-
except Exception as e:
|
24 |
-
print("Erro ao inicializar CUDA:", str(e))
|
25 |
|
26 |
# Adicionar o caminho da pasta ComfyUI ao sys.path
|
27 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
28 |
comfyui_path = os.path.join(current_dir, "ComfyUI")
|
29 |
sys.path.append(comfyui_path)
|
30 |
|
31 |
-
#
|
32 |
-
|
33 |
-
import asyncio
|
34 |
-
import execution
|
35 |
-
from nodes import init_extra_nodes
|
36 |
-
import server
|
37 |
-
|
38 |
-
loop = asyncio.new_event_loop()
|
39 |
-
asyncio.set_event_loop(loop)
|
40 |
-
server_instance = server.PromptServer(loop)
|
41 |
-
execution.PromptQueue(server_instance)
|
42 |
-
init_extra_nodes()
|
43 |
-
|
44 |
-
print("Importando n贸s customizados...")
|
45 |
-
import_custom_nodes()
|
46 |
-
|
47 |
-
from nodes import NODE_CLASS_MAPPINGS
|
48 |
from comfy import model_management
|
49 |
import folder_paths
|
50 |
|
@@ -54,6 +33,10 @@ output_dir = os.path.join(BASE_DIR, "output")
|
|
54 |
os.makedirs(output_dir, exist_ok=True)
|
55 |
folder_paths.set_output_directory(output_dir)
|
56 |
|
|
|
|
|
|
|
|
|
57 |
# Helper function
|
58 |
def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
|
59 |
try:
|
@@ -75,6 +58,7 @@ def download_models():
|
|
75 |
]
|
76 |
|
77 |
for repo_id, filename, local_dir in models:
|
|
|
78 |
hf_hub_download(repo_id=repo_id, filename=filename, local_dir=local_dir)
|
79 |
|
80 |
# Download models antes de inicializar
|
|
|
16 |
print("Quantidade de GPUs:", torch.cuda.device_count())
|
17 |
if torch.cuda.is_available():
|
18 |
print("GPU atual:", torch.cuda.get_device_name(0))
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# Adicionar o caminho da pasta ComfyUI ao sys.path
|
21 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
22 |
comfyui_path = os.path.join(current_dir, "ComfyUI")
|
23 |
sys.path.append(comfyui_path)
|
24 |
|
25 |
+
# Importar ComfyUI components
|
26 |
+
from nodes import NODE_CLASS_MAPPINGS, init_extra_nodes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
from comfy import model_management
|
28 |
import folder_paths
|
29 |
|
|
|
33 |
os.makedirs(output_dir, exist_ok=True)
|
34 |
folder_paths.set_output_directory(output_dir)
|
35 |
|
36 |
+
# Inicializar n贸s extras
|
37 |
+
print("Inicializando n贸s extras...")
|
38 |
+
init_extra_nodes()
|
39 |
+
|
40 |
# Helper function
|
41 |
def get_value_at_index(obj: Union[Sequence, Mapping], index: int) -> Any:
|
42 |
try:
|
|
|
58 |
]
|
59 |
|
60 |
for repo_id, filename, local_dir in models:
|
61 |
+
os.makedirs(local_dir, exist_ok=True)
|
62 |
hf_hub_download(repo_id=repo_id, filename=filename, local_dir=local_dir)
|
63 |
|
64 |
# Download models antes de inicializar
|