multimodalart HF staff commited on
Commit
dae6484
1 Parent(s): d064a68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import os
2
  import torch
3
  import gradio as gr
4
- from PIL import Image
 
5
  from huggingface_hub import snapshot_download
6
  from pyramid_dit import PyramidDiTForVideoGeneration
7
  from diffusers.utils import export_to_video
@@ -61,7 +62,8 @@ def generate_video_from_image(image, prompt, duration, video_guidance_scale):
61
  temp = int(duration * 2.4) # Convert seconds to temp value (assuming 24 FPS)
62
  torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
63
 
64
- image = image.resize((1280, 768))
 
65
 
66
  with torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):
67
  frames = model.generate_i2v(
 
1
  import os
2
  import torch
3
  import gradio as gr
4
+ from PIL import Image, ImageOps
5
+
6
  from huggingface_hub import snapshot_download
7
  from pyramid_dit import PyramidDiTForVideoGeneration
8
  from diffusers.utils import export_to_video
 
62
  temp = int(duration * 2.4) # Convert seconds to temp value (assuming 24 FPS)
63
  torch_dtype = torch.bfloat16 if MODEL_DTYPE == "bf16" else torch.float32
64
 
65
+ target_size = (1280, 720)
66
+ image = ImageOps.fit(image, target_size, method=Image.LANCZOS, centering=(0.5, 0.5))
67
 
68
  with torch.no_grad(), torch.cuda.amp.autocast(enabled=True, dtype=torch_dtype):
69
  frames = model.generate_i2v(