0

I wanted to do character detection in the game via yolov5 But so far I have just started to study it all How to train custom data, I know But I don't know how to tell yolo in the code so that it detects custom data in the screenshot that I make using mss, and numpy and I broadcast these screenshots using cv2.imshow thanks in advance

I tried different ways, but nothing worked, I looked in the official documentation. but without success

2

1 Answer 1

0

Using Custom Model

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
4
  • You can find out more or an article on this topic
    – localhost
    Commented Dec 14, 2022 at 8:40
  • @ХлебКрутой I recommend if your dataset can be public, you can use Roboflow, Label the Data, then while exporting add some augmentations and then train on Googe Colab. For More Tutorials visit github.com/ultralytics/yolov5 Commented Dec 14, 2022 at 9:09
  • understood, but I need a little more information about the line: model = burner.the hub.load ( etc . )
    – localhost
    Commented Dec 14, 2022 at 17:33
  • @ХлебКрутой When you have trained your custom model it will give a best.pt model in YOLOv5 directory. Here in the path/to/best.pt you specify that path to the best.pt to use your custom model. Commented Dec 14, 2022 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.