How not to end the program and switch weights? #7836
Replies: 1 comment 1 reply
-
@1372764481 👋 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 model1 = torch.hub.load('ultralytics/yolov5', 'custom', 'path/to/best1.pt')
model2 = torch.hub.load('ultralytics/yolov5', 'custom', 'path/to/best2.pt')
model3 = torch.hub.load('ultralytics/yolov5', 'custom', 'path/to/best3.pt') Simple Inference ExampleThis example loads a pretrained YOLOv5s model from PyTorch Hub as 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! |
Beta Was this translation helpful? Give feedback.
-
I want to switch different weight files for mo target detection in different situations, but I don't want to end or restart the program. Is there any way?
Beta Was this translation helpful? Give feedback.
All reactions