rahul7star commited on
Commit
5e623f3
·
verified ·
1 Parent(s): 2b78ef9

Update app_4k.py

Browse files
Files changed (1) hide show
  1. app_4k.py +6 -7
app_4k.py CHANGED
@@ -223,7 +223,6 @@ def generate_video(prompt, height, width,
223
  negative_prompt=default_negative_prompt,
224
  duration_seconds=2, guidance_scale=1,
225
  steps=4, seed=42, randomize_seed=False,
226
- use_ultrawan_4k=False,
227
  progress=gr.Progress(track_tqdm=True)):
228
 
229
  if not prompt or prompt.strip() == "":
@@ -238,11 +237,11 @@ def generate_video(prompt, height, width,
238
  duration_seconds = min(duration_seconds, LIMITED_MAX_DURATION)
239
  steps = min(steps, LIMITED_MAX_STEPS)
240
 
241
- # Ensure dimensions are multiples of MOD_VALUE
242
  target_h = max(MOD_VALUE, (int(height) // MOD_VALUE) * MOD_VALUE)
243
  target_w = max(MOD_VALUE, (int(width) // MOD_VALUE) * MOD_VALUE)
244
 
245
- generator_pipe = pipe # your model pipeline
246
 
247
  num_frames = np.clip(int(round(duration_seconds * FIXED_FPS)), MIN_FRAMES_MODEL, MAX_FRAMES_MODEL)
248
 
@@ -258,18 +257,18 @@ def generate_video(prompt, height, width,
258
  generator=torch.Generator(device="cuda").manual_seed(current_seed)
259
  ).frames[0]
260
 
261
- # Export video
262
  with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
263
  video_path = tmpfile.name
264
 
265
  export_to_video(output_frames_list, video_path, fps=FIXED_OUTPUT_FPS)
266
 
267
- # Optional 4K upscale
268
- if use_ultrawan_4k:
269
- upscale_to_4k_and_replace(video_path)
270
 
271
  return video_path, current_seed
272
 
 
273
 
274
 
275
 
 
223
  negative_prompt=default_negative_prompt,
224
  duration_seconds=2, guidance_scale=1,
225
  steps=4, seed=42, randomize_seed=False,
 
226
  progress=gr.Progress(track_tqdm=True)):
227
 
228
  if not prompt or prompt.strip() == "":
 
237
  duration_seconds = min(duration_seconds, LIMITED_MAX_DURATION)
238
  steps = min(steps, LIMITED_MAX_STEPS)
239
 
240
+ # Ensure dimensions are aligned
241
  target_h = max(MOD_VALUE, (int(height) // MOD_VALUE) * MOD_VALUE)
242
  target_w = max(MOD_VALUE, (int(width) // MOD_VALUE) * MOD_VALUE)
243
 
244
+ generator_pipe = pipe
245
 
246
  num_frames = np.clip(int(round(duration_seconds * FIXED_FPS)), MIN_FRAMES_MODEL, MAX_FRAMES_MODEL)
247
 
 
257
  generator=torch.Generator(device="cuda").manual_seed(current_seed)
258
  ).frames[0]
259
 
260
+ # Save video to temporary file
261
  with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
262
  video_path = tmpfile.name
263
 
264
  export_to_video(output_frames_list, video_path, fps=FIXED_OUTPUT_FPS)
265
 
266
+ # Always upscale to 4K
267
+ upscale_to_4k_and_replace(video_path)
 
268
 
269
  return video_path, current_seed
270
 
271
+
272
 
273
 
274