Spaces:
Configuration error
Configuration error
xierui.0097
commited on
Commit
·
24a09de
1
Parent(s):
48af642
zerogpu
Browse files
app.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
-
import
|
| 2 |
import os
|
| 3 |
-
import random
|
| 4 |
-
|
| 5 |
import gradio as gr
|
| 6 |
-
|
| 7 |
from video_super_resolution.scripts.inference_sr import VEnhancer_sr
|
| 8 |
|
| 9 |
examples = [
|
|
@@ -16,15 +13,21 @@ examples = [
|
|
| 16 |
["prompts/gwen.mp4", "Gwen Stacy reading a book, black and white", 4, 24, 250],
|
| 17 |
]
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
def venhancer_demo(result_dir="./tmp/"):
|
| 21 |
css = """#input_video {max-width: 1024px !important} #output_vid {max-width: 2048px; max-height:1280px}"""
|
|
|
|
| 22 |
venhancer = VEnhancer_sr(result_dir)
|
|
|
|
| 23 |
with gr.Blocks(analytics_enabled=False, css=css) as venhancer_iface:
|
| 24 |
gr.Markdown(
|
| 25 |
"<div align='center'> <h1> VEnhancer </span> </h1> \
|
| 26 |
-
<a style='font-size:18px;color: #000000' href='https://arxiv.org/abs/
|
| 27 |
-
<a style='font-size:18px;color: #000000' href='https://
|
| 28 |
<a style='font-size:18px;color: #000000' href='https://github.com/NJU-PCALab/STAR'> [Github] </a> </div>"
|
| 29 |
)
|
| 30 |
with gr.Tab(label="VEnhancer"):
|
|
@@ -45,13 +48,13 @@ def venhancer_demo(result_dir="./tmp/"):
|
|
| 45 |
examples=examples,
|
| 46 |
inputs=[input_video, input_text],
|
| 47 |
outputs=[output_video],
|
| 48 |
-
fn=
|
| 49 |
cache_examples=False,
|
| 50 |
)
|
| 51 |
end_btn.click(
|
| 52 |
inputs=[input_video, input_text],
|
| 53 |
outputs=[output_video],
|
| 54 |
-
fn=
|
| 55 |
)
|
| 56 |
|
| 57 |
return venhancer_iface
|
|
@@ -61,4 +64,4 @@ if __name__ == "__main__":
|
|
| 61 |
result_dir = os.path.join("./", "results")
|
| 62 |
venhancer_iface = venhancer_demo(result_dir)
|
| 63 |
venhancer_iface.queue(max_size=12)
|
| 64 |
-
venhancer_iface.launch(max_threads=1)
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
import os
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
from video_super_resolution.scripts.inference_sr import VEnhancer_sr
|
| 5 |
|
| 6 |
examples = [
|
|
|
|
| 13 |
["prompts/gwen.mp4", "Gwen Stacy reading a book, black and white", 4, 24, 250],
|
| 14 |
]
|
| 15 |
|
| 16 |
+
# Define a GPU-decorated function for enhancement
|
| 17 |
+
@spaces.GPU(duration=1200)
|
| 18 |
+
def enhance_with_gpu(input_video, input_text):
|
| 19 |
+
return venhancer.enhance_a_video(input_video, input_text)
|
| 20 |
|
| 21 |
def venhancer_demo(result_dir="./tmp/"):
|
| 22 |
css = """#input_video {max-width: 1024px !important} #output_vid {max-width: 2048px; max-height:1280px}"""
|
| 23 |
+
global venhancer
|
| 24 |
venhancer = VEnhancer_sr(result_dir)
|
| 25 |
+
|
| 26 |
with gr.Blocks(analytics_enabled=False, css=css) as venhancer_iface:
|
| 27 |
gr.Markdown(
|
| 28 |
"<div align='center'> <h1> VEnhancer </span> </h1> \
|
| 29 |
+
<a style='font-size:18px;color: #000000' href='https://arxiv.org/abs/2501.02976'> [ArXiv] </a>\
|
| 30 |
+
<a style='font-size:18px;color: #000000' href='https://nju-pcalab.github.io/projects/STAR'> [Project Page] </a> \
|
| 31 |
<a style='font-size:18px;color: #000000' href='https://github.com/NJU-PCALab/STAR'> [Github] </a> </div>"
|
| 32 |
)
|
| 33 |
with gr.Tab(label="VEnhancer"):
|
|
|
|
| 48 |
examples=examples,
|
| 49 |
inputs=[input_video, input_text],
|
| 50 |
outputs=[output_video],
|
| 51 |
+
fn=enhance_with_gpu, # Use the GPU-decorated function
|
| 52 |
cache_examples=False,
|
| 53 |
)
|
| 54 |
end_btn.click(
|
| 55 |
inputs=[input_video, input_text],
|
| 56 |
outputs=[output_video],
|
| 57 |
+
fn=enhance_with_gpu, # Use the GPU-decorated function
|
| 58 |
)
|
| 59 |
|
| 60 |
return venhancer_iface
|
|
|
|
| 64 |
result_dir = os.path.join("./", "results")
|
| 65 |
venhancer_iface = venhancer_demo(result_dir)
|
| 66 |
venhancer_iface.queue(max_size=12)
|
| 67 |
+
venhancer_iface.launch(max_threads=1)
|