示例#1
0
def see_big_img():
    yolo = YOLO()
    with open('train.txt') as f:
        lines = f.readlines()
    np.random.shuffle(lines)
    for k in lines[:50]:
        line = k.split()
        img2 = draw(line)
        try:
            image = cv2.imread(line[0])
            if image is None:
                raise FileNotFoundError('666')
        except Exception:
            print('Open Error! Try again!')
            continue
        else:
            image = yolo.detect_big_image(image)
            cv2.imshow('img', image)
            cv2.imshow('img1', img2)
            cv2.waitKey(0)
            cv2.destroyAllWindows()
        k = input('233')
        if k.lower() == 'q':
            break
    yolo.close_session()
示例#2
0
def detect_img():
    yolo = YOLO()
    while True:
        img = input('Input image filename(input Q to exit):')
        if img.lower() == 'q':
            yolo.close_session()
            return
        try:
            image = cv2.imread(img)
            if image is None:
                raise FileNotFoundError('666')
        except Exception:
            print('Open Error! Try again!')
            continue
        else:
            r_image = yolo.detect_big_image(image)
            cv2.imshow('img', r_image)
            cv2.waitKey(0)
            cv2.destroyWindow('img')
    yolo.close_session()