alex commited on
Commit
58f3778
·
1 Parent(s): 35f548f

unlogged users

Browse files
app.py CHANGED
@@ -252,6 +252,8 @@ def is_portrait(video_file):
252
 
253
  def calculate_time_required(max_duration_s, rc_bool):
254
 
 
 
255
  if max_duration_s == -1:
256
  return 75
257
  if max_duration_s == 2:
@@ -307,7 +309,12 @@ def _animate(input_video, max_duration_s, edited_frame, rc_bool, pts_by_frame, l
307
  w, h = 360, 640
308
  else:
309
  w, h = 640, 360
310
-
 
 
 
 
 
311
  tag_string = "replace_flag" if rc_bool else "retarget_flag"
312
 
313
  preprocess_model = load_preprocess_models(max_duration_s)
@@ -515,17 +522,32 @@ def animate_scene(input_video, max_duration_s, edited_frame, rc_str,
515
  except Exception as e:
516
  err = str(e).lower()
517
  print(f"{session_id} failed due to {err}")
 
 
 
 
 
 
518
  try:
519
  pts_by_frame, lbs_by_frame = {}, {}
520
 
521
  output_video_path = _animate(
522
- input_video, -1, edited_frame_png, rc_bool,
523
  pts_by_frame, lbs_by_frame, session_id, progress
524
  )
525
  except Exception as e:
526
  err = str(e).lower()
527
  print(f"{session_id} failed due to {err}")
528
- raise
 
 
 
 
 
 
 
 
 
529
 
530
  final_video_path = os.path.join(output_dir, 'final_result.mp4')
531
 
 
252
 
253
  def calculate_time_required(max_duration_s, rc_bool):
254
 
255
+ if max_duration_s == -2:
256
+ return None
257
  if max_duration_s == -1:
258
  return 75
259
  if max_duration_s == 2:
 
309
  w, h = 360, 640
310
  else:
311
  w, h = 640, 360
312
+ elif max_duration_s == -2:
313
+ if is_portrait(input_video):
314
+ w, h = 240, 426
315
+ else:
316
+ w, h = 426, 240
317
+
318
  tag_string = "replace_flag" if rc_bool else "retarget_flag"
319
 
320
  preprocess_model = load_preprocess_models(max_duration_s)
 
522
  except Exception as e:
523
  err = str(e).lower()
524
  print(f"{session_id} failed due to {err}")
525
+
526
+ if "zerogpu quotas" not in err and "pro gpu quota" not in err:
527
+ raise
528
+
529
+ max_duration_s = -1
530
+
531
  try:
532
  pts_by_frame, lbs_by_frame = {}, {}
533
 
534
  output_video_path = _animate(
535
+ input_video, max_duration_s, edited_frame_png, rc_bool,
536
  pts_by_frame, lbs_by_frame, session_id, progress
537
  )
538
  except Exception as e:
539
  err = str(e).lower()
540
  print(f"{session_id} failed due to {err}")
541
+
542
+ if "unlogged" in err:
543
+ max_duration_s = -2
544
+
545
+ output_video_path = _animate(
546
+ input_video, max_duration_s, edited_frame_png, rc_bool,
547
+ pts_by_frame, lbs_by_frame, session_id, progress
548
+ )
549
+ else:
550
+ raise
551
 
552
  final_video_path = os.path.join(output_dir, 'final_result.mp4')
553
 
wan/modules/animate/preprocess/preprocess_data.py CHANGED
@@ -39,7 +39,7 @@ def load_preprocess_models(max_duration_s):
39
  pose2d_checkpoint_path = os.path.join(ckpt_path, 'pose2d/vitpose_h_wholebody.onnx')
40
  det_checkpoint_path = os.path.join(ckpt_path, 'det/yolov10m.onnx')
41
 
42
- if max_duration_s == -1:
43
  print("using small sam2")
44
  sam2_checkpoint_path = [os.path.join(ckpt_path, 'sam2/sam2_hiera_small.pt'),"sam2_hiera_s.yaml"]
45
  else:
 
39
  pose2d_checkpoint_path = os.path.join(ckpt_path, 'pose2d/vitpose_h_wholebody.onnx')
40
  det_checkpoint_path = os.path.join(ckpt_path, 'det/yolov10m.onnx')
41
 
42
+ if max_duration_s < 0:
43
  print("using small sam2")
44
  sam2_checkpoint_path = [os.path.join(ckpt_path, 'sam2/sam2_hiera_small.pt'),"sam2_hiera_s.yaml"]
45
  else: