alexnasa commited on
Commit
8f03b92
·
verified ·
1 Parent(s): 4ae5f54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -18
app.py CHANGED
@@ -12,18 +12,35 @@ import psutil
12
 
13
  PROC = psutil.Process(os.getpid())
14
 
15
- def debug_children_detail(limit=10):
 
 
 
 
16
  children = PROC.children(recursive=True)
17
- print(f"[DEBUG] Total children: {len(children)}")
18
- for child in children[:limit]:
 
 
 
19
  try:
20
- print(
21
- f" PID={child.pid} status={child.status()} "
22
- f"name={child.name()} cmdline={child.cmdline()[:5]}"
23
- )
24
  except psutil.Error:
25
- pass
26
-
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  from huggingface_hub import snapshot_download, list_repo_files, hf_hub_download
29
  import importlib, site
@@ -167,17 +184,9 @@ def update_required_time(steps, max_duration):
167
 
168
  return get_required_time_string(steps, max_duration)
169
 
170
- num_scene_generation = 0
171
 
172
  def generate_scene(prompt_text, steps, image_paths, audio_file_path, max_duration = 3, session_id = None, progress=gr.Progress(),):
173
 
174
- global num_scene_generation
175
- if num_scene_generation % 30 == 0:
176
- debug_children_detail()
177
- num_scene_generation = num_scene_generation + 1
178
-
179
-
180
-
181
  prompt_text_check = (prompt_text or "").strip()
182
  if not prompt_text_check:
183
  raise gr.Error("Please enter a prompt.")
@@ -316,7 +325,8 @@ def run_pipeline(prompt_text, steps, image_paths, audio_file_path, max_duration
316
  tea_cache_l1_thresh = 0.0,
317
  progress_bar_cmd=progress
318
  )
319
-
 
320
  # Return resulting video path
321
  video_path = os.path.join(output_dir, f"{filename}.mp4")
322
  if os.path.exists(video_path):
 
12
 
13
  PROC = psutil.Process(os.getpid())
14
 
15
+ def debug_resources(tag=""):
16
+ # Threads in this process
17
+ thread_count = PROC.num_threads()
18
+
19
+ # Children processes spawned by this process (recursive = include grandchildren)
20
  children = PROC.children(recursive=True)
21
+ child_count = len(children)
22
+
23
+ # Group children by name to see what’s being spawned (ffmpeg, python, etc.)
24
+ name_counts = {}
25
+ for c in children:
26
  try:
27
+ name = c.name()
 
 
 
28
  except psutil.Error:
29
+ name = "unknown"
30
+ name_counts[name] = name_counts.get(name, 0) + 1
31
+
32
+ # File descriptors (Linux/macOS; on Windows use len(PROC.open_files()) instead)
33
+ try:
34
+ fd_count = PROC.num_fds()
35
+ except AttributeError:
36
+ fd_count = len(PROC.open_files())
37
+
38
+ print("========== RESOURCE DEBUG", tag, "==========")
39
+ print("[DEBUG]", "Threads in this process:", thread_count)
40
+ print("[DEBUG]", "Child processes (recursive):", child_count)
41
+ print("[DEBUG]", "Child processes by name:", name_counts)
42
+ print("[DEBUG]", "Open file descriptors:", fd_count)
43
+ print("============================================")
44
 
45
  from huggingface_hub import snapshot_download, list_repo_files, hf_hub_download
46
  import importlib, site
 
184
 
185
  return get_required_time_string(steps, max_duration)
186
 
 
187
 
188
  def generate_scene(prompt_text, steps, image_paths, audio_file_path, max_duration = 3, session_id = None, progress=gr.Progress(),):
189
 
 
 
 
 
 
 
 
190
  prompt_text_check = (prompt_text or "").strip()
191
  if not prompt_text_check:
192
  raise gr.Error("Please enter a prompt.")
 
325
  tea_cache_l1_thresh = 0.0,
326
  progress_bar_cmd=progress
327
  )
328
+ debug_resources("after generation")
329
+
330
  # Return resulting video path
331
  video_path = os.path.join(output_dir, f"{filename}.mp4")
332
  if os.path.exists(video_path):