
Ultimate Guide to Setting Up YOLOv5 on macOS for Object Detection
Learn how to set up YOLOv5 on your Mac for advanced object detection using PyTorch and Torch. Follow the steps to install necessary packages, clone repositories, and run detection scripts efficiently. Explore the world of YOLOv5 and start detecting objects today!
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
2021 For Mac YOLOv5
MAC Python 3.8 python.org mac https://www.python.org/downloads/release/python-388/
1. project YOLOCOCO 2. install torch 3. git clone labelImg 4. git clone yolov5 5. yolo5 requirements.txt 6. detect00.py 7. detect01.py 8. detect02.py
1.project YOLOCOCO (data/images)
PyTorch Facebook 2017 Torch Python Python Python PyTorch https://reurl.cc/8375Yg
https://pytorch.org/get-started/locally/ Mac pip3 install torch torchvision torchaudio -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
ternimal git clone https://github.com/tzutalin/labelImg
ternimal git clone https://github.com/ultralytics/yolov5
ternimal cd yolov5 pip install -r requirements.txt
import torch import cv2 import numpy as np model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # print(model) img=cv2.imread('IMG_2997.JPG') results = model(img) results.print() print(results.xyxy) cv2.imshow('YOLO COCO', np.squeeze(results.render())) cv2.waitKey(0)
import torch import numpy as np import cv2 model = torch.hub.load('ultralytics/yolov5', 'yolov5s') cap = cv2.VideoCapture(0) while cap.isOpened(): success, frame = cap.read() if not success: print("Ignoring empty camera frame.") continue results = model(frame) cv2.imshow( YOLO COCO 01', np.squeeze(results.render())) if cv2.waitKey(1) & 0xFF == 27: break cap.release() cv2.destroyAllWindows()
import torch import numpy as np import cv2 import time prev_time = 0 model = torch.hub.load('ultralytics/yolov5', 'yolov5s') cap = cv2.VideoCapture("https://cctvn.freeway.gov.tw/abs2mjpg/bmjpg?camera=13380") while cap.isOpened(): success, frame = cap.read() if not success: print("Ignoring empty camera frame.") continue frame = cv2.resize(frame,(960,540)) results = model(frame) output_image = np.squeeze(results.render()) cv2.putText(output_image, f'FPS: {int(1 / (time.time() - prev_time))} , (3, 40), cv2.FONT_HERSHEY_PLAIN, 3, (0, 0, 255), 3) prev_time = time.time() cv2.imshow('YOLO COCO 02', output_image) if cv2.waitKey(1) & 0xFF == 27: break cap.release() cv2.destroyAllWindows()
import pafy url = "https://www.youtube.com/watch?v=r9dlwCs4JmE" # url = "https://www.youtube.com/watch?v=E87M8LRlnKQ" live = pafy.new(url) stream = live.getbest(preftype="mp4") cap = cv2.VideoCapture(stream.url)
=== pafy youtube-dl === 1. pycharm pafy 2. pycharm Youtube-dl2 3. pycharm terminal pip install -U youtube-dl Mac terminal open "/Applications/Python 3.8/Install Certificates.command"