Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local AI with YOLOv5 #53

Open
mrlt8 opened this issue Jun 12, 2021 · 1 comment
Open

Local AI with YOLOv5 #53

mrlt8 opened this issue Jun 12, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@mrlt8
Copy link
Contributor

mrlt8 commented Jun 12, 2021

Not really a feature request, but a quick example to get local AI on the wyze stream with yolov5 using 14 lines of code!

yolov5 requirements: pip install -r https://raw.githubusercontent.com/ultralytics/yolov5/master/requirements.txt

import os
import cv2
import wyzecam
import torch

model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
auth_info = wyzecam.login(os.environ["WYZE_EMAIL"], os.environ["WYZE_PASSWORD"])
account = wyzecam.get_user_info(auth_info)
camera = wyzecam.get_camera_list(auth_info)[0]

with wyzecam.WyzeIOTC() as wyze_iotc:
    with wyze_iotc.connect_and_auth(account, camera) as sess:
        for (frame, frame_info) in sess.recv_video_frame_ndarray():
            results = model(frame)
            cv2.imshow("Video Feed", results.render()[0].copy())
            cv2.waitKey(1)
@mrlt8 mrlt8 added the enhancement New feature or request label Jun 12, 2021
Repository owner deleted a comment from github-actions bot Jun 18, 2021
@bsharper
Copy link

I'm doing something similar to this (though I'm using the RTSP firmware).

I used TrainYourOwnYOLO to create an image classifier that can recognize USPS, UPS and Fedex logos. When they are detected it triggers a motion event which sends my phone and watch a preview image. This automatically logs the times when these trucks make deliveries, so I have a better idea when to expect deliveries in the future.

I also save off the images and the coordinates of what was recognized to a file, which I first verify and then feed back into the training data. I trained a tiny-yolo model, so I'm able to run the whole thing on a raspberry pi 4. I actually ended up adding a delay after each detection to reduce the number of duplicate images (and to keep the pi4 from running too hot).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants