Spaces:
Runtime error
Runtime error
smellslikeml
commited on
Commit
Β·
69c46d2
1
Parent(s):
e248db0
initial commit
Browse files- README.md +2 -2
- app.py +4 -0
- requirements.txt +3 -0
- tool_config.json +6 -0
- video_stabilizer.py +38 -0
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
title: Video Stabilizer
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.43.2
|
|
|
1 |
---
|
2 |
title: Video Stabilizer
|
3 |
+
emoji: π
|
4 |
+
colorFrom: green
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.43.2
|
app.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.tools.base import launch_gradio_demo
|
2 |
+
from video_stabilizer import VideoStabilizationTool
|
3 |
+
|
4 |
+
launch_gradio_demo(VideoStabilizationTool)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
ffmpeg-python
|
2 |
+
huggingface_hub
|
3 |
+
transformers
|
tool_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"description": "This tool stabilizes a video. Inputs are input_path, output_path, smoothing, zoom. Output is the output_path.",
|
3 |
+
"name": "video_stabilization_tool",
|
4 |
+
"tool_class": "video_stabilizer.VideoStabilizationTool"
|
5 |
+
}
|
6 |
+
|
video_stabilizer.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import ffmpeg
|
2 |
+
from transformers import Tool
|
3 |
+
|
4 |
+
class VideoStabilizationTool(Tool):
|
5 |
+
name = "video_stabilization_tool"
|
6 |
+
description = """
|
7 |
+
This tool stabilizes a video.
|
8 |
+
Inputs are input_path, output_path, smoothing, zoom.
|
9 |
+
"""
|
10 |
+
inputs = ["text", "text", "integer", "integer", "integer"]
|
11 |
+
outputs = ["text"]
|
12 |
+
|
13 |
+
def __call__(
|
14 |
+
self,
|
15 |
+
input_path: str,
|
16 |
+
output_path: str,
|
17 |
+
smoothing: int = 10,
|
18 |
+
zoom: int = 0,
|
19 |
+
shakiness: int = 5,
|
20 |
+
):
|
21 |
+
(
|
22 |
+
ffmpeg.input(input_path)
|
23 |
+
.output("null", vf="vidstabdetect=shakiness={}".format(shakiness), f="null")
|
24 |
+
.overwrite_output()
|
25 |
+
.run(capture_stdout=True, capture_stderr=True)
|
26 |
+
)
|
27 |
+
(
|
28 |
+
ffmpeg.input(input_path)
|
29 |
+
.output(
|
30 |
+
output_path,
|
31 |
+
vf="vidstabtransform=smoothing={}:zoom={}:input={}".format(
|
32 |
+
smoothing, zoom, "transforms.trf"
|
33 |
+
),
|
34 |
+
)
|
35 |
+
.overwrite_output()
|
36 |
+
.run()
|
37 |
+
)
|
38 |
+
return output_path
|