Spaces:
Runtime error
Runtime error
remove video
Browse files
app.py
CHANGED
|
@@ -44,7 +44,6 @@ def infer_video(path_input, seed):
|
|
| 44 |
|
| 45 |
def run_demo_server():
|
| 46 |
infer_gpu = spaces.GPU(functools.partial(infer))
|
| 47 |
-
infer_video_gpu = spaces.GPU(functools.partial(infer_video))
|
| 48 |
gradio_theme = gr.themes.Default()
|
| 49 |
|
| 50 |
with gr.Blocks(
|
|
@@ -110,96 +109,49 @@ def run_demo_server():
|
|
| 110 |
"""
|
| 111 |
)
|
| 112 |
with gr.Tabs(elem_classes=["tabs"]):
|
| 113 |
-
with gr.
|
| 114 |
-
with gr.
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
| 124 |
)
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
type="filepath",
|
| 134 |
interactive=False,
|
| 135 |
elem_classes="slider",
|
| 136 |
position=0.25,
|
| 137 |
)
|
| 138 |
-
with gr.Row():
|
| 139 |
-
image_output_d = ImageSlider(
|
| 140 |
-
label="Output (Discriminative)",
|
| 141 |
-
type="filepath",
|
| 142 |
-
interactive=False,
|
| 143 |
-
elem_classes="slider",
|
| 144 |
-
position=0.25,
|
| 145 |
-
)
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
with gr.Tab("VIDEO"):
|
| 159 |
-
with gr.Row():
|
| 160 |
-
with gr.Column():
|
| 161 |
-
input_video = gr.Video(
|
| 162 |
-
label="Input Video",
|
| 163 |
-
autoplay=True,
|
| 164 |
-
loop=True,
|
| 165 |
-
)
|
| 166 |
-
seed = gr.Number(
|
| 167 |
-
label="Seed (only for Generative mode)",
|
| 168 |
-
minimum=0,
|
| 169 |
-
maximum=999999999,
|
| 170 |
-
)
|
| 171 |
-
with gr.Row():
|
| 172 |
-
video_submit_btn = gr.Button(
|
| 173 |
-
value="Predict Normal!", variant="primary"
|
| 174 |
-
)
|
| 175 |
-
video_reset_btn = gr.Button(value="Reset")
|
| 176 |
-
with gr.Column():
|
| 177 |
-
video_output_g = gr.Video(
|
| 178 |
-
label="Output (Generative)",
|
| 179 |
-
interactive=False,
|
| 180 |
-
autoplay=True,
|
| 181 |
-
loop=True,
|
| 182 |
-
show_share_button=True,
|
| 183 |
-
)
|
| 184 |
-
with gr.Row():
|
| 185 |
-
video_output_d = gr.Video(
|
| 186 |
-
label="Output (Discriminative)",
|
| 187 |
-
interactive=False,
|
| 188 |
-
autoplay=True,
|
| 189 |
-
loop=True,
|
| 190 |
-
show_share_button=True,
|
| 191 |
-
)
|
| 192 |
-
|
| 193 |
-
gr.Examples(
|
| 194 |
-
fn=infer_video_gpu,
|
| 195 |
-
examples=sorted([
|
| 196 |
-
[os.path.join("files", "videos", name), 0]
|
| 197 |
-
for name in os.listdir(os.path.join("files", "videos"))
|
| 198 |
-
]),
|
| 199 |
-
inputs=[input_video, seed],
|
| 200 |
-
outputs=[video_output_g, video_output_d],
|
| 201 |
-
cache_examples=False,
|
| 202 |
-
)
|
| 203 |
|
| 204 |
### Image
|
| 205 |
image_submit_btn.click(
|
|
@@ -214,25 +166,12 @@ def run_demo_server():
|
|
| 214 |
queue=False,
|
| 215 |
)
|
| 216 |
|
| 217 |
-
### Video
|
| 218 |
-
video_submit_btn.click(
|
| 219 |
-
fn=infer_video_gpu,
|
| 220 |
-
inputs=[input_video, seed],
|
| 221 |
-
outputs=[video_output_g, video_output_d],
|
| 222 |
-
queue=True,
|
| 223 |
-
)
|
| 224 |
-
video_reset_btn.click(
|
| 225 |
-
fn=lambda: (None, None, None),
|
| 226 |
-
inputs=[],
|
| 227 |
-
outputs=[video_output_g, video_output_d],
|
| 228 |
-
)
|
| 229 |
-
|
| 230 |
### Server launch
|
| 231 |
demo.queue(
|
| 232 |
api_open=False,
|
| 233 |
).launch(
|
| 234 |
server_name="0.0.0.0",
|
| 235 |
-
server_port=
|
| 236 |
)
|
| 237 |
|
| 238 |
def main():
|
|
|
|
| 44 |
|
| 45 |
def run_demo_server():
|
| 46 |
infer_gpu = spaces.GPU(functools.partial(infer))
|
|
|
|
| 47 |
gradio_theme = gr.themes.Default()
|
| 48 |
|
| 49 |
with gr.Blocks(
|
|
|
|
| 109 |
"""
|
| 110 |
)
|
| 111 |
with gr.Tabs(elem_classes=["tabs"]):
|
| 112 |
+
with gr.Row():
|
| 113 |
+
with gr.Column():
|
| 114 |
+
image_input = gr.Image(
|
| 115 |
+
label="Input Image",
|
| 116 |
+
type="filepath",
|
| 117 |
+
)
|
| 118 |
+
seed = gr.Number(
|
| 119 |
+
label="Seed (only for Generative mode)",
|
| 120 |
+
minimum=0,
|
| 121 |
+
maximum=999999999,
|
| 122 |
+
)
|
| 123 |
+
with gr.Row():
|
| 124 |
+
image_submit_btn = gr.Button(
|
| 125 |
+
value="Predict Normal!", variant="primary"
|
| 126 |
)
|
| 127 |
+
image_reset_btn = gr.Button(value="Reset")
|
| 128 |
+
with gr.Column():
|
| 129 |
+
image_output_g = ImageSlider(
|
| 130 |
+
label="Output (Generative)",
|
| 131 |
+
type="filepath",
|
| 132 |
+
interactive=False,
|
| 133 |
+
elem_classes="slider",
|
| 134 |
+
position=0.25,
|
| 135 |
+
)
|
| 136 |
+
with gr.Row():
|
| 137 |
+
image_output_d = ImageSlider(
|
| 138 |
+
label="Output (Discriminative)",
|
| 139 |
type="filepath",
|
| 140 |
interactive=False,
|
| 141 |
elem_classes="slider",
|
| 142 |
position=0.25,
|
| 143 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
+
gr.Examples(
|
| 146 |
+
fn=infer_gpu,
|
| 147 |
+
examples=sorted([
|
| 148 |
+
[os.path.join("files", "images", name), 0]
|
| 149 |
+
for name in os.listdir(os.path.join("files", "images"))
|
| 150 |
+
]),
|
| 151 |
+
inputs=[image_input, seed],
|
| 152 |
+
outputs=[image_output_g, image_output_d],
|
| 153 |
+
cache_examples=False,
|
| 154 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
### Image
|
| 157 |
image_submit_btn.click(
|
|
|
|
| 166 |
queue=False,
|
| 167 |
)
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
### Server launch
|
| 170 |
demo.queue(
|
| 171 |
api_open=False,
|
| 172 |
).launch(
|
| 173 |
server_name="0.0.0.0",
|
| 174 |
+
server_port=7861,
|
| 175 |
)
|
| 176 |
|
| 177 |
def main():
|