def _process_files(paths, **params_decode): paths = [paths] if not isinstance(paths, list) else paths import modules.data.decode_tf as decode_tf import tensorflow as tf # IMPROVE: accept different kinds of input data data_list = [] for path in paths: data_list.append(decode_tf.decode_image_file(tf.convert_to_tensor(path), **params_decode)) data_t = tf.data.Dataset.from_tensor_slices(data_list) return data_t
def wrapper_decode_image_file(file_name_t, folder_id_t): # NOTE: cannot use ordinary string operations here, use Tensor instead # path = osp.join(root_path, folder_name, file_name) folder_name_t = vocabulary_t[folder_id_t] path_t = tf.strings.join([root_path_t, folder_name_t, file_name_t], '/') # Updating: consider use **decode_x in map_func # return decode_tf.decode_image_file( # path_t, encoding=None, colormode=colormode, # resize_w=resize_w, resize_h=resize_h, # normalize=normalize, preserve_aspect_ratio=preserve_aspect_ratio # ) return decode_tf.decode_image_file(path_t, **params_decode)
def map_path_to_image(path_t): return decode_tf.decode_image_file(path_t, **params_decode)