Closed rusvagzur closed 2 years ago
@rusvagzur you can use detect.py with --save-label
. This will create labels in YOLOv5 format. You can also use PyTorch Hub for custom python workflows.
YOLOv5 🚀 PyTorch Hub models allow for simple model loading and inference in a pure python environment without using detect.py
.
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') # or yolov5m, yolov5l, yolov5x, etc.
# model = torch.hub.load('ultralytics/yolov5', 'custom', 'path/to/best.pt') # custom trained 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
See YOLOv5 PyTorch Hub Tutorial for details.
Good luck 🍀 and let us know if you have any other questions!
@rusvagzur you can use detect.py with
--save-label
. This will create labels in YOLOv5 format. You can also use PyTorch Hub for custom python workflows.
--save-label does not seem to exist for me
usage: detect.py [-h] [--weights WEIGHTS [WEIGHTS ...]] [--source SOURCE]
[--data DATA] [--imgsz IMGSZ [IMGSZ ...]]
[--conf-thres CONF_THRES] [--iou-thres IOU_THRES]
[--max-det MAX_DET] [--device DEVICE] [--view-img]
[--save-txt] [--save-conf] [--save-crop] [--nosave]
[--classes CLASSES [CLASSES ...]] [--agnostic-nms]
[--augment] [--visualize] [--update] [--project PROJECT]
[--name NAME] [--exist-ok] [--line-thickness LINE_THICKNESS]
[--hide-labels] [--hide-conf] [--half] [--dnn]
detect.py: error: unrecognized arguments: --save-label
@RainierKlopper detect.py uses --save-txt to save labels in txt format
Search before asking
Question
Hi Ultralytics team,
I would like to use the help of Yolov5 to annotate my custom set of images instead of annotating them manually from scratch.
Is there a way of obtaining a coco-format file as output using Yolov5 inference on a set of images? I thought this could be my starting point to continue annotating later. If not, maybe this opens a new way of using Yolov5: as automatic object detection annotator :)
Many thanks in advance and keep up the good work
Additional
No response