Exemplo n.º 1
0
 def test_close_early(self):
     sampler = UniformSampler(reader=get_dynamic_window_reader(),
                              window_sizes=DYNAMIC_MOD_DATA,
                              batch_size=2,
                              windows_per_image=10,
                              queue_length=10)
     sampler.close_all()
Exemplo n.º 2
0
 def test_close_early(self):
     sampler = UniformSampler(reader=get_dynamic_window_reader(),
                              window_sizes=DYNAMIC_MOD_DATA,
                              batch_size=2,
                              windows_per_image=10,
                              queue_length=10)
     sampler.close_all()
Exemplo n.º 3
0
 def test_ill_init(self):
     with self.assertRaisesRegexp(ValueError, ""):
         sampler = UniformSampler(reader=get_3d_reader(),
                                  window_sizes=MOD_2D_DATA,
                                  batch_size=2,
                                  windows_per_image=10,
                                  queue_length=10)
Exemplo n.º 4
0
 def __init__(self,
              reader,
              window_sizes,
              batch_size=1,
              windows_per_image=1,
              queue_length=10,
              name='balanced_sampler'):
     UniformSampler.__init__(self,
                             reader=reader,
                             window_sizes=window_sizes,
                             batch_size=batch_size,
                             windows_per_image=windows_per_image,
                             queue_length=queue_length,
                             name=name)
     tf.logging.info('Initialised balanced sampler window instance')
     self.window_centers_sampler = balanced_spatial_coordinates
Exemplo n.º 5
0
 def __init__(self,
              reader,
              window_sizes,
              batch_size=1,
              windows_per_image=1,
              queue_length=10,
              name='weighted_sampler'):
     UniformSampler.__init__(self,
                             reader=reader,
                             window_sizes=window_sizes,
                             batch_size=batch_size,
                             windows_per_image=windows_per_image,
                             queue_length=queue_length,
                             name=name)
     tf.logging.info('Initialised weighted sampler window instance')
     self.window_centers_sampler = weighted_spatial_coordinates
Exemplo n.º 6
0
 def test_dynamic_init(self):
     sampler = UniformSampler(reader=get_dynamic_window_reader(),
                              window_sizes=DYNAMIC_MOD_DATA,
                              batch_size=2,
                              windows_per_image=10,
                              queue_length=10)
     with self.test_session() as sess:
         coordinator = tf.train.Coordinator()
         sampler.run_threads(sess, coordinator, num_threads=2)
         out = sess.run(sampler.pop_batch_op())
         self.assertAllClose(out['image'].shape[1:], (8, 2, 256, 2))
     sampler.close_all()
Exemplo n.º 7
0
 def test_dynamic_init(self):
     sampler = UniformSampler(reader=get_dynamic_window_reader(),
                              window_sizes=DYNAMIC_MOD_DATA,
                              batch_size=2,
                              windows_per_image=10,
                              queue_length=10)
     with self.test_session() as sess:
         coordinator = tf.train.Coordinator()
         sampler.run_threads(sess, coordinator, num_threads=2)
         out = sess.run(sampler.pop_batch_op())
         self.assertAllClose(out['image'].shape[1:], (8, 2, 256, 2))
     sampler.close_all()
Exemplo n.º 8
0
 def test_3d_concentric_init(self):
     sampler = UniformSampler(reader=get_concentric_window_reader(),
                              window_sizes=MULTI_WINDOW_DATA,
                              batch_size=2,
                              windows_per_image=10,
                              queue_length=10)
     with self.test_session() as sess:
         coordinator = tf.train.Coordinator()
         sampler.run_threads(sess, coordinator, num_threads=2)
         out = sess.run(sampler.pop_batch_op())
         img_loc = out['image_location']
         seg_loc = out['label_location']
         self.assertTrue(np.all(img_loc[:, 0] == seg_loc[:, 0]))
         self.assertTrue(np.all((img_loc - seg_loc)[:, 1:4] == [1, 1, 0]))
         self.assertTrue(np.all((img_loc - seg_loc)[:, 4:] == [-2, -1, 1]))
         self.assertAllClose(out['image'].shape, (2, 4, 10, 3, 1))
         self.assertAllClose(out['label'].shape, (2, 7, 12, 2, 1))
     sampler.close_all()
Exemplo n.º 9
0
 def test_3d_concentric_init(self):
     sampler = UniformSampler(reader=get_concentric_window_reader(),
                              window_sizes=MULTI_WINDOW_DATA,
                              batch_size=2,
                              windows_per_image=10,
                              queue_length=10)
     with self.test_session() as sess:
         coordinator = tf.train.Coordinator()
         sampler.run_threads(sess, coordinator, num_threads=2)
         out = sess.run(sampler.pop_batch_op())
         img_loc = out['image_location']
         seg_loc = out['label_location']
         self.assertTrue(np.all(img_loc[:, 0] == seg_loc[:, 0]))
         self.assertTrue(np.all((img_loc - seg_loc)[:, 1:4] == [1, 1, 0]))
         self.assertTrue(np.all((img_loc - seg_loc)[:, 4:] == [-2, -1, 1]))
         self.assertAllClose(out['image'].shape, (2, 4, 10, 3, 1))
         self.assertAllClose(out['label'].shape, (2, 7, 12, 2, 1))
     sampler.close_all()