mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2026-09-21 13:23:18 +08:00
Merge branch 'develop' into develop
This commit is contained in:
+15
-2
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user