3588适配
This commit is contained in:
15
detect.py
15
detect.py
@ -15,7 +15,7 @@ from utils.plots import plot_one_box
|
||||
from utils.torch_utils import select_device, load_classifier, time_synchronized
|
||||
|
||||
|
||||
def detect(opt, save_img=False):
|
||||
def detect(opt, model, stride, save_img=False):
|
||||
source, weights, view_img, save_txt, imgsz = opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size
|
||||
save_img = not opt.nosave and not source.endswith('.txt') # save inference images
|
||||
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(
|
||||
@ -31,12 +31,15 @@ def detect(opt, save_img=False):
|
||||
half = device.type != 'cpu' # half precision only supported on CUDA
|
||||
|
||||
# Load model
|
||||
model = attempt_load(weights, map_location=device) # load FP32 model
|
||||
stride = int(model.stride.max()) # model stride
|
||||
# model = attempt_load(weights, map_location=device) # load FP32 model
|
||||
# stride = int(model.stride.max()) # model stride
|
||||
imgsz = check_img_size(imgsz, s=stride) # check img_size
|
||||
if half:
|
||||
model.half() # to FP16
|
||||
model.eval()
|
||||
# if half:
|
||||
# model.half() # to FP16
|
||||
# model.eval()
|
||||
model = model
|
||||
|
||||
|
||||
# Second-stage classifier
|
||||
classify = False
|
||||
if classify:
|
||||
|
Reference in New Issue
Block a user