Ultimate Guide to Setting Up YOLOv5 on macOS for Object Detection

slide1 n.w
1 / 22
Embed
Share

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!

  • macOS
  • YOLOv5
  • PyTorch
  • Object Detection
  • Tutorial

Uploaded on | 0 Views


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


  1. 2021 For Mac YOLOv5

  2. MAC Python 3.8 python.org mac https://www.python.org/downloads/release/python-388/

  3. 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

  4. 1.project YOLOCOCO (data/images)

  5. 2. install torch

  6. PyTorch Facebook 2017 Torch Python Python Python PyTorch https://reurl.cc/8375Yg

  7. https://pytorch.org/get-started/locally/ Mac pip3 install torch torchvision torchaudio -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html

  8. 3. git clone labelImg

  9. ternimal git clone https://github.com/tzutalin/labelImg

  10. 4. git clone yolov5

  11. ternimal git clone https://github.com/ultralytics/yolov5

  12. 5. yolo5requirements.txt

  13. ternimal cd yolov5 pip install -r requirements.txt

  14. 6. detect00.py

  15. 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)

  16. 7. detect01.py

  17. 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()

  18. 8. detect02.py

  19. 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()

  20. 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)

  21. === 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"

Related


More Related Content