Beispiel #1
0
def parse_img_with_aug(img):
    img = tf.io.decode_image(img,
                             channels=all_var_dict['target_shape'][-1],
                             dtype=tf.dtypes.float32,
                             expand_animations=False)
    img = augment_img(img, 16, 200, all_var_dict['target_shape'])
    # img = tf.image.resize_with_pad(img, all_var_dict['target_shape'][1],
    #                             all_var_dict['target_shape'][0])
    return img
def parse_model1(path, label):
    img = tf.io.read_file(path)
    img = parse_img(img)
    if AUGMENT:
        img = metadata.augment_img(img, 6, target_shape)
    label = all_var_dict['ok_lookup'].lookup(label)
    onehot_label = tf.one_hot(label, all_var_dict['LABEL_NUM'], dtype='int64')
    onehot_label = tf.cast(onehot_label, dtype=tf.float32)
    return img, onehot_label
def parse_other_com_to_morecomp(path):
    img = tf.io.read_file(path)
    img = parse_img(img)
    if AUGMENT:
        img = metadata.augment_img(img, 6, target_shape)
    label = all_var_dict['ok_lookup'].lookup(
        tf.constant('NG-MoreComp', dtype=tf.string))
    onehot_label = tf.one_hot(label, all_var_dict['LABEL_NUM'], dtype='int64')
    onehot_label = tf.cast(onehot_label, dtype=tf.float32)
    return img, onehot_label
def process_ng(path, degree):
    byte_string_img = tf.io.read_file(path)
    img = tf.io.decode_image(byte_string_img,
                             channels=target_shape[-1],
                             dtype=tf.dtypes.float32)
    #     img = tf.image.convert_image_dtype(img, tf.float32)
    img = tf.image.resize_with_crop_or_pad(img, target_shape[1],
                                           target_shape[0])
    if AUGMENT:
        img = metadata.augment_img(img, 6, target_shape)
    deg = ng_lookup.lookup(degree)
    onehot_degree = tf.one_hot(deg, DEGREE_NUM, dtype='int64')
    return img, onehot_degree