def testSimple(self): labels = [9, 3, 0] records = [self._record(labels[0], 0, 128, 255), self._record(labels[1], 255, 0, 1), self._record(labels[2], 254, 255, 0)] i = len(records) contents = b"".join([record for record, _ in records]) expected = [expected for _, expected in records] filename = os.path.join('/tmp', "cifar_test.bin") open(filename, "wb").write(contents) with self.test_session() as sess: q = tf.FIFOQueue(99, [tf.string], shapes=()) q.enqueue([filename]).run() q.close().run() result = cifar10_input.read_cifar10(q) for i in range(3): key, label, uint8image = sess.run([ result.key, result.label, result.uint8image]) print("the value of key"+key) # print(label) # print(uint8image) # print(expected[i]) self.assertEqual("%s:%d" % (filename, i), compat.as_text(key)) self.assertEqual(labels[i], label) self.assertAllEqual(expected[i], uint8image) with self.assertRaises(tf.errors.OutOfRangeError): sess.run([result.key, result.uint8image])
def testSimple(self): labels = [9, 3, 0] records = [ self._record(labels[0], 0, 128, 255), self._record(labels[1], 255, 0, 1), self._record(labels[2], 254, 255, 0) ] i = len(records) contents = b"".join([record for record, _ in records]) expected = [expected for _, expected in records] filename = os.path.join('/tmp', "cifar_test.bin") open(filename, "wb").write(contents) with self.test_session() as sess: q = tf.FIFOQueue(99, [tf.string], shapes=()) q.enqueue([filename]).run() q.close().run() result = cifar10_input.read_cifar10(q) for i in range(3): key, label, uint8image = sess.run( [result.key, result.label, result.uint8image]) print("the value of key" + key) # print(label) # print(uint8image) # print(expected[i]) self.assertEqual("%s:%d" % (filename, i), compat.as_text(key)) self.assertEqual(labels[i], label) self.assertAllEqual(expected[i], uint8image) with self.assertRaises(tf.errors.OutOfRangeError): sess.run([result.key, result.uint8image])
def testSimple2(self): # url = '/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/' # labels = [1, 2, 3, 4] # images = ['N20031221G035621.bmp', 'N20031221G031111.bmp', 'N20031221G101531.bmp', 'N20031222G041721.bmp'] # # results, expectes = self.img2list(url, labels, images) # i = len(results) # contents = b"".join(results) # expected = [expected for expected in expectes] # filename = os.path.join('/tmp', "aurora_test.bin") # open(filename, "wb").write(contents) labels = 3 expected, nums = self.gen_bin_files( '/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/') # filename = '/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/bin_files/type1_data21.bin' filename = '/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/bin_files_128/type3_data03.bin' with self.test_session() as sess: q = tf.FIFOQueue(10000, [tf.string], shapes=()) q.enqueue([filename]).run() q.close().run() result = input_data.read_aurora(q) for i in range(nums): key, label, uint8image = sess.run( [result.key, result.label, result.uint8image]) # print("the value of key"+key) print(label) # print(len(uint8image), len(uint8image[0]), len(uint8image[0][1])) # print(uint8image) # print(expected[i]) self.assertEqual("%s:%d" % (filename, i), compat.as_text(key)) self.assertEqual(labels, label) self.assertAllEqual(expected[i], uint8image) with self.assertRaises(tf.errors.OutOfRangeError): sess.run([result.key, result.uint8image])
def testSimple2(self): # url = '/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/' # labels = [1, 2, 3, 4] # images = ['N20031221G035621.bmp', 'N20031221G031111.bmp', 'N20031221G101531.bmp', 'N20031222G041721.bmp'] # # results, expectes = self.img2list(url, labels, images) # i = len(results) # contents = b"".join(results) # expected = [expected for expected in expectes] # filename = os.path.join('/tmp', "aurora_test.bin") # open(filename, "wb").write(contents) labels = 3 expected, nums = self.gen_bin_files('/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/') # filename = '/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/bin_files/type1_data21.bin' filename = '/home/aurora/hdd/workspace/PycharmProjects/data/aurora2/bin_files_128/type3_data03.bin' with self.test_session() as sess: q = tf.FIFOQueue(10000, [tf.string], shapes=()) q.enqueue([filename]).run() q.close().run() result = input_data.read_aurora(q) for i in range(nums): key, label, uint8image = sess.run([ result.key, result.label, result.uint8image]) # print("the value of key"+key) print(label) # print(len(uint8image), len(uint8image[0]), len(uint8image[0][1])) # print(uint8image) # print(expected[i]) self.assertEqual("%s:%d" % (filename, i), compat.as_text(key)) self.assertEqual(labels, label) self.assertAllEqual(expected[i], uint8image) with self.assertRaises(tf.errors.OutOfRangeError): sess.run([result.key, result.uint8image])