Skip to content

Instantly share code, notes, and snippets.

@PranjalDureja0002
Created May 7, 2021 11:40
Show Gist options
  • Save PranjalDureja0002/fde82d4dd6785d4b4a365eaf94bee1e7 to your computer and use it in GitHub Desktop.
Save PranjalDureja0002/fde82d4dd6785d4b4a365eaf94bee1e7 to your computer and use it in GitHub Desktop.
table
def normalize_image(input_image):
input_image = tf.cast(input_image, tf.float32) / 255.0
return input_image
def decode_image(img):
img = tf.image.decode_jpeg(img)
return tf.image.resize(img, [img_height, img_width])
def decode_mask_image(img):
img = tf.image.decode_jpeg(img, channels=1)
return tf.image.resize(img, [img_height, img_width])
def p1(file_path):
file_path_new = file_path
col_path = tf.strings.regex_replace(file_path_new, 'cs2_table', 'cs2_col')
file_path_f = tf.strings.regex_replace(col_path, 'cs2_col', 'data_cs2')
file_path_q = tf.strings.regex_replace(file_path_f, '.jpeg', '.jpg')
file_actual = normalize_image(decode_image(tf.io.read_file(file_path_q)))
table_mask = normalize_image(decode_mask_image(tf.io.read_file(file_path_new)))
column_mask = normalize_image(decode_mask_image(tf.io.read_file(col_path)))
#tf.print(col_path)
return file_actual, {"table_output" : table_mask, "column_output" : column_mask }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment