Add python sample for face detection and age classification using HF models#595
Add python sample for face detection and age classification using HF models#595
Conversation
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
| gi.require_version("GstAnalytics", "1.0") | ||
| from gi.repository import GLib, Gst, GstAnalytics | ||
| from huggingface_hub import hf_hub_download | ||
| from ultralytics import YOLO |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
C0413: Import "from ultralytics import YOLO" should be placed at the top of the module (wrong-import-position)
| from ultralytics import YOLO | ||
|
|
||
| # wrapper to run the gstreamer pipeline loop | ||
| def pipeline_loop(pipeline): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
| sys.stderr.write("Input video file does not exist\n") | ||
| sys.exit(1) | ||
| else: | ||
| default_video_url = "https://videos.pexels.com/video-files/18553046/18553046-hd_1280_720_30fps.mp4" |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
C0301: Line too long (107/100) (line-too-long)
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/face_detection_and_classification.py
Outdated
Show resolved
Hide resolved
| import subprocess | ||
| import urllib.request | ||
| import gi | ||
| from gi.repository import Gst |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
E0611: No name 'Gst' in module 'gi.repository' (no-name-in-module)
|
|
||
|
|
||
| # Prepare input video file; download default if none provided | ||
| def prepare_input_video(args): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)
|
|
||
|
|
||
| # wrapper to run the gstreamer pipeline loop | ||
| def pipeline_loop(pipeline): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)
|
|
||
|
|
||
| # Download PyTorch models, convert to OpenVINO IR, create and run gstreamer pipeline | ||
| def main(input_video): |
There was a problem hiding this comment.
[pylint] reported by reviewdog 🐶
C0116: Missing function or method docstring (missing-function-docstring)
samples/gstreamer/python/face_detection_and_classification/README.md
Outdated
Show resolved
Hide resolved
samples/gstreamer/python/face_detection_and_classification/README.md
Outdated
Show resolved
Hide resolved
| Use optimum-cli to download the face age classifier from Hugging Face and export it to OpenVINO IR. | ||
|
|
||
| **STEP 3 — Build and run the pipeline** | ||
| Construct a GStreamer pipeline with `gvadetect` and `gvaclassify`, run inference, and write an annotated MP4 output. |
There was a problem hiding this comment.
add mention about DL Streamer -->
'Construct a GStreamer pipeline with DL Streamer gvadetect and gvaclassify elements'...
|
|
||
| ## Sample Output | ||
|
|
||
| The script prints the pipeline string and produces an output video annotated with detections and classification results. |
There was a problem hiding this comment.
Consider adding screenshot from the sample, to visualize the final effect.
tbujewsk
left a comment
There was a problem hiding this comment.
Looks good but please see my comments.
…models.
Description
Please include a summary of the changes and the related issue. List any dependencies that are required for this change.
Fixes # (issue)
Any Newly Introduced Dependencies
Please describe any newly introduced 3rd party dependencies in this change. List their name, license information and how they are used in the project.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: