Skip to content

How do I use CUDA with a custom model? #2630

@Pro100rus32

Description

@Pro100rus32

❔Question

Code:

import torch
import cv2
from PIL import Image
from time import sleep, time
import numpy as np
# Model
model = torch.hub.load('ultralytics/yolov5', 'custom', path_or_model='last.pt')
# Images
img = Image.open('test.png')
# convert image to numpy array
img = np.asarray(img)

# Inference
stime = time()
results = model(img, size=608)
print(time() - stime) #0.8 sec

speed: 1frame - 0.78sec (cpu)

detect.py
speed: 0.04sec (With CUDA)

is much faster

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions