xi0v Fabrice-TIERCELIN commited on
Commit
50b6cac
β€’
1 Parent(s): 6bac019

Remove the formats that do not work and parameterize the size (#37)

Browse files

- Remove the formats that do not work and parameterize the size (545b3c678df9e627b43dbc4477f5a8f9bf47c2de)


Co-authored-by: Fabrice TIERCELIN <[email protected]>

Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -41,9 +41,11 @@ def animate(
41
  video_format: str = "mp4",
42
  frame_format: str = "webp",
43
  version: str = "auto",
44
- output_folder: str = "outputs",
 
45
  ):
46
  start = time.time()
 
47
  if image.mode == "RGBA":
48
  image = image.convert("RGB")
49
 
@@ -63,7 +65,9 @@ def animate(
63
  fps_id,
64
  noise_aug_strength,
65
  decoding_t,
66
- version
 
 
67
  )
68
 
69
  os.makedirs(output_folder, exist_ok=True)
@@ -118,16 +122,18 @@ def animate_on_gpu(
118
  fps_id: int = 6,
119
  noise_aug_strength: float = 0.1,
120
  decoding_t: int = 3,
121
- version: str = "svdxt"
 
 
122
  ):
123
  generator = torch.manual_seed(seed)
124
 
125
  if version == "dragnuwa":
126
- return dragnuwaPipe(image, width=1024, height=576, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=noise_aug_strength, num_frames=25).frames[0]
127
  elif version == "svdxt":
128
- return fps25Pipe(image, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=noise_aug_strength, num_frames=25).frames[0]
129
  else:
130
- return fps14Pipe(image, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=noise_aug_strength, num_frames=25).frames[0]
131
 
132
 
133
  def resize_image(image, output_size=(1024, 576)):
@@ -199,7 +205,7 @@ with gr.Blocks() as demo:
199
  motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
200
  noise_aug_strength = gr.Slider(label="Noise strength", info="The noise to add", value=0.1, minimum=0, maximum=1, step=0.1)
201
  decoding_t = gr.Slider(label="Decoding", info="Number of frames decoded at a time; this eats more VRAM; reduce if necessary", value=3, minimum=1, maximum=5, step=1)
202
- video_format = gr.Radio([["*.mp4", "mp4"], ["*.avi", "avi"], ["*.webm", "webm"], ["*.ogv", "ogv"], ["*.mkv", "mkv"], ["*.mov", "mov"], ["*.flv", "flv"], ["*.wmv", "wmv"], ["*.gif", "gif"]], label="Video format for result", info="File extention", value="mp4", interactive=True)
203
  frame_format = gr.Radio([["*.webp", "webp"], ["*.png", "png"], ["*.jpeg", "jpeg"], ["*.gif (unanimated)", "gif"], ["*.bmp", "bmp"]], label="Image format for frames", info="File extention", value="webp", interactive=True)
204
  version = gr.Radio([["Auto", "auto"], ["πŸƒπŸ»β€β™€οΈ SVD (trained on 14 f/s)", "svd"], ["πŸƒπŸ»β€β™€οΈπŸ’¨ SVD-XT (trained on 25 f/s)", "svdxt"], ["DragNUWA (unstable)", "dragnuwa"]], label="Model", info="Trained model", value="auto", interactive=True)
205
  seed = gr.Slider(label="Seed", value=42, randomize=True, minimum=0, maximum=max_64_bit_int, step=1)
 
41
  video_format: str = "mp4",
42
  frame_format: str = "webp",
43
  version: str = "auto",
44
+ width: int = 1024,
45
+ height: int = 576
46
  ):
47
  start = time.time()
48
+ output_folder = "outputs"
49
  if image.mode == "RGBA":
50
  image = image.convert("RGB")
51
 
 
65
  fps_id,
66
  noise_aug_strength,
67
  decoding_t,
68
+ version,
69
+ width,
70
+ height
71
  )
72
 
73
  os.makedirs(output_folder, exist_ok=True)
 
122
  fps_id: int = 6,
123
  noise_aug_strength: float = 0.1,
124
  decoding_t: int = 3,
125
+ version: str = "svdxt",
126
+ width: int = 1024,
127
+ height: int = 576
128
  ):
129
  generator = torch.manual_seed(seed)
130
 
131
  if version == "dragnuwa":
132
+ return dragnuwaPipe(image, width=width, height=height, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=noise_aug_strength, num_frames=25).frames[0]
133
  elif version == "svdxt":
134
+ return fps25Pipe(image, width=width, height=height, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=noise_aug_strength, num_frames=25).frames[0]
135
  else:
136
+ return fps14Pipe(image, width=width, height=height, decode_chunk_size=decoding_t, generator=generator, motion_bucket_id=motion_bucket_id, noise_aug_strength=noise_aug_strength, num_frames=25).frames[0]
137
 
138
 
139
  def resize_image(image, output_size=(1024, 576)):
 
205
  motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
206
  noise_aug_strength = gr.Slider(label="Noise strength", info="The noise to add", value=0.1, minimum=0, maximum=1, step=0.1)
207
  decoding_t = gr.Slider(label="Decoding", info="Number of frames decoded at a time; this eats more VRAM; reduce if necessary", value=3, minimum=1, maximum=5, step=1)
208
+ video_format = gr.Radio([["*.mp4", "mp4"], ["*.avi", "avi"], ["*.wmv", "wmv"], ["*.mkv", "mkv"], ["*.mov", "mov"], ["*.gif", "gif"]], label="Video format for result", info="File extention", value="mp4", interactive=True)
209
  frame_format = gr.Radio([["*.webp", "webp"], ["*.png", "png"], ["*.jpeg", "jpeg"], ["*.gif (unanimated)", "gif"], ["*.bmp", "bmp"]], label="Image format for frames", info="File extention", value="webp", interactive=True)
210
  version = gr.Radio([["Auto", "auto"], ["πŸƒπŸ»β€β™€οΈ SVD (trained on 14 f/s)", "svd"], ["πŸƒπŸ»β€β™€οΈπŸ’¨ SVD-XT (trained on 25 f/s)", "svdxt"], ["DragNUWA (unstable)", "dragnuwa"]], label="Model", info="Trained model", value="auto", interactive=True)
211
  seed = gr.Slider(label="Seed", value=42, randomize=True, minimum=0, maximum=max_64_bit_int, step=1)