Lupara90 commited on
Commit
c62ade5
·
verified ·
1 Parent(s): e8c2738

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -19,9 +19,11 @@ if not os.path.exists(COMFYUI_DIR):
19
  check=True
20
  )
21
 
22
- # Append the cloned ComfyUI folder to python path so its modules (like main.py) can be found
 
 
23
  if COMFYUI_DIR not in sys.path:
24
- sys.path.append(COMFYUI_DIR)
25
 
26
  # Now it is safe to import main
27
  import main as comfy_main
@@ -33,9 +35,8 @@ import main as comfy_main
33
  @spaces.GPU(duration=60) # Borrow free ZeroGPU for 60 seconds per run
34
  def generate_image(user_prompt):
35
  # Load your exported ComfyUI API JSON
36
- # (Make sure workflow_api.json is uploaded to your Space's main directory)
37
  if not os.path.exists("workflow_api.json"):
38
- return None # Or handle error appropriately
39
 
40
  with open("workflow_api.json", "r") as f:
41
  prompt_workflow = json.load(f)
 
19
  check=True
20
  )
21
 
22
+ # Fix path resolution priority:
23
+ # Insert COMFYUI_DIR at index 0 of sys.path so ComfyUI imports (like 'import app')
24
+ # look inside ComfyUI's folder FIRST, ignoring your space's root 'app' folder name.
25
  if COMFYUI_DIR not in sys.path:
26
+ sys.path.insert(0, COMFYUI_DIR)
27
 
28
  # Now it is safe to import main
29
  import main as comfy_main
 
35
  @spaces.GPU(duration=60) # Borrow free ZeroGPU for 60 seconds per run
36
  def generate_image(user_prompt):
37
  # Load your exported ComfyUI API JSON
 
38
  if not os.path.exists("workflow_api.json"):
39
+ return None
40
 
41
  with open("workflow_api.json", "r") as f:
42
  prompt_workflow = json.load(f)