File size: 8,184 Bytes
c28feac
5764d8b
2ee3801
c28feac
e157aaa
 
 
6bd7964
c28feac
b56c42a
2ee3801
 
ed7eb3f
6bd7964
 
 
 
2ee3801
ed7eb3f
5764d8b
e157aaa
 
 
e6b5aa1
e157aaa
6298c5f
 
 
e6b5aa1
4cdd405
 
e6b5aa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e157aaa
e6b5aa1
 
 
 
 
 
 
 
fd0e01f
 
 
 
 
 
e6b5aa1
 
 
 
 
 
 
fd0e01f
 
 
6bd7964
e6b5aa1
 
e157aaa
e6b5aa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e157aaa
e6b5aa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd0e01f
 
e6b5aa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ee3801
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import gradio as gr
from videopose_PSTMO import gr_video2mc
import os

# ffmpeg -i input_videos/kun_1280x720_30fps_0-14_0-32.mp4 -vf trim=0:5,setpts=PTS-STARTPTS input_videos/kun_test_5sec.mp4
# ffmpeg -i input.mp4 -vf scale=320:-1 output.mp4

Count = 0

def Video2MC(video, progress=gr.Progress(track_tqdm=True)):

    progress(1.0, desc="Step 0: Starting")
    output_path, output_video = gr_video2mc(video, progress)
    
    global Count 
    Count += 1
    print(f"Count: {Count}")

    return output_path, output_path, output_video

with gr.Blocks() as iface:

    text1 = gr.Markdown(
                        f"""
                        <div align=center>

                        ![](file/Video2MC.png)

                        </div>
                        """
                        )

    with gr.Tab("English"):

        text2 = gr.Markdown(
                            """
                            <h1 align="center">Video2MC: 3D-HPE based Mine-imator animation generation</h1>
                            

                            ## Introduction
                            
                            Using computer vision algorithms, I have achieved cost-effective "motion capture," and I am now officially releasing the Video2MC algorithm for automatic generation of Mine-imator animations!
                            
                            Before using, it is **highly recommended** to watch my [introductory video](https://www.bilibili.com/video/BV1SP411W7pw), as it will help you quickly understand what this project is about.

                            Enjoy it!

                            """
                            )
        
        with gr.Accordion("Related Links", open=False):

            text_req = gr.Markdown(
                """
                ## Related Links

                Github: https://github.com/Balloon-356/Video2MC

                My Bilibili (Contact): https://space.bilibili.com/244384103

                **Introductory video:** https://www.bilibili.com/video/BV1SP411W7pw
                
                Implementation details: https://www.bilibili.com/read/cv25704198

                """
            )
        
        with gr.Accordion("How to Use", open=False):

            text_req = gr.Markdown(
                """
                ## How to Use

                1. Upload a video by dragging it into the box on the bottom left. The video must meet the **requirements**.
                
                2. Click "Submit", and the algorithm will start running. Please wait patiently, and you can see the current progress in the box on the right. (A 5s video takes about 5min.)

                3. Algorithm finished. You can download the .miframes file and preview the video rendered by the 3D-HPE algorithm (for previewing motion capture results).
                
                4. Import the .miframes file into the Mine-imator to create a Minecraft animation (you can learn how to use it on the Mine-imator forums).

                5. Fine-tune the motions of the skeleton model in Mine-imator.

                """
            )

        with gr.Accordion("Video Requirements", open=False):

            text_req = gr.Markdown(
                """
                ## Video Requirements

                1. Please upload short videos, preferably not exceeding 10 seconds. (Otherwise, the algorithm will run for several tens of mins and it still works.)
                            
                2. The video should only contain one person, positioned at the center of the frame, fully visible from head to toe, facing the camera.

                3. Just as shown in the "example" below.

                """
            )
        
        with gr.Row():

            with gr.Column():
                input_video = gr.Video()
                with gr.Row():
                    btn_c = gr.ClearButton(input_video)
                    btn_s = gr.Button("Submit", variant='primary')
                gr.Examples([os.path.join(os.path.dirname(__file__), 
                        "input_videos/kun_test_5sec.mp4")], input_video)
                
            with gr.Column():
                output_miframes = gr.File()
                output_path = gr.Text()
                output_video = gr.Video()
            
            
        btn_s.click(Video2MC, inputs=[input_video], outputs=[output_miframes, output_path, output_video])


    with gr.Tab("中文"):

        text2 = gr.Markdown(
                            """
                            <h1 align="center">Video2MC:基于3D-HPE的MC动画自动生成</h1>

                            <br/>

                            **有问题或者改进建议请在B站视频评论区发表评论,感谢支持!**

                            <br/>
                            
                            ## 简单介绍

                            利用计算机视觉算法,我实现了低成本“动作捕捉”,在此正式发布MC动画自动生成算法Video2MC!

                            使用前,强烈建议先观看我的[B站视频](https://www.bilibili.com/video/BV1SP411W7pw),快速了解该项目的用法。

                            目前该项目还在不断优化改进,请关注我的B站帐号,获取最新消息。

                            初次使用务必阅读下面的“使用说明”和“视频要求”!  ↓↓↓

                            """
                            )
        

        with gr.Accordion("相关链接", open=False):

            text_req = gr.Markdown(
                """
                ## 相关链接

                Github项目:https://github.com/Balloon-356/Video2MC

                B站帐号(私信联系):https://space.bilibili.com/244384103

                **介绍视频:** https://www.bilibili.com/video/BV1SP411W7pw

                实现原理:https://www.bilibili.com/read/cv25704198

                """
            )
        
        with gr.Accordion("使用说明", open=False):

            text_req = gr.Markdown(
                """
                ## 使用说明

                1. 上传一段视频(拖入下方左侧的框中)。视频需要满足“视频要求”。

                2. 点击“Submit”提交视频,此时算法开始运行。请耐心等待,右侧的框中将显示算法运行的进度。(5s的视频大约需要5分钟)

                3. 运行结束。可以在右侧的框中下载.miframes文件,并且可以通过算法渲染得到的骨架动作视频预览效果。

                4. 将.miframes文件导入到Mine-imator软件中,生成一段动画。(导入方法可在互联网上查询)

                5. 微调人物动作,导出动画。

                注:目前使用的是CPU,代码运行较慢。GPU算力过于昂贵,若有需求请私信联系。

                """
            )

        with gr.Accordion("视频要求", open=False):

            text_req = gr.Markdown(
                """
                ## 视频要求

                1. 请尽量上传时长较短的视频(10s内最好),否则算法将运行很长时间。

                2. 视频中应该只包含一个人,且人位于视频中心、全身完整地出现在视频中,面向相机。

                3. 如"example"中展示的视频一样。

                """
            )



        with gr.Row():

            with gr.Column():
                input_video = gr.Video()
                with gr.Row():
                    btn_c = gr.ClearButton(input_video)
                    btn_s = gr.Button("Submit", variant='primary')
                gr.Examples([os.path.join(os.path.dirname(__file__), 
                        "input_videos/kun_test_5sec.mp4")], input_video)
                
            with gr.Column():
                output_miframes = gr.File()
                output_path = gr.Text()
                output_video = gr.Video()
            
            
        btn_s.click(Video2MC, inputs=[input_video], outputs=[output_miframes, output_path, output_video])
    

iface.queue(concurrency_count=10).launch()