Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import gradio as gr
|
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
import spaces
|
| 10 |
from typing import Union, Sequence, Mapping, Any
|
|
|
|
| 11 |
|
| 12 |
# Configura莽茫o inicial e diagn贸stico CUDA
|
| 13 |
print("Python version:", sys.version)
|
|
@@ -22,19 +23,26 @@ 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 |
-
#
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
import
|
| 29 |
-
import
|
| 30 |
-
import
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
# Configura莽茫o de diret贸rios
|
| 40 |
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
@@ -76,10 +84,25 @@ download_models()
|
|
| 76 |
# Inicializar modelos
|
| 77 |
print("Inicializando modelos...")
|
| 78 |
with torch.inference_mode():
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
@spaces.GPU
|
| 85 |
def generate_image(prompt, input_image, lora_weight, guidance, downsampling_factor, weight, seed, width, height, batch_size, steps, progress=gr.Progress(track_tqdm=True)):
|
|
|
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
import spaces
|
| 10 |
from typing import Union, Sequence, Mapping, Any
|
| 11 |
+
import folder_paths
|
| 12 |
|
| 13 |
# Configura莽茫o inicial e diagn贸stico CUDA
|
| 14 |
print("Python version:", sys.version)
|
|
|
|
| 23 |
comfyui_path = os.path.join(current_dir, "ComfyUI")
|
| 24 |
sys.path.append(comfyui_path)
|
| 25 |
|
| 26 |
+
# Inicializar o ComfyUI
|
| 27 |
+
def init_comfyui():
|
| 28 |
+
import execution
|
| 29 |
+
from nodes import NODE_CLASS_MAPPINGS, init_custom_nodes
|
| 30 |
+
import server
|
| 31 |
+
import asyncio
|
| 32 |
+
|
| 33 |
+
# Criar e configurar o loop de eventos
|
| 34 |
+
loop = asyncio.new_event_loop()
|
| 35 |
+
asyncio.set_event_loop(loop)
|
| 36 |
+
|
| 37 |
+
# Inicializar servidor e n贸s
|
| 38 |
+
server_instance = server.PromptServer(loop)
|
| 39 |
+
execution.PromptQueue(server_instance)
|
| 40 |
+
init_custom_nodes()
|
| 41 |
+
|
| 42 |
+
return NODE_CLASS_MAPPINGS
|
| 43 |
|
| 44 |
+
print("Inicializando ComfyUI...")
|
| 45 |
+
NODE_CLASS_MAPPINGS = init_comfyui()
|
| 46 |
|
| 47 |
# Configura莽茫o de diret贸rios
|
| 48 |
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
| 84 |
# Inicializar modelos
|
| 85 |
print("Inicializando modelos...")
|
| 86 |
with torch.inference_mode():
|
| 87 |
+
# CLIP
|
| 88 |
+
dualcliploader = NODE_CLASS_MAPPINGS["DualCLIPLoader"]()
|
| 89 |
+
dualcliploader_357 = dualcliploader.load_clip(
|
| 90 |
+
clip_name1="models/text_encoders/t5xxl_fp16.safetensors",
|
| 91 |
+
clip_name2="models/text_encoders/ViT-L-14-TEXT-detail-improved-hiT-GmP-HF.safetensors",
|
| 92 |
+
type="flux",
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
# Style Model
|
| 96 |
+
stylemodelloader = NODE_CLASS_MAPPINGS["StyleModelLoader"]()
|
| 97 |
+
stylemodelloader_441 = stylemodelloader.load_style_model(
|
| 98 |
+
style_model_name="models/style_models/flux1-redux-dev.safetensors"
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
# VAE
|
| 102 |
+
vaeloader = NODE_CLASS_MAPPINGS["VAELoader"]()
|
| 103 |
+
vaeloader_359 = vaeloader.load_vae(
|
| 104 |
+
vae_name="models/vae/ae.safetensors"
|
| 105 |
+
)
|
| 106 |
|
| 107 |
@spaces.GPU
|
| 108 |
def generate_image(prompt, input_image, lora_weight, guidance, downsampling_factor, weight, seed, width, height, batch_size, steps, progress=gr.Progress(track_tqdm=True)):
|