Skip to content

Instantly share code, notes, and snippets.

View AtiqueUrRehman's full-sized avatar

Atique Ur Rehman AtiqueUrRehman

  • Automotive Artificial Intelligence
  • Islamabad
View GitHub Profile
@AtiqueUrRehman
AtiqueUrRehman / images_to_tfrecords_threaded
Last active November 20, 2017 17:00
An example of converting images to tfrecords, in this case we have an image-to-image mapping, so we have some input images and corresponding label images. Correspoing reading code is in comments below. A simpler barebones example is here : https://gist.github.com/AtiqueUrRehman/dfeeea0397fa5588619ebf193717ac0c
# coding: utf-8
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@AtiqueUrRehman
AtiqueUrRehman / images_to_tfrecords
Created February 11, 2017 16:09
An example of converting images to tfrecords, in this case we have an image-to-image mapping, so we have some input images and corresponding label images. Correspoing reading code is in comments below.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from datetime import datetime
import os
import random
import sys
import threading
import math
@AtiqueUrRehman
AtiqueUrRehman / images_to_tfrecords
Created February 11, 2017 16:11
An example of converting images to tfrecords, in this case we have an image-to-image mapping, so we have some input images and corresponding label images. Correspoing reading code is in comments below. The code is barebones and non threaded for simpplicity a threaded example is here : https://gist.github.com/AtiqueUrRehman/c1ccc7a76115262e20e507…
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from datetime import datetime
import os
import random
import sys
import threading
import math
@AtiqueUrRehman
AtiqueUrRehman / read_tfrecords_batches
Created February 11, 2017 18:11
Read the examples in tfrecords files in batches using Tensorflow queue runners
import tensorflow as tf
def read_and_decode_example(filename_queue):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
# Defaults are not specified since both keys are required.
features={
'label/image/encoded': tf.FixedLenFeature([], tf.string),