2021SC@SDUSC
接上篇
run yolo_video.py
def detect_img(yolo):
while True:
img = input('Input image filename:') #输入一张图片
try:
image = Image.open(img)
except:
print('Open Error! Try again!')
continue
else:
r_image = yolo.detect_image(image) #进入yolo.detect_image 进行检测
r_image.show()
yolo.close_session()
detect_image()函数在yolo.py第102行
def detect_image(self, image):
start = timer()
if self.model_image_size != (None, None): #判断图片是否存在
assert self.model_image_size[0]%32 == 0, 'Multiples of 32 required'
assert self.model_image_size[1]%32 == 0, 'Multiples of 32 required'
#assert断言语句的语法格式 model_image_size[0][1]指图像的w和h,且必须是32的整数倍
boxed_image = letterbox_