test fps reduction function
Browse files- main_noweb.py +14 -13
main_noweb.py
CHANGED
@@ -37,6 +37,7 @@ hand = MMPoseInferencer("hand")
|
|
37 |
#"https://github.com/open-mmlab/mmpose/blob/main/configs/body_3d_keypoint/pose_lift/h36m/pose-lift_simplebaseline3d_8xb64-200e_h36m.py",
|
38 |
#"https://download.openmmlab.com/mmpose/body3d/simple_baseline/simple3Dbaseline_h36m-f0ad73a4_20210419.pth") # pose3d="human3d"
|
39 |
#https://github.com/open-mmlab/mmpose/tree/main/configs/hand_2d_keypoint/topdown_regression
|
|
|
40 |
print("[INFO]: Downloaded models!")
|
41 |
|
42 |
def check_fps(video):
|
@@ -46,7 +47,12 @@ def check_fps(video):
|
|
46 |
return nframes, fps
|
47 |
|
48 |
|
49 |
-
def get_frames(video, fps=
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
split_tup = os.path.splitext(video)
|
52 |
|
@@ -57,12 +63,6 @@ def get_frames(video, fps=20, height=512, width=512):
|
|
57 |
print("Converting to mp4")
|
58 |
video = file_name+".mp4"
|
59 |
|
60 |
-
|
61 |
-
clip = moviepy.VideoFileClip(video)
|
62 |
-
|
63 |
-
if clip.duration > 10:
|
64 |
-
raise gr.Error("Please provide or record a video shorter than 10 seconds...")
|
65 |
-
|
66 |
#check fps
|
67 |
if clip.fps > fps:
|
68 |
print("vide rate is over 15, resetting to 15")
|
@@ -189,7 +189,9 @@ def UI():
|
|
189 |
with gr.Row():
|
190 |
video_input = gr.Video(source="upload", type="filepath", height=512, width=512)
|
191 |
# Insert slider with kpt_thr
|
192 |
-
|
|
|
|
|
193 |
with gr.Row():
|
194 |
submit_pose_file = gr.Button("Make 2d pose estimation")
|
195 |
submit_pose3d_file = gr.Button("Make 3d pose estimation")
|
@@ -212,8 +214,6 @@ def UI():
|
|
212 |
import json
|
213 |
import numpy as np
|
214 |
|
215 |
-
kpointlist=[]
|
216 |
-
|
217 |
# First we load the data
|
218 |
with open(file_path, 'r') as json_file:
|
219 |
data = json.load(json_file)
|
@@ -303,12 +303,12 @@ def UI():
|
|
303 |
|
304 |
submit_pose3d_file.click(fn=pose3d,
|
305 |
inputs= [video_input, file_kpthr],
|
306 |
-
outputs = video_output2,
|
307 |
queue=True)
|
308 |
|
309 |
submit_hand_file.click(fn=pose2dhand,
|
310 |
inputs= [video_input, file_kpthr],
|
311 |
-
outputs = video_output3,
|
312 |
queue=True)
|
313 |
return block
|
314 |
|
@@ -319,7 +319,8 @@ if __name__ == "__main__":
|
|
319 |
#max_size=25, # Maximum number of requests that the queue processes
|
320 |
api_open = False # When creating a Gradio demo, you may want to restrict all traffic to happen through the user interface as opposed to the programmatic API that is automatically created for your Gradio demo.
|
321 |
).launch(
|
322 |
-
|
|
|
323 |
server_port=7860,
|
324 |
auth=("novouser", "bstad2023")
|
325 |
)
|
|
|
37 |
#"https://github.com/open-mmlab/mmpose/blob/main/configs/body_3d_keypoint/pose_lift/h36m/pose-lift_simplebaseline3d_8xb64-200e_h36m.py",
|
38 |
#"https://download.openmmlab.com/mmpose/body3d/simple_baseline/simple3Dbaseline_h36m-f0ad73a4_20210419.pth") # pose3d="human3d"
|
39 |
#https://github.com/open-mmlab/mmpose/tree/main/configs/hand_2d_keypoint/topdown_regression
|
40 |
+
|
41 |
print("[INFO]: Downloaded models!")
|
42 |
|
43 |
def check_fps(video):
|
|
|
47 |
return nframes, fps
|
48 |
|
49 |
|
50 |
+
def get_frames(video, fps=50, height=512, width=512):
|
51 |
+
|
52 |
+
clip = moviepy.VideoFileClip(video)
|
53 |
+
|
54 |
+
if clip.duration > 10:
|
55 |
+
raise gr.Error("Please provide or record a video shorter than 10 seconds...")
|
56 |
|
57 |
split_tup = os.path.splitext(video)
|
58 |
|
|
|
63 |
print("Converting to mp4")
|
64 |
video = file_name+".mp4"
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
#check fps
|
67 |
if clip.fps > fps:
|
68 |
print("vide rate is over 15, resetting to 15")
|
|
|
189 |
with gr.Row():
|
190 |
video_input = gr.Video(source="upload", type="filepath", height=512, width=512)
|
191 |
# Insert slider with kpt_thr
|
192 |
+
with gr.Column("Drag the keypoint threshold to filter out lower probability keypoints:"):
|
193 |
+
gr.Markdown()
|
194 |
+
file_kpthr = gr.Slider(0, 1, value=0.3, label='Keypoint threshold')
|
195 |
with gr.Row():
|
196 |
submit_pose_file = gr.Button("Make 2d pose estimation")
|
197 |
submit_pose3d_file = gr.Button("Make 3d pose estimation")
|
|
|
214 |
import json
|
215 |
import numpy as np
|
216 |
|
|
|
|
|
217 |
# First we load the data
|
218 |
with open(file_path, 'r') as json_file:
|
219 |
data = json.load(json_file)
|
|
|
303 |
|
304 |
submit_pose3d_file.click(fn=pose3d,
|
305 |
inputs= [video_input, file_kpthr],
|
306 |
+
outputs = [video_output2, jsonoutput],
|
307 |
queue=True)
|
308 |
|
309 |
submit_hand_file.click(fn=pose2dhand,
|
310 |
inputs= [video_input, file_kpthr],
|
311 |
+
outputs = [video_output3, jsonoutput],
|
312 |
queue=True)
|
313 |
return block
|
314 |
|
|
|
319 |
#max_size=25, # Maximum number of requests that the queue processes
|
320 |
api_open = False # When creating a Gradio demo, you may want to restrict all traffic to happen through the user interface as opposed to the programmatic API that is automatically created for your Gradio demo.
|
321 |
).launch(
|
322 |
+
max_threads=41,
|
323 |
+
server_name="0.0.0.0",
|
324 |
server_port=7860,
|
325 |
auth=("novouser", "bstad2023")
|
326 |
)
|