Skip to content

Commit

Permalink
#43 add benchmark "blur-faces-parallel"
Browse files Browse the repository at this point in the history
  • Loading branch information
tomskikh committed Jan 30, 2023
1 parent ae7bd25 commit 028b98e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gpumat/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@ def benchmark_gpu_blur_faces(
)


def benchmark_gpu_blur_faces_parallel(
gst_buffer: Gst.Buffer,
nvds_frame_meta: pyds.NvDsFrameMeta,
data: BenchmarkData,
):
with nvds_to_gpu_mat(gst_buffer, nvds_frame_meta) as frame_mat:
streams = []
results = []
for x, y in data.points:
streams.append(cv2.cuda.Stream())
roi_mat = cv2.cuda.GpuMat(frame_mat, (x, y, FACE_WIDTH, FACE_HEIGHT))
results.append(
(roi_mat, data.cuda_blur_filter.apply(roi_mat, stream=streams[-1]))
)
for i, stream in enumerate(streams):
stream.waitForCompletion()
results[i][1].copyTo(results[i][0])


def benchmark_gpu_blur_faces_in_cpu(
gst_buffer: Gst.Buffer,
nvds_frame_meta: pyds.NvDsFrameMeta,
Expand Down Expand Up @@ -165,6 +184,7 @@ def benchmark_gpu_download_upload(
'overlay-single': (None, benchmark_gpu_overlay_single),
'draw-rectangles': (benchmark_cpu_draw_rectangles, benchmark_gpu_draw_rectangles),
'blur-faces': (benchmark_cpu_blur_faces, benchmark_gpu_blur_faces),
'blur-faces-parallel': (None, benchmark_gpu_blur_faces_parallel),
'blur-faces-in-cpu': (None, benchmark_gpu_blur_faces_in_cpu),
'download-upload': (None, benchmark_gpu_download_upload),
}
Expand Down
1 change: 1 addition & 0 deletions gpumat/run_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GPU_BENCHMARK_NAMES=(
"overlay-single"
"draw-rectangles"
"blur-faces"
"blur-faces-parallel"
"blur-faces-in-cpu"
"download-upload"
)
Expand Down

0 comments on commit 028b98e

Please sign in to comment.