YOLO 여러 장의 사진 예측 코드

#
#-------------------------------------#
#                
#-------------------------------------#
# from yolo import YOLO
# from PIL import Image

# yolo = 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)
#         r_image.show()
#         

from yolo import YOLO
from PIL import Image
import os

yolo = YOLO()
filepath ="/diskb/jyz/ddata/bus2/"
filename = os.listdir(filepath)
while True:
    for i in filename:
        print(i)
        image = i.strip().split(".")
        j=i.split(".")[0]
        # print(image)
        # print(j)
#           split  。

    # img = input('Input image filename:')
        try:
            img = image[0]+".jpg"
            imag = os.path.join(filepath,img)
            im = Image.open(imag)
            print(im)
        except:
            
            print('Open Error! Try again!')
            continue
        else:
            r_image = yolo.detect_image(im)
            r_image.save('/diskb/jyz/ddata/bus1/'+ j +'.jpg')
        break

좋은 웹페이지 즐겨찾기