multimodalart HF staff commited on
Commit
9167495
1 Parent(s): f9979b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -66,12 +66,12 @@ model = load_model()
66
  # Text-to-video generation function
67
  @spaces.GPU(duration=120)
68
  def generate_video(prompt, image=None, duration=5, guidance_scale=9, video_guidance_scale=5, progress=gr.Progress(track_tqdm=True)):
69
- multiplier = 0.8 if is_canonical else 2.4
70
- temp = int(duration * 0.8) # Convert seconds to temp value (assuming 24 FPS)
71
  torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
72
  if(image):
73
- cropped_image = center_crop(image, 1280, 720)
74
- resized_image = cropped_image.resize((1280, 720))
75
  with torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):
76
  frames = model.generate_i2v(
77
  prompt=prompt,
@@ -113,12 +113,12 @@ with gr.Blocks() as demo:
113
  i2v_image = gr.Image(type="pil", label="Input Image")
114
  t2v_prompt = gr.Textbox(label="Prompt")
115
  with gr.Accordion("Advanced settings", open=False):
116
- t2v_duration = gr.Slider(minimum=1, maximum=10, value=5, step=1, label="Duration (seconds)", visible=not is_canonical)
117
  t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=9, step=0.1, label="Guidance Scale")
118
  t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
119
  t2v_generate_btn = gr.Button("Generate Video")
120
  with gr.Column():
121
- t2v_output = gr.Video(label="Generated Video")
122
  gr.HTML("""
123
  <div style="display: flex; flex-direction: column;justify-content: center; align-items: center; text-align: center;">
124
  <p style="display: flex;gap: 6px;">
 
66
  # Text-to-video generation function
67
  @spaces.GPU(duration=120)
68
  def generate_video(prompt, image=None, duration=5, guidance_scale=9, video_guidance_scale=5, progress=gr.Progress(track_tqdm=True)):
69
+ multiplier = 1.2 if is_canonical else 3.0
70
+ temp = int(duration * multiplier) + 1
71
  torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
72
  if(image):
73
+ cropped_image = center_crop(image, 1280, 768)
74
+ resized_image = cropped_image.resize((1280, 768))
75
  with torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):
76
  frames = model.generate_i2v(
77
  prompt=prompt,
 
113
  i2v_image = gr.Image(type="pil", label="Input Image")
114
  t2v_prompt = gr.Textbox(label="Prompt")
115
  with gr.Accordion("Advanced settings", open=False):
116
+ t2v_duration = gr.Slider(minimum=1, maximum=3 if is_canonical else 10, value=3 if is_canonical else 5, step=1, label="Duration (seconds)", visible=not is_canonical)
117
  t2v_guidance_scale = gr.Slider(minimum=1, maximum=15, value=9, step=0.1, label="Guidance Scale")
118
  t2v_video_guidance_scale = gr.Slider(minimum=1, maximum=15, value=5, step=0.1, label="Video Guidance Scale")
119
  t2v_generate_btn = gr.Button("Generate Video")
120
  with gr.Column():
121
+ t2v_output = gr.Video(label=f"Generated Video at {'8fps' if is_caonical else '24fps'}")
122
  gr.HTML("""
123
  <div style="display: flex; flex-direction: column;justify-content: center; align-items: center; text-align: center;">
124
  <p style="display: flex;gap: 6px;">