Spaces:
Running
on
Zero
Running
on
Zero
Solitude-liu
commited on
Commit
·
11cda7a
1
Parent(s):
0b80321
Add parameter tuning
Browse files- __pycache__/inference_utils.cpython-39.pyc +0 -0
- app.py +20 -14
- examples/016_video.mp4 +0 -0
- video_super_resolution/__pycache__/color_fix.cpython-39.pyc +0 -0
- video_super_resolution/scripts/__pycache__/inference_sr.cpython-39.pyc +0 -0
- video_super_resolution/scripts/inference_sr.py +2 -0
- video_to_video/__pycache__/__init__.cpython-39.pyc +0 -0
- video_to_video/__pycache__/video_to_video_model.cpython-39.pyc +0 -0
- video_to_video/diffusion/__pycache__/__init__.cpython-39.pyc +0 -0
- video_to_video/diffusion/__pycache__/diffusion_sdedit.cpython-39.pyc +0 -0
- video_to_video/diffusion/__pycache__/schedules_sdedit.cpython-39.pyc +0 -0
- video_to_video/diffusion/__pycache__/solvers_sdedit.cpython-39.pyc +0 -0
- video_to_video/modules/__pycache__/__init__.cpython-39.pyc +0 -0
- video_to_video/modules/__pycache__/embedder.cpython-39.pyc +0 -0
- video_to_video/modules/__pycache__/unet_v2v.cpython-39.pyc +0 -0
- video_to_video/utils/__pycache__/__init__.cpython-39.pyc +0 -0
- video_to_video/utils/__pycache__/config.cpython-39.pyc +0 -0
- video_to_video/utils/__pycache__/logger.cpython-39.pyc +0 -0
- video_to_video/utils/__pycache__/seed.cpython-39.pyc +0 -0
- video_to_video/video_to_video_model.py +3 -1
__pycache__/inference_utils.cpython-39.pyc
CHANGED
Binary files a/__pycache__/inference_utils.cpython-39.pyc and b/__pycache__/inference_utils.cpython-39.pyc differ
|
|
app.py
CHANGED
@@ -11,14 +11,19 @@ examples = [
|
|
11 |
|
12 |
# Define a GPU-decorated function for enhancement
|
13 |
@spaces.GPU(duration=120)
|
14 |
-
def enhance_with_gpu(input_video, input_text):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
return star.enhance_a_video(input_video, input_text)
|
16 |
|
17 |
def star_demo(result_dir="./tmp/"):
|
18 |
css = """#input_video {max-width: 1024px !important} #output_vid {max-width: 2048px; max-height:1280px}"""
|
19 |
-
|
20 |
-
star = STAR_sr(result_dir)
|
21 |
-
|
22 |
with gr.Blocks(analytics_enabled=False, css=css) as star_iface:
|
23 |
gr.Markdown(
|
24 |
"<div align='center'> <h1> STAR: Spatial-Temporal Augmentation with Text-to-Video Models for Real-World Video Super-Resolution </span> </h1> \
|
@@ -30,15 +35,16 @@ def star_demo(result_dir="./tmp/"):
|
|
30 |
with gr.Column():
|
31 |
with gr.Row():
|
32 |
with gr.Column():
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
37 |
end_btn = gr.Button("Generate")
|
38 |
-
|
39 |
-
|
40 |
-
label="Generated Video", elem_id="output_vid", autoplay=True, show_share_button=True
|
41 |
-
)
|
42 |
|
43 |
gr.Examples(
|
44 |
examples=examples,
|
@@ -47,15 +53,15 @@ def star_demo(result_dir="./tmp/"):
|
|
47 |
fn=enhance_with_gpu, # Use the GPU-decorated function
|
48 |
cache_examples=False,
|
49 |
)
|
|
|
50 |
end_btn.click(
|
51 |
-
inputs=[input_video, input_text],
|
52 |
outputs=[output_video],
|
53 |
fn=enhance_with_gpu, # Use the GPU-decorated function
|
54 |
)
|
55 |
|
56 |
return star_iface
|
57 |
|
58 |
-
|
59 |
if __name__ == "__main__":
|
60 |
result_dir = os.path.join("./", "results")
|
61 |
star_iface = star_demo(result_dir)
|
|
|
11 |
|
12 |
# Define a GPU-decorated function for enhancement
|
13 |
@spaces.GPU(duration=120)
|
14 |
+
def enhance_with_gpu(input_video, input_text, upscale, max_chunk_len, chunk_size):
|
15 |
+
"""在每次调用时创建新的 STAR_sr 实例,确保参数正确传递"""
|
16 |
+
star = STAR_sr(
|
17 |
+
result_dir="./results/",
|
18 |
+
upscale=upscale,
|
19 |
+
max_chunk_len=max_chunk_len,
|
20 |
+
chunk_size=chunk_size
|
21 |
+
)
|
22 |
return star.enhance_a_video(input_video, input_text)
|
23 |
|
24 |
def star_demo(result_dir="./tmp/"):
|
25 |
css = """#input_video {max-width: 1024px !important} #output_vid {max-width: 2048px; max-height:1280px}"""
|
26 |
+
|
|
|
|
|
27 |
with gr.Blocks(analytics_enabled=False, css=css) as star_iface:
|
28 |
gr.Markdown(
|
29 |
"<div align='center'> <h1> STAR: Spatial-Temporal Augmentation with Text-to-Video Models for Real-World Video Super-Resolution </span> </h1> \
|
|
|
35 |
with gr.Column():
|
36 |
with gr.Row():
|
37 |
with gr.Column():
|
38 |
+
input_video = gr.Video(label="Input Video", elem_id="input_video")
|
39 |
+
input_text = gr.Text(label="Prompts")
|
40 |
+
|
41 |
+
upscale = gr.Slider(1, 4, value=4, step=1, label="Upscale Factor")
|
42 |
+
max_chunk_len = gr.Slider(1, 32, value=24, step=1, label="Input Chunk Length")
|
43 |
+
chunk_size = gr.Slider(1, 5, value=3, step=1, label="Decode Chunk Size")
|
44 |
+
|
45 |
end_btn = gr.Button("Generate")
|
46 |
+
|
47 |
+
output_video = gr.Video(label="Generated Video", elem_id="output_vid", autoplay=True, show_share_button=True)
|
|
|
|
|
48 |
|
49 |
gr.Examples(
|
50 |
examples=examples,
|
|
|
53 |
fn=enhance_with_gpu, # Use the GPU-decorated function
|
54 |
cache_examples=False,
|
55 |
)
|
56 |
+
|
57 |
end_btn.click(
|
58 |
+
inputs=[input_video, input_text, upscale, max_chunk_len, chunk_size],
|
59 |
outputs=[output_video],
|
60 |
fn=enhance_with_gpu, # Use the GPU-decorated function
|
61 |
)
|
62 |
|
63 |
return star_iface
|
64 |
|
|
|
65 |
if __name__ == "__main__":
|
66 |
result_dir = os.path.join("./", "results")
|
67 |
star_iface = star_demo(result_dir)
|
examples/016_video.mp4
CHANGED
Binary files a/examples/016_video.mp4 and b/examples/016_video.mp4 differ
|
|
video_super_resolution/__pycache__/color_fix.cpython-39.pyc
CHANGED
Binary files a/video_super_resolution/__pycache__/color_fix.cpython-39.pyc and b/video_super_resolution/__pycache__/color_fix.cpython-39.pyc differ
|
|
video_super_resolution/scripts/__pycache__/inference_sr.cpython-39.pyc
ADDED
Binary file (3.97 kB). View file
|
|
video_super_resolution/scripts/inference_sr.py
CHANGED
@@ -26,6 +26,7 @@ class STAR_sr():
|
|
26 |
upscale=4,
|
27 |
max_chunk_len=32,
|
28 |
variant_info=None,
|
|
|
29 |
):
|
30 |
self.model_path=model_path
|
31 |
logger.info('checkpoint_path: {}'.format(self.model_path))
|
@@ -36,6 +37,7 @@ class STAR_sr():
|
|
36 |
|
37 |
model_cfg = EasyDict(__name__='model_cfg')
|
38 |
model_cfg.model_path = self.model_path
|
|
|
39 |
self.model = VideoToVideo_sr(model_cfg)
|
40 |
|
41 |
steps = 15 if solver_mode == 'fast' else steps
|
|
|
26 |
upscale=4,
|
27 |
max_chunk_len=32,
|
28 |
variant_info=None,
|
29 |
+
chunk_size=3,
|
30 |
):
|
31 |
self.model_path=model_path
|
32 |
logger.info('checkpoint_path: {}'.format(self.model_path))
|
|
|
37 |
|
38 |
model_cfg = EasyDict(__name__='model_cfg')
|
39 |
model_cfg.model_path = self.model_path
|
40 |
+
model_cfg.chunk_size = chunk_size
|
41 |
self.model = VideoToVideo_sr(model_cfg)
|
42 |
|
43 |
steps = 15 if solver_mode == 'fast' else steps
|
video_to_video/__pycache__/__init__.cpython-39.pyc
CHANGED
Binary files a/video_to_video/__pycache__/__init__.cpython-39.pyc and b/video_to_video/__pycache__/__init__.cpython-39.pyc differ
|
|
video_to_video/__pycache__/video_to_video_model.cpython-39.pyc
CHANGED
Binary files a/video_to_video/__pycache__/video_to_video_model.cpython-39.pyc and b/video_to_video/__pycache__/video_to_video_model.cpython-39.pyc differ
|
|
video_to_video/diffusion/__pycache__/__init__.cpython-39.pyc
CHANGED
Binary files a/video_to_video/diffusion/__pycache__/__init__.cpython-39.pyc and b/video_to_video/diffusion/__pycache__/__init__.cpython-39.pyc differ
|
|
video_to_video/diffusion/__pycache__/diffusion_sdedit.cpython-39.pyc
CHANGED
Binary files a/video_to_video/diffusion/__pycache__/diffusion_sdedit.cpython-39.pyc and b/video_to_video/diffusion/__pycache__/diffusion_sdedit.cpython-39.pyc differ
|
|
video_to_video/diffusion/__pycache__/schedules_sdedit.cpython-39.pyc
CHANGED
Binary files a/video_to_video/diffusion/__pycache__/schedules_sdedit.cpython-39.pyc and b/video_to_video/diffusion/__pycache__/schedules_sdedit.cpython-39.pyc differ
|
|
video_to_video/diffusion/__pycache__/solvers_sdedit.cpython-39.pyc
CHANGED
Binary files a/video_to_video/diffusion/__pycache__/solvers_sdedit.cpython-39.pyc and b/video_to_video/diffusion/__pycache__/solvers_sdedit.cpython-39.pyc differ
|
|
video_to_video/modules/__pycache__/__init__.cpython-39.pyc
CHANGED
Binary files a/video_to_video/modules/__pycache__/__init__.cpython-39.pyc and b/video_to_video/modules/__pycache__/__init__.cpython-39.pyc differ
|
|
video_to_video/modules/__pycache__/embedder.cpython-39.pyc
CHANGED
Binary files a/video_to_video/modules/__pycache__/embedder.cpython-39.pyc and b/video_to_video/modules/__pycache__/embedder.cpython-39.pyc differ
|
|
video_to_video/modules/__pycache__/unet_v2v.cpython-39.pyc
CHANGED
Binary files a/video_to_video/modules/__pycache__/unet_v2v.cpython-39.pyc and b/video_to_video/modules/__pycache__/unet_v2v.cpython-39.pyc differ
|
|
video_to_video/utils/__pycache__/__init__.cpython-39.pyc
CHANGED
Binary files a/video_to_video/utils/__pycache__/__init__.cpython-39.pyc and b/video_to_video/utils/__pycache__/__init__.cpython-39.pyc differ
|
|
video_to_video/utils/__pycache__/config.cpython-39.pyc
CHANGED
Binary files a/video_to_video/utils/__pycache__/config.cpython-39.pyc and b/video_to_video/utils/__pycache__/config.cpython-39.pyc differ
|
|
video_to_video/utils/__pycache__/logger.cpython-39.pyc
CHANGED
Binary files a/video_to_video/utils/__pycache__/logger.cpython-39.pyc and b/video_to_video/utils/__pycache__/logger.cpython-39.pyc differ
|
|
video_to_video/utils/__pycache__/seed.cpython-39.pyc
CHANGED
Binary files a/video_to_video/utils/__pycache__/seed.cpython-39.pyc and b/video_to_video/utils/__pycache__/seed.cpython-39.pyc differ
|
|
video_to_video/video_to_video_model.py
CHANGED
@@ -88,6 +88,8 @@ class VideoToVideo_sr():
|
|
88 |
|
89 |
negative_y = text_encoder(self.negative_prompt).detach()
|
90 |
self.negative_y = negative_y
|
|
|
|
|
91 |
|
92 |
|
93 |
def test(self, input: Dict[str, Any], total_noise_levels=1000, \
|
@@ -142,7 +144,7 @@ class VideoToVideo_sr():
|
|
142 |
torch.cuda.empty_cache()
|
143 |
|
144 |
logger.info(f'sampling, finished.')
|
145 |
-
vid_tensor_gen = self.vae_decode_chunk(gen_vid, chunk_size=
|
146 |
|
147 |
logger.info(f'temporal vae decoding, finished.')
|
148 |
|
|
|
88 |
|
89 |
negative_y = text_encoder(self.negative_prompt).detach()
|
90 |
self.negative_y = negative_y
|
91 |
+
|
92 |
+
self.chunk_size = opt.chunk_size
|
93 |
|
94 |
|
95 |
def test(self, input: Dict[str, Any], total_noise_levels=1000, \
|
|
|
144 |
torch.cuda.empty_cache()
|
145 |
|
146 |
logger.info(f'sampling, finished.')
|
147 |
+
vid_tensor_gen = self.vae_decode_chunk(gen_vid, chunk_size=self.chunk_size)
|
148 |
|
149 |
logger.info(f'temporal vae decoding, finished.')
|
150 |
|