JS6969 commited on
Commit
24e0155
·
verified ·
1 Parent(s): f4dea5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -32
app.py CHANGED
@@ -4,23 +4,15 @@
4
  # - Step 1: Extract frames (with live estimate & progress)
5
  # - Step 2: Upscale frames (now supports uploading your own images directly)
6
  # - Step 3: Re-encode frames (now supports uploading your own frames/ZIP and optional audio source)
7
- # - Quick Mode: One-click (All Frames → Upscale x4 → MP4 H.264 with audio)
8
  # - Previews: 30 frames sampled evenly; scrollable galleries
9
  # - Prefix defaults to input video filename if left blank
10
  # =============================
11
 
12
 
13
- import sys, types
14
- def _rgb_to_grayscale_np(arr: np.ndarray) -> np.ndarray:
15
- # arr: HxWx3 uint8
16
- r, g, b = arr[...,0], arr[...,1], arr[...,2]
17
- gray = (0.2989*r + 0.5870*g + 0.1140*b).astype(arr.dtype)
18
- return np.stack([gray, gray, gray], axis=-1)
19
-
20
-
21
  # ────────────────────────────────────────────────────────
22
  # Standard imports
23
  # ────────────────────────────────────────────────────────
 
24
  import os
25
  import re
26
  import cv2
@@ -47,6 +39,12 @@ from realesrgan.archs.srvgg_arch import SRVGGNetCompact
47
 
48
  _num = re.compile(r'(\d+)')
49
 
 
 
 
 
 
 
50
  def _natural_key(p: Path | str):
51
  s = str(p)
52
  return [int(t) if t.isdigit() else t.lower() for t in _num.split(s)]
@@ -1149,29 +1147,29 @@ def build_ui():
1149
  )
1150
 
1151
  # QUICK MODE
1152
- with gr.Tab("⚡ Quick Mode"):
1153
- gr.Markdown("Extract ALL frames → Upscale ×4 → MP4 (H.264) with original audio. No toggles.")
1154
- with gr.Row():
1155
- q_video = gr.File(label="Upload video", file_types=[".mp4", ".mov", ".mkv", ".avi", ".webm", ".m4v"], type="filepath")
1156
- with gr.Row():
1157
- q_start = gr.Textbox(value="", label="Start (HH:MM:SS.mmm, optional)")
1158
- q_end = gr.Textbox(value="", label="End (HH:MM:SS.mmm, optional)")
1159
- q_resize = gr.Number(value=0, label="Resize long side before upscale (0 = none)")
1160
- q_prefix = gr.Textbox(value="", label="Filename prefix (defaults to input file name)")
1161
-
1162
- q_btn = gr.Button("Run Quick Pipeline", variant="primary")
1163
- q_prog = gr.HTML(render_progress(0.0, "Idle"))
1164
- q_video_out = gr.Video(label="Output video")
1165
- with gr.Accordion("Show intermediates", open=False):
1166
- q_zip_frames = gr.File(label="frames.zip")
1167
- q_zip_up = gr.File(label="upscaled.zip")
1168
- q_details = gr.Markdown("")
1169
-
1170
- q_btn.click(
1171
- quick_mode,
1172
- inputs=[q_video, q_start, q_end, q_resize, q_prefix, q_prog],
1173
- outputs=[q_video_out, q_zip_frames, q_zip_up, q_details, q_prog],
1174
- )
1175
 
1176
  return demo
1177
 
 
4
  # - Step 1: Extract frames (with live estimate & progress)
5
  # - Step 2: Upscale frames (now supports uploading your own images directly)
6
  # - Step 3: Re-encode frames (now supports uploading your own frames/ZIP and optional audio source)
 
7
  # - Previews: 30 frames sampled evenly; scrollable galleries
8
  # - Prefix defaults to input video filename if left blank
9
  # =============================
10
 
11
 
 
 
 
 
 
 
 
 
12
  # ────────────────────────────────────────────────────────
13
  # Standard imports
14
  # ────────────────────────────────────────────────────────
15
+ import sys, types
16
  import os
17
  import re
18
  import cv2
 
39
 
40
  _num = re.compile(r'(\d+)')
41
 
42
+ def _rgb_to_grayscale_np(arr: np.ndarray) -> np.ndarray:
43
+ # arr: HxWx3 uint8
44
+ r, g, b = arr[...,0], arr[...,1], arr[...,2]
45
+ gray = (0.2989*r + 0.5870*g + 0.1140*b).astype(arr.dtype)
46
+ return np.stack([gray, gray, gray], axis=-1)
47
+
48
  def _natural_key(p: Path | str):
49
  s = str(p)
50
  return [int(t) if t.isdigit() else t.lower() for t in _num.split(s)]
 
1147
  )
1148
 
1149
  # QUICK MODE
1150
+ # with gr.Tab("⚡ Quick Mode"):
1151
+ # gr.Markdown("Extract ALL frames → Upscale ×4 → MP4 (H.264) with original audio. No toggles.")
1152
+ # with gr.Row():
1153
+ # q_video = gr.File(label="Upload video", file_types=[".mp4", ".mov", ".mkv", ".avi", ".webm", ".m4v"], type="filepath")
1154
+ # with gr.Row():
1155
+ # q_start = gr.Textbox(value="", label="Start (HH:MM:SS.mmm, optional)")
1156
+ # q_end = gr.Textbox(value="", label="End (HH:MM:SS.mmm, optional)")
1157
+ # q_resize = gr.Number(value=0, label="Resize long side before upscale (0 = none)")
1158
+ # q_prefix = gr.Textbox(value="", label="Filename prefix (defaults to input file name)")
1159
+
1160
+ # q_btn = gr.Button("Run Quick Pipeline", variant="primary")
1161
+ # q_prog = gr.HTML(render_progress(0.0, "Idle"))
1162
+ # q_video_out = gr.Video(label="Output video")
1163
+ # with gr.Accordion("Show intermediates", open=False):
1164
+ # q_zip_frames = gr.File(label="frames.zip")
1165
+ # q_zip_up = gr.File(label="upscaled.zip")
1166
+ # q_details = gr.Markdown("")
1167
+
1168
+ # q_btn.click(
1169
+ # quick_mode,
1170
+ # inputs=[q_video, q_start, q_end, q_resize, q_prefix, q_prog],
1171
+ # outputs=[q_video_out, q_zip_frames, q_zip_up, q_details, q_prog],
1172
+ # )
1173
 
1174
  return demo
1175