Repository navigation
Add real-time webcam inference loop with FPS and compliance counters - #6
MathewTech254 wants to merge 1 commit into
Conversation
🎉 Thank you for your Pull Request, @MathewTech254!Welcome to AIML Club OCT! 🚀 A maintainer will review your code shortly. In the meantime:
Happy coding! 💻✨ |
|
Hi @MathewTech254! 👋 Thank you so much for this PR! The real-time webcam loop, FPS calculation, normalized multi-label handling (\helmetless, \No_Helmet, etc.), and 10-frame drop tolerance are fantastic additions to make the detector actually deployable in live environments. There is currently a small git conflict with the latest \main\ branch in \�eginner/safety-helmet-detector/detect.py\ (due to recent fallback updates). Could you please sync your fork with upstream \main\ and rebase / resolve the conflict? resolve conflicts in detect.py, then:git push --force-with-lease As soon as that's rebased, we are ready to approve and merge this! Appreciate your awesome work! 🚀 |
|
Am on it.
Will push when done.
Thank you for considering my work.
…On Fri, Oct 23, 2026, 12:44 PM Umesh Patel ***@***.***> wrote:
*UmeshCode1* left a comment (AIMLCLUBOCT/Projects#6)
<#6 (comment)>
Hi @MathewTech254 <https://github.com/MathewTech254>! 👋
Thank you so much for this PR! The real-time webcam loop, FPS calculation,
normalized multi-label handling (\helmetless, \No_Helmet, etc.), and
10-frame drop tolerance are fantastic additions to make the detector
actually deployable in live environments.
There is currently a small git conflict with the latest \main\ branch in
\�eginner/safety-helmet-detector/detect.py\ (due to recent fallback
updates).
Could you please sync your fork with upstream \main\ and rebase / resolve
the conflict?
\\�ash
git fetch origin main
git rebase origin/main
resolve conflicts in detect.py, then:
git push --force-with-lease
\\
As soon as that's rebased, we are ready to approve and merge this!
Appreciate your awesome work! 🚀
—
Reply to this email directly, view it on GitHub
<#6?email_source=notifications&email_token=CM4VKUMSVH5Q6EXZJHVUIA35VMSBVA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMZWGIYDQOBQHA2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6362088084>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/CM4VKUOWLG5DD4HSHPG6DFD5VMSBVAVCNFSNUABGKJSXA33TNF2G64TZHMYTAMJRG42DKMBQGY5US43TOVSTWNJWGU4TKNRZHE3DTILWAI>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/CM4VKULYYI52ZNOH3O3RGYL5VMSBVA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMZWGIYDQOBQHA2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y>
and Android
<https://github.com/notifications/mobile/android/CM4VKUJ4YUM37NCXB5OIDNT5VMSBVA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMZWGIYDQOBQHA2KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
What this does
Turns the
detect.pystub into an actual working detector. It pulls frames from your webcam (or a video file), runs them through YOLO, draws the boxes, and puts an FPS counter and a helmet/no-helmet tally in the corner.Press
qto quit.Closes #2
Things I ran into
The default
yolov8n.ptis a COCO model and doesn't have a helmet class, so out of the box it will always sayNO DETECTIONSno matter what you point it at. That's expected — you need weights trained on helmet classes, which you pass with--model. I mentioned it in the--helptext so nobody thinks it's broken.Class names came back in more shapes than I expected, so
classify_labelnormalises them first.Helmet,no-helmet,No_Helmet,helmetlessandwithout helmetall end up in the right bucket. A plain"no" in labelcheck would have worked too, but it also matches things likeNose helmet, which is not a thing, but you get the idea. Also worth knowing: Ultralytics gives younamesas a dict on most models and a list on others, so both are handled.One more: the first version stopped the whole loop the first time a frame failed to read. Webcams drop frames, so now it puts up with 10 in a row before deciding the stream is actually over.
Testing
No webcam here, so I ran the loop against generated video and real photos with the GUI calls stubbed out.
python -m py_compile detect.pyclean,--helpshows all three flags,yolov8n.ptloadsqquits early, end of stream exits cleanNote
Only
detect.pychanged.requirements.txtandREADME.mduntouched.