rahul7star commited on
Commit
d84e30c
·
verified ·
1 Parent(s): 99977d7
Files changed (1) hide show
  1. app_two_lora.py +42 -0
app_two_lora.py CHANGED
@@ -9,6 +9,47 @@ from huggingface_hub import hf_hub_download
9
  import numpy as np
10
  import random
11
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # LIGHT WEIGHT 1.3b
13
  # MODEL_ID = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
14
  # LORA_REPO_ID = "Kijai/WanVideo_comfy"
@@ -288,6 +329,7 @@ def generate_video(prompt, height, width,
288
  with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
289
  video_path = tmpfile.name
290
  export_to_video(output_frames_list, video_path, fps=FIXED_OUTPUT_FPS)
 
291
  return video_path, current_seed
292
 
293
 
 
9
  import numpy as np
10
  import random
11
  import os
12
+
13
+ import os
14
+ import tempfile
15
+ import random
16
+ import numpy as np
17
+ import torch
18
+ import gradio as gr
19
+ import subprocess
20
+ import shutil
21
+ import random
22
+ def upscale_to_4k_and_replace(input_video_path):
23
+ import tempfile, subprocess, shutil
24
+
25
+ # Skip if file too small or missing
26
+ if not os.path.exists(input_video_path) or os.path.getsize(input_video_path) < 1000:
27
+ raise RuntimeError("❌ Input video is missing or empty")
28
+
29
+ with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmp_upscaled:
30
+ upscaled_path = tmp_upscaled.name
31
+
32
+ cmd = [
33
+ "ffmpeg",
34
+ "-loglevel", "error", # Only show errors
35
+ "-i", input_video_path,
36
+ "-vf", "scale=3840:2160:flags=lanczos",
37
+ "-c:v", "libx264",
38
+ "-crf", "18",
39
+ "-preset", "slow",
40
+ "-y",
41
+ upscaled_path,
42
+ ]
43
+
44
+ result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
45
+
46
+ if result.returncode != 0:
47
+ print("❌ FFmpeg error:\n", result.stderr.decode())
48
+ raise RuntimeError("FFmpeg upscale failed")
49
+
50
+ shutil.move(upscaled_path, input_video_path)
51
+
52
+
53
  # LIGHT WEIGHT 1.3b
54
  # MODEL_ID = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
55
  # LORA_REPO_ID = "Kijai/WanVideo_comfy"
 
329
  with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
330
  video_path = tmpfile.name
331
  export_to_video(output_frames_list, video_path, fps=FIXED_OUTPUT_FPS)
332
+ upscale_to_4k_and_replace(video_path)
333
  return video_path, current_seed
334
 
335