4

community,

in pytorch (& yolov5) i was able to train two models (one detects cars, the other detects bikes).

I am loading two different models (last.pt files) with the following commands:

model_c = torch.hub.load('ultralytics/yolov5', 'custom', path='/last.pt', force_reload=True)
model_b = torch.hub.load('ultralytics/yolov5', 'custom', path='/last.pt', force_reload=True)

I use an image for the model to detect cars or bikes in:

img = os.path.join('data', 'images', 'traffic.jpg')

The results command can show the model detection for cars:

results = model_c(img)
results.print()

..or bikes:

results = model_b(img)
results.print()

Question 1:

How can the results of cars and bikes detections be shown in the same image at the same time?

Question 2:

Is there a way to combine two model pt.files into one?

Thank you very much in advance.

Phil Harmony
  • 41
  • 1
  • 2

0 Answers0