Closed oes5756 closed 2 years ago
👋 Hello @oes5756, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.
If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.
Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.
@oes5756 👋 Hello! Thanks for asking about handling inference results. YOLOv5 🚀 PyTorch Hub models allow for simple model loading and inference in a pure python environment without using detect.py
.
You can export data to Excel from pandas: https://pandas.pydata.org/docs/reference/api/pandas.ExcelWriter.html
This example loads a pretrained YOLOv5s model from PyTorch Hub as model
and passes an image for inference. 'yolov5s'
is the YOLOv5 'small' model. For details on all available models please see the README. Custom models can also be loaded, including custom trained PyTorch models and their exported variants, i.e. ONNX, TensorRT, TensorFlow, OpenVINO YOLOv5 models.
import torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # yolov5n - yolov5x6 official model
# 'custom', 'path/to/best.pt') # custom model
# Images
im = 'https://ultralytics.com/images/zidane.jpg' # or file, Path, URL, PIL, OpenCV, numpy, list
# Inference
results = model(im)
# Results
results.print() # or .show(), .save(), .crop(), .pandas(), etc.
results.xyxy[0] # im predictions (tensor)
results.pandas().xyxy[0] # im predictions (pandas)
# xmin ymin xmax ymax confidence class name
# 0 749.50 43.50 1148.0 704.5 0.874023 0 person
# 2 114.75 195.75 1095.0 708.0 0.624512 0 person
# 3 986.00 304.00 1028.0 420.0 0.286865 27 tie
results.pandas().xyxy[0].value_counts('name') # class counts (pandas)
# person 2
# tie 1
See YOLOv5 PyTorch Hub Tutorial for details.
Good luck 🍀 and let us know if you have any other questions!
@glenn-jocher But the time when it's detected doesn't come out. What should I do if I want to mark the time?
@glenn-jocher When operating with YOLO webcam, log recording is recorded in real time. As if the log is being recorded in real time It's an Excel file that shows the detected time I want to get the detection result value through the webcam.
@mintu07ruet Can you tell me how to successfully timestamp Excel?
@oes5756 , Did you check this page, where I have shared the whole code? Thanks! https://github.com/ultralytics/yolov5/issues/1097#issuecomment-1172009392
@mintu07ruet Did you modify the whole detect.py?
@oes5756 part of it. You can compare with original one to check the modification.
@mintu07ruet https://github.com/ultralytics/yolov5 = my detect.py There are a few different parts in the detect.py file and "import" that I used. Isn't that a problem?
@mintu07ruet What's the execution order? This is what I do it "python detect.py --source 0 --save-txt"
@oes5756 , I am not sure what additional things you added. For my case, I have added additional code just for recording time stamp and object. It is also important to know which version you are using. I have used yolov5, if you are using same version like me, make sure to switch the master branch using git checkout f5b8f7d and also get the corresponding weight from bottom of this page https://github.com/ultralytics/yolov5/releases/tag/v5.0
Here is my execution code
python detect3.py --weights yolov5s.pt --conf 0.65 --class 0 1 3 17 36 --source Exp_2021630_10_1_15.avi --save-txt
I have detected person, bicycle, car, skateboard and so on. if you are using webcam, yes after source it should be 0 as you used.
@mintu07ruet
import argparse import os import sys from pathlib import Path
import torch import torch.backends.cudnn as cudnn
FILE = Path(file).resolve() ROOT = FILE.parents[0] # YOLOv5 root directory if str(ROOT) not in sys.path: sys.path.append(str(ROOT)) # add ROOT to PATH ROOT = Path(os.path.relpath(ROOT, Path.cwd())) # relative
from models.common import DetectMultiBackend from utils.datasets import IMG_FORMATS, VID_FORMATS, LoadImages, LoadStreams from utils.general import (LOGGER, check_file, check_img_size, check_imshow, check_requirements, colorstr, cv2, increment_path, non_max_suppression, print_args, scale_coords, strip_optimizer, xyxy2xywh) from utils.plots import Annotator, colors, save_one_box from utils.torch_utils import select_device, time_sync import time
my "import" part Do I not need to add an import?
It is a little difficult because there is something different from your import part. I'm sorry
@oes5756 I think that you are confused about the version. I have used the older version (https://github.com/ultralytics/yolov5/blob/v5.0/detect.py) as I mentioned. That's why you may see it differently from yourself! However, your current import may not work with my rest of the code. As they are continuously updating yolo. But you may modify and add your code to record it from your cuurent version. Thanks!
@mintu07ruet Is the link you gave me the yolov5 version you tried?
@mintu07ruet Can I get the link to the version of yolo that you used? I changed only detect.py, but I get an error "cannot import name 'plot_one_box' from 'utils.plots'"
@oes5756 I have already provided the link to you for the detect.py and also shared mine, you need to just switch the branch on your current installation and download the weight (yolov5s.pt) as I mentioned in my previous comment. That's all.
@oes5756 here is my rough guidelines Step1: Download github for Desktops- https://git-scm.com/download/win and install it, install python and pip if you need from here https://www.python.org/downloads/release/python-3100/ https://www.geeksforgeeks.org/how-to-install-pip-on-windows/ if you need to fix the environment https://projects.raspberrypi.org/en/projects/using-pip-on-windows/4 Fix the path if you need setx PATH "%PATH%;C:\Python34\Scripts"
Download weight from the below link page (at the bottom) https://github.com/ultralytics/yolov5/releases/tag/v5.0
At the bottom of this page, there is a list of all the assets. Download the correct asset (yolov5s.pt) and put it into the detect1.py directory.
Step2: open your command prompt and run the following code
git clone https://github.com/ultralytics/yolov5
cd yolov5
git checkout f5b8f7d
pip install -qr requirements.txt # install
python detect3.py --weights yolov5s.pt --conf 0.65 --class 0 1 3 17 36 --source Exp_2021630_10_1_15.avi --save-txt
0= Person 1= Bicycle 3= motorcycle 17=Horse 36= Skateboard
@mintu07ruet I'm sorry. It's my first time using Github I downloaded it. yolov5 all file https://github.com/ultralytics/yolov5 -> code -> "download ZIP" but The link you sent me new version yolov5 is no "download ZIP"
I want to download the all yolov5 new versin files. Because plots.py seems to be changing.
I'm sorry to keep asking you questions.
@mintu07ruet I was confused. The one I used is a new version That's the old version you used Is it correct?
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.
Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!
Search before asking
Question
Log value output with --save-txt. But I'm going to use log values with timestamps I'd like to print it out in Excel. Help me
Additional
No response