Tophness2022 commited on
Commit
5adda77
·
1 Parent(s): d7b86b3

fix broken queue states (again)

Browse files
Files changed (1) hide show
  1. gradio_server.py +15 -17
gradio_server.py CHANGED
@@ -215,8 +215,8 @@ def update_queue_data():
215
  for item in queue:
216
  data.append([
217
  str(item['id']),
218
- item['status'],
219
- item['repeats'],
220
  item.get('progress', "0.0%"),
221
  item.get('steps', ''),
222
  item.get('time', '--'),
@@ -998,7 +998,7 @@ def save_video(final_frames, output_path, fps=24):
998
  final_frames = (final_frames * 255).astype(np.uint8)
999
  ImageSequenceClip(list(final_frames), fps=fps).write_videofile(output_path, verbose= False, logger = None)
1000
 
1001
- def build_callback(state, pipe, num_inference_steps, status):
1002
  start_time = time.time()
1003
  def update_progress(step_idx, latents, read_state = False):
1004
  with tracker_lock:
@@ -1011,12 +1011,12 @@ def build_callback(state, pipe, num_inference_steps, status):
1011
  else:
1012
  phase = "Denoising"
1013
  elapsed = time.time() - start_time
1014
- progress_tracker[task_id] = {
1015
  'current_step': step_idx,
1016
  'total_steps': num_inference_steps,
1017
  'start_time': start_time,
1018
  'last_update': time.time(),
1019
- 'repeats': status,
1020
  'status': phase
1021
  }
1022
  return update_progress
@@ -1262,16 +1262,8 @@ def generate_video(
1262
  trans.previous_residual_uncond = None
1263
  trans.previous_residual_cond = None
1264
  video_no = 0
1265
- status = f"{video_no}/{repeat_generation}"
1266
- with tracker_lock:
1267
- if task_id in progress_tracker:
1268
- progress_tracker[task_id]['status'] = "Encoding Prompt"
1269
- progress_tracker[task_id]['repeats'] = status
1270
- progress_tracker[task_id]['current_step'] = 0
1271
- progress_tracker[task_id]['total_steps'] = num_inference_steps
1272
- progress_tracker[task_id]['start_time'] = time.time()
1273
- progress_tracker[task_id]['last_update'] = time.time()
1274
- callback = build_callback(state, trans, num_inference_steps, status)
1275
  offload.shared_state["callback"] = callback
1276
  gc.collect()
1277
  torch.cuda.empty_cache()
@@ -1279,8 +1271,14 @@ def generate_video(
1279
  for i in range(repeat_generation):
1280
  try:
1281
  with tracker_lock:
1282
- if task_id in progress_tracker:
1283
- progress_tracker[task_id]['repeats'] = video_no
 
 
 
 
 
 
1284
  video_no += 1
1285
  if image2video:
1286
  samples = wan_model.generate(
 
215
  for item in queue:
216
  data.append([
217
  str(item['id']),
218
+ item.get('status', "Starting"),
219
+ item.get('repeats', "0/0"),
220
  item.get('progress', "0.0%"),
221
  item.get('steps', ''),
222
  item.get('time', '--'),
 
998
  final_frames = (final_frames * 255).astype(np.uint8)
999
  ImageSequenceClip(list(final_frames), fps=fps).write_videofile(output_path, verbose= False, logger = None)
1000
 
1001
+ def build_callback(taskid, state, pipe, num_inference_steps, repeats):
1002
  start_time = time.time()
1003
  def update_progress(step_idx, latents, read_state = False):
1004
  with tracker_lock:
 
1011
  else:
1012
  phase = "Denoising"
1013
  elapsed = time.time() - start_time
1014
+ progress_tracker[taskid] = {
1015
  'current_step': step_idx,
1016
  'total_steps': num_inference_steps,
1017
  'start_time': start_time,
1018
  'last_update': time.time(),
1019
+ 'repeats': repeats,
1020
  'status': phase
1021
  }
1022
  return update_progress
 
1262
  trans.previous_residual_uncond = None
1263
  trans.previous_residual_cond = None
1264
  video_no = 0
1265
+ repeats = f"{video_no}/{repeat_generation}"
1266
+ callback = build_callback(task_id, state, trans, num_inference_steps, repeats)
 
 
 
 
 
 
 
 
1267
  offload.shared_state["callback"] = callback
1268
  gc.collect()
1269
  torch.cuda.empty_cache()
 
1271
  for i in range(repeat_generation):
1272
  try:
1273
  with tracker_lock:
1274
+ progress_tracker[task_id] = {
1275
+ 'current_step': 0,
1276
+ 'total_steps': num_inference_steps,
1277
+ 'start_time': time.time(),
1278
+ 'last_update': time.time(),
1279
+ 'repeats': f"0/{repeat_generation}",
1280
+ 'status': "Encoding Prompt"
1281
+ }
1282
  video_no += 1
1283
  if image2video:
1284
  samples = wan_model.generate(