This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import utils | |
class Reader(): | |
def __init__(self, tfrecords_file, image_size=256, | |
min_queue_examples=1000, batch_size=1, num_threads=8, name=''): | |
""" | |
Args: | |
tfrecords_file: string, tfrecords file path | |
min_queue_examples: integer, minimum number of samples to retain in the queue that provides of batches of examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import listdir | |
from os.path import isfile, join | |
import tensorflow as tf | |
def get_image(path, height, width, preprocess_fn): | |
png = path.lower().endswith('png') | |
img_bytes = tf.read_file(path) | |
image = tf.image.decode_png(img_bytes, channels=3) if png else tf.image.decode_jpeg(img_bytes, channels=3) | |
return preprocess_fn(image, height, width) |