2021YOLOv5 Project: Installation, Setup, and Object Detection

2021YOLOv5 Project: Installation, Setup, and Object Detection
Slide Note
Embed
Share

This project focuses on setting up YOLOv5 for object detection tasks. It covers the installation of necessary tools like Torch, LabelImg, and YOLOv5. Step-by-step guides and code snippets are provided for setting up the environment, cloning repositories, installing requirements, and running detection scripts. PyTorch, Torch, and YOLOv5 are essential components used in this project, with references to relevant resources for further exploration.

  • YOLOv5
  • Object Detection
  • PyTorch
  • Torch
  • Installation

Uploaded on Feb 24, 2025 | 2 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 YOLOv5

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

  3. 1.project YOLOCOCO (data/images)

  4. 2. install torch

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

  6. https://pytorch.org/get-started/locally/ Win: pip3 install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio===0.8.1 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html

  7. 3. git clone labelImg

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

  9. 4. git clone yolov5

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

  11. 5. yolo5requirements.txt

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

  13. 6. detect00.py

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

  15. 7. detect01.py

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

  17. 8. detect02.py

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

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

Related


More Related Content