Merge branch 'develop' into develop

This commit is contained in:
shaohua.zhang
2020-07-30 22:33:17 +08:00
committed by GitHub
11 changed files with 65 additions and 36 deletions
+15 -2
View File
@@ -15,6 +15,8 @@
import logging
import os
import imghdr
import cv2
from paddle import fluid
def initial_logger():
@@ -62,7 +64,7 @@ def get_image_file_list(img_file):
if img_file is None or not os.path.exists(img_file):
raise Exception("not found any img file in {}".format(img_file))
img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff'}
img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif', 'GIF'}
if os.path.isfile(img_file) and imghdr.what(img_file) in img_end:
imgs_lists.append(img_file)
elif os.path.isdir(img_file):
@@ -75,7 +77,18 @@ def get_image_file_list(img_file):
return imgs_lists
from paddle import fluid
def check_and_read_gif(img_path):
if os.path.basename(img_path)[-3:] in ['gif', 'GIF']:
gif = cv2.VideoCapture(img_path)
ret, frame = gif.read()
if not ret:
logging.info("Cannot read {}. This gif image maybe corrupted.")
return None, False
if len(frame.shape) == 2 or frame.shape[-1] == 1:
frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
imgvalue = frame[:, :, ::-1]
return imgvalue, True
return None, False
def create_multi_devices_program(program, loss_var_name):