xmrt commited on
Commit
e2522a6
1 Parent(s): 8d667ad

3d visualization

Browse files
Files changed (2) hide show
  1. main.py +25 -25
  2. requirements.txt +2 -1
main.py CHANGED
@@ -1,12 +1,15 @@
1
  import mmpose
2
  import os
 
3
  from mmpose.apis import MMPoseInferencer
4
- print("[INFO]: Imported modules!")
5
-
6
  import gradio as gr
7
  import numpy as np
8
  import cv2
9
 
 
 
 
 
10
  # inferencer = MMPoseInferencer('hand') # 'hand', 'human , device='cuda'
11
  # inferencer = MMPoseInferencer('human')
12
 
@@ -29,38 +32,35 @@ def poses(photo):
29
  result_generator = inferencer(photo,
30
  vis_out_dir =".",
31
  return_vis=True,
32
- thickness=2)
33
-
34
-
35
-
36
- # Prepare to save video
37
- output_file = os.path.join("output.mp4")
38
 
39
- fourcc = cv2.VideoWriter_fourcc(*"mp4v") # Codec for MP4 video
40
- fps = 32
41
- height = 480
42
- width = 640
43
- size = (width,height)
44
 
45
- out_writer = cv2.VideoWriter(output_file, fourcc, fps, size)
 
 
 
 
46
 
47
- for result in result_generator:
48
- print("[INFO] Result: ", result)
49
- frame = result["visualization"]
50
- out_writer.write(cv2.cvtColor(frame[0], cv2.COLOR_BGR2RGB))
51
 
52
- print(os.listdir())
53
- print("[INFO]: Visualizing results!")
54
- print(os.listdir())
55
- print()
56
 
57
- out_writer.release()
58
- cv2.destroyAllWindows() # Closing window
 
 
59
 
 
 
 
60
 
61
  return output_file
62
 
63
-
64
  # # specify detection model by alias
65
  # # the available aliases include 'human', 'hand', 'face', 'animal',
66
  # # as well as any additional aliases defined in mmdet
 
1
  import mmpose
2
  import os
3
+ import glob
4
  from mmpose.apis import MMPoseInferencer
 
 
5
  import gradio as gr
6
  import numpy as np
7
  import cv2
8
 
9
+ print("[INFO]: Imported modules!")
10
+
11
+
12
+
13
  # inferencer = MMPoseInferencer('hand') # 'hand', 'human , device='cuda'
14
  # inferencer = MMPoseInferencer('human')
15
 
 
32
  result_generator = inferencer(photo,
33
  vis_out_dir =".",
34
  return_vis=True,
35
+ thickness=2)
 
 
 
 
 
36
 
37
+ # # Prepare to save video
38
+ # output_file = os.path.join("output.mp4")
 
 
 
39
 
40
+ # fourcc = cv2.VideoWriter_fourcc(*"mp4v") # Codec for MP4 video
41
+ # fps = 32
42
+ # height = 480
43
+ # width = 640
44
+ # size = (width,height)
45
 
46
+ # out_writer = cv2.VideoWriter(output_file, fourcc, fps, size)
 
 
 
47
 
48
+ # for result in result_generator:
49
+ # print("[INFO] Result: ", result)
50
+ # frame = result["visualization"]
51
+ # out_writer.write(cv2.cvtColor(frame[0], cv2.COLOR_BGR2RGB))
52
 
53
+ # print(os.listdir())
54
+ # print("[INFO]: Visualizing results!")
55
+ # print(os.listdir())
56
+ # print()
57
 
58
+ # out_writer.release()
59
+ # cv2.destroyAllWindows() # Closing window
60
+ output_file = glob.glob("*.mp4")
61
 
62
  return output_file
63
 
 
64
  # # specify detection model by alias
65
  # # the available aliases include 'human', 'hand', 'face', 'animal',
66
  # # as well as any additional aliases defined in mmdet
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  gradio
2
  numpy
3
- opencv-python
 
 
1
  gradio
2
  numpy
3
+ opencv-python
4
+ glob