smellslikeml commited on
Commit
87c2878
1 Parent(s): 4855339

added image_directory_to_video_tool

Browse files
Files changed (5) hide show
  1. README.md +2 -2
  2. app.py +4 -0
  3. image_directory_to_video.py +32 -0
  4. requirements.txt +3 -0
  5. tool_config.json +6 -0
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
- title: Image Directory To Video
3
- emoji: 📈
4
  colorFrom: red
5
  colorTo: pink
6
  sdk: gradio
 
1
  ---
2
+ title: Image Directory To Video Tool
3
+ emoji: 🖼
4
  colorFrom: red
5
  colorTo: pink
6
  sdk: gradio
app.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from transformers.tools.base import launch_gradio_demo
2
+ from ffprobe import FFProbeTool
3
+
4
+ launch_gradio_demo(FFProbeTool)
image_directory_to_video.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import ffmpeg
3
+ from transformers import Tool
4
+
5
+ class ImageDirectoryToVideoTool(Tool):
6
+ name = "image_directory_video_tool"
7
+ description = """
8
+ This tool creates video
9
+ from a directory of images. Inputs
10
+ are input_path and output_path.
11
+ Output is the output_path.
12
+ """
13
+ inputs = ["text", "text"]
14
+ outputs = ["text"]
15
+
16
+ def __call__(
17
+ self,
18
+ input_path: str,
19
+ output_path: str,
20
+ framerate: int = 25,
21
+ extension: str = "jpg",
22
+ ):
23
+ (
24
+ ffmpeg.input(
25
+ input_path.rstrip("/") + "/*." + extension.lstrip("."),
26
+ pattern_type="glob",
27
+ framerate=framerate,
28
+ )
29
+ .output(output_path)
30
+ .run()
31
+ )
32
+ return output_path
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 creates video from a directory of images. Inputs are input_path and output_path. Output is the output_path.",
3
+ "name": "image_directory_video_tool",
4
+ "tool_class": "image_directory_to_video.ImageDirectoryToVideoTool"
5
+ }
6
+