visualization
Browse files- Dockerfile +1 -0
- main.py +27 -4
Dockerfile
CHANGED
|
@@ -25,6 +25,7 @@ WORKDIR /..
|
|
| 25 |
|
| 26 |
RUN pip install --no-cache-dir --upgrade gradio
|
| 27 |
RUN pip install --no-cache-dir --upgrade numpy
|
|
|
|
| 28 |
|
| 29 |
#https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo
|
| 30 |
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
|
|
|
|
| 25 |
|
| 26 |
RUN pip install --no-cache-dir --upgrade gradio
|
| 27 |
RUN pip install --no-cache-dir --upgrade numpy
|
| 28 |
+
RUN pip install --no-cache-dir --upgrade opencv-python
|
| 29 |
|
| 30 |
#https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo
|
| 31 |
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
|
main.py
CHANGED
|
@@ -5,6 +5,7 @@ print("[INFO]: Imported modules!")
|
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
import numpy as np
|
|
|
|
| 8 |
|
| 9 |
inferencer = MMPoseInferencer('human')
|
| 10 |
print("[INFO]: Downloaded models!")
|
|
@@ -15,15 +16,37 @@ def poses(photo):
|
|
| 15 |
vis_out_dir =".",
|
| 16 |
return_vis=True,
|
| 17 |
thickness=2)
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
print(os.listdir())
|
| 22 |
print("[INFO]: Visualizing results!")
|
| 23 |
print(os.listdir())
|
| 24 |
print()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
return
|
| 27 |
|
| 28 |
|
| 29 |
# # specify detection model by alias
|
|
|
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
import numpy as np
|
| 8 |
+
import cv2
|
| 9 |
|
| 10 |
inferencer = MMPoseInferencer('human')
|
| 11 |
print("[INFO]: Downloaded models!")
|
|
|
|
| 16 |
vis_out_dir =".",
|
| 17 |
return_vis=True,
|
| 18 |
thickness=2)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
video = cv2.VideoCapture(photo)
|
| 23 |
+
|
| 24 |
+
# Prepare to save video
|
| 25 |
+
output_file = os.path.join("output.mp4")
|
| 26 |
+
|
| 27 |
+
fourcc = cv2.VideoWriter_fourcc(*"mp4v") # Codec for MP4 video
|
| 28 |
+
fps = video.get(cv2.CAP_PROP_FPS)
|
| 29 |
+
height = 480
|
| 30 |
+
width = 640
|
| 31 |
+
size = (width,height)
|
| 32 |
+
|
| 33 |
+
out_writer = cv2.VideoWriter(output_file, fourcc, fps, size)
|
| 34 |
+
|
| 35 |
+
for result in result_generator:
|
| 36 |
+
frame = result["visualization"]
|
| 37 |
+
out_writer.write(frame)
|
| 38 |
+
|
| 39 |
print(os.listdir())
|
| 40 |
print("[INFO]: Visualizing results!")
|
| 41 |
print(os.listdir())
|
| 42 |
print()
|
| 43 |
+
|
| 44 |
+
out_writer.release()
|
| 45 |
+
|
| 46 |
+
cv2.destroyAllWindows() # Closing window
|
| 47 |
+
|
| 48 |
|
| 49 |
+
return output_file
|
| 50 |
|
| 51 |
|
| 52 |
# # specify detection model by alias
|